6
6
using System . Windows ;
7
7
using System . Windows . Controls ;
8
8
using Mages . Core ;
9
- using Flow . Launcher . Infrastructure . Storage ;
10
9
using Flow . Launcher . Plugin . Caculator . ViewModels ;
11
10
using Flow . Launcher . Plugin . Caculator . Views ;
12
11
@@ -25,6 +24,9 @@ public class Main : IPlugin, IPluginI18n, ISettingProvider
25
24
@")+$" , RegexOptions . Compiled ) ;
26
25
private static readonly Regex RegBrackets = new Regex ( @"[\(\)\[\]]" , RegexOptions . Compiled ) ;
27
26
private static Engine MagesEngine ;
27
+ private const string comma = "," ;
28
+ private const string dot = "." ;
29
+
28
30
private PluginInitContext Context { get ; set ; }
29
31
30
32
private static Settings _settings ;
@@ -60,7 +62,7 @@ public List<Result> Query(Query query)
60
62
{
61
63
case DecimalSeparator . Comma :
62
64
case DecimalSeparator . UseSystemLocale when CultureInfo . CurrentCulture . NumberFormat . NumberDecimalSeparator == "," :
63
- expression = query . Search . Replace ( ". " , ", " ) ;
65
+ expression = query . Search . Replace ( ", " , ". " ) ;
64
66
break ;
65
67
default :
66
68
expression = query . Search ;
@@ -132,6 +134,10 @@ private bool CanCalculate(Query query)
132
134
return false ;
133
135
}
134
136
137
+ if ( ( query . Search . Contains ( dot ) && GetDecimalSeparator ( ) != dot ) ||
138
+ ( query . Search . Contains ( comma ) && GetDecimalSeparator ( ) != comma ) )
139
+ return false ;
140
+
135
141
return true ;
136
142
}
137
143
@@ -155,8 +161,8 @@ private string GetDecimalSeparator()
155
161
switch ( _settings . DecimalSeparator )
156
162
{
157
163
case DecimalSeparator . UseSystemLocale : return systemDecimalSeperator ;
158
- case DecimalSeparator . Dot : return "." ;
159
- case DecimalSeparator . Comma : return "," ;
164
+ case DecimalSeparator . Dot : return dot ;
165
+ case DecimalSeparator . Comma : return comma ;
160
166
default : return systemDecimalSeperator ;
161
167
}
162
168
}
0 commit comments