mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev' into Fix-'100%-CPU'-BrowserBookmark-issue
This commit is contained in:
commit
522d7debe8
34 changed files with 222 additions and 181 deletions
|
|
@ -1,5 +1,7 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
|
||||
<!-- Work around https://github.com/dotnet/runtime/issues/109682 -->
|
||||
<CETCompat>false</CETCompat>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -136,7 +136,6 @@
|
|||
|
||||
<Target Name="RemoveDuplicateAnalyzers" BeforeTargets="CoreCompile">
|
||||
<!-- Work around https://github.com/dotnet/wpf/issues/6792 -->
|
||||
|
||||
<ItemGroup>
|
||||
<FilteredAnalyzer Include="@(Analyzer->Distinct())" />
|
||||
<Analyzer Remove="@(Analyzer)" />
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@
|
|||
FontSize="14"
|
||||
ItemContainerStyle="{StaticResource PluginList}"
|
||||
ItemsSource="{Binding Source={StaticResource PluginCollectionView}}"
|
||||
Loaded="PluginListBox_Loaded"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
SnapsToDevicePixels="True"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Navigation;
|
||||
|
|
@ -33,6 +35,14 @@ public partial class SettingsPanePlugins
|
|||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
private void PluginListBox_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// After list is loaded, we need to clear selection to make sure all items can be mouse hovered
|
||||
// because the selected item cannot be hovered.
|
||||
if (sender is not ListBox listBox) return;
|
||||
listBox.SelectedIndex = -1;
|
||||
}
|
||||
|
||||
private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(SettingsPanePluginsViewModel.FilterText))
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">آلة حاسبة</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">تمكنك من إجراء العمليات الحسابية. (جرب 5*3-2 في Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">آلة حاسبة</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">تمكنك من إجراء العمليات الحسابية. (جرب 5*3-2 في Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">ليست رقمًا (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">التعبير خاطئ أو غير مكتمل (هل نسيت بعض الأقواس؟)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">نسخ هذا الرقم إلى الحافظة</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Kalkulačka</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Umožňuje provádět matematické výpočty.(Try 5*3-2 v průtokovém spouštěči)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Kalkulačka</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Umožňuje provádět matematické výpočty.(Try 5*3-2 v průtokovém spouštěči)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Není číslo (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Nesprávný nebo neúplný výraz (Nezapomněli jste na závorky?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Kopírování výsledku do schránky</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calculator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Allows to do mathematical calculations.(Try 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Calculator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Allows to do mathematical calculations.(Try 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Not a number (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expression wrong or incomplete (Did you forget some parentheses?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Copy this number to the clipboard</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Rechner</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Ermöglicht mathematische Berechnungen. (Versuchen Sie 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Rechner</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Ermöglicht mathematische Berechnungen. (Versuchen Sie 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Nicht eine Zahl (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Ausdruck falsch oder unvollständig (Haben Sie einige Klammern vergessen?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Diese Zahl in die Zwischenablage kopieren</system:String>
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calculator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Allows to do mathematical calculations.(Try 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Calculator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Perform mathematical calculations (including hexadecimal values). Use ',' or '.' as thousand separator or decimal place.</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Not a number (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expression wrong or incomplete (Did you forget some parentheses?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Copy this number to the clipboard</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calculadora</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Permite hacer cálculos matemáticos. (Pruebe con 5*3-2 en Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Calculadora</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Permite hacer cálculos matemáticos. (Pruebe con 5*3-2 en Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">No es un número (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expresión incorrecta o incompleta (¿Olvidó algún paréntesis?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Copiar este número al portapapeles</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calculadora</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Permite hacer cálculos matemáticos. (Pruebe 5*3-2 en Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Calculadora</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Permite hacer cálculos matemáticos. (Pruebe 5*3-2 en Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">No es un número (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expresión incorrecta o incompleta (¿Ha olvidado algunos paréntesis?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Copiar este número al portapapeles</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calculatrice</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Permet de faire des calculs mathématiques.(Essayez 5*3-2 dans Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Calculatrice</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Permet de faire des calculs mathématiques.(Essayez 5*3-2 dans Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Pas un nombre (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expression incorrecte ou incomplète (avez-vous oublié certaines parenthèses ?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Copier ce chiffre dans le presse-papiers</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">מחשבון</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">מאפשר לבצע חישובים מתמטיים. (נסה 5*3-2 ב-Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">מחשבון</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">מאפשר לבצע חישובים מתמטיים. (נסה 5*3-2 ב-Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">לא מספר (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">הביטוי שגוי או לא שלם (האם שכחת סוגריים?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">העתק מספר זה ללוח</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calcolatrice</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Consente di eseguire calcoli matematici (provare 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Calcolatrice</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Consente di eseguire calcoli matematici (provare 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Non è un numero (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Espressione sbagliata o incompleta (avete dimenticato delle parentesi?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Copiare questo numero negli appunti</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">電卓</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">数式の計算ができます(Flow Launcherで「5*3-2」と入力してみてください)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">電卓</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">数式の計算ができます(Flow Launcherで「5*3-2」と入力してみてください)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Not a number (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expression wrong or incomplete (Did you forget some parentheses?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">この数字をクリップボードにコピーします</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">계산기</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">수학 계산을 할 수 있습니다. Flow Launcher에서 5*3-2를 입력해보세요.</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">계산기</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">수학 계산을 할 수 있습니다. Flow Launcher에서 5*3-2를 입력해보세요.</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">숫자가 아님 (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">표현식이 잘못되었거나 불완전합니다. (괄호를 깜빡하셨나요?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">해당 숫자를 클립보드에 복사</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Kalkulator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Lar deg gjøre matematiske beregninger. (Prøv 5*3-2 i Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Kalkulator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Lar deg gjøre matematiske beregninger. (Prøv 5*3-2 i Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Ikke et tall (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Uttrykk feil eller ufullstendig (glem noen parenteser?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Kopier dette nummeret til utklippstavlen</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calculator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Allows to do mathematical calculations.(Try 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Calculator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Allows to do mathematical calculations.(Try 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Not a number (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expression wrong or incomplete (Did you forget some parentheses?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Copy this number to the clipboard</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Kalkulator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Szybkie wykonywanie obliczeń matematycznych. (Spróbuj wpisać 5*3-2 w oknie Flow Launchera)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Kalkulator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Szybkie wykonywanie obliczeń matematycznych. (Spróbuj wpisać 5*3-2 w oknie Flow Launchera)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Nie liczba (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Wyrażenie niepoprawne lub niekompletne (Czy zapomniałeś o nawiasach?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Skopiuj ten numer do schowka</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calculadora</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Permite fazer cálculos matemáticos.(Tente 5*3-2 no Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Calculadora</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Permite fazer cálculos matemáticos.(Tente 5*3-2 no Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Não é um número (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expressão errada ou incompleta (Você esqueceu de adicionar parênteses?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Copiar este numero para a área de transferência</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calculadora</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Permite a execução de cálculos matemáticos (experimente 5*3-2)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Calculadora</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Permite a execução de cálculos matemáticos (experimente 5*3-2)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Não é número (NN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expressão errada ou incompleta (esqueceu-se de algum parêntese?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Copiar número para a área de transferência</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Калькулятор</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Позволяет выполнять математические вычисления. (Попробуйте 5*3-2 в Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Калькулятор</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Позволяет выполнять математические вычисления. (Попробуйте 5*3-2 в Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Не является числом (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Выражение неправильное или неполное (Вы забыли скобки?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Скопировать этот номер в буфер обмена</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Kalkulačka</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Spracúva matematické operácie. (Skúste 5*3-2 vo Flow Launcheri)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Kalkulačka</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Spracúva matematické operácie. (Skúste 5*3-2 vo Flow Launcheri)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Nie je číslo (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Nesprávny alebo neúplný výraz (Nezabudli ste na zátvorky?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Kopírovať výsledok do schránky</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calculator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Allows to do mathematical calculations.(Try 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Calculator</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Allows to do mathematical calculations.(Try 5*3-2 in Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Not a number (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expression wrong or incomplete (Did you forget some parentheses?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Copy this number to the clipboard</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Hesap Makinesi</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Matematiksel hesaplamalar yapmaya yarar. (5*3-2 yazmayı deneyin)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Hesap Makinesi</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Matematiksel hesaplamalar yapmaya yarar. (5*3-2 yazmayı deneyin)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Sayı değil (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">İfade hatalı ya da eksik. (Parantez koymayı mı unuttunuz?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Bu sayıyı panoya kopyala</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Калькулятор</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Дозволяє виконувати математичні обчислення (спробуйте 5*3-2 у Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Калькулятор</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Дозволяє виконувати математичні обчислення (спробуйте 5*3-2 у Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Не є числом (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Вираз неправильний або неповний (Ви забули якісь дужки?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Скопіюйте це число в буфер обміну</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Máy tính</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Cho phép thực hiện các phép tính toán học. (Thử 5*3-2 trong Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">Máy tính</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">Cho phép thực hiện các phép tính toán học. (Thử 5*3-2 trong Flow Launcher)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">Không phải là số (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Biểu thức sai hoặc không đầy đủ (Bạn có quên một số dấu ngoặc đơn không?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">Sao chép số này vào clipboard</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">计算器</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">为 Flow Launcher 提供数学计算能力。(试着在 Flow Launcher 输入 5*3-2)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">计算器</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">为 Flow Launcher 提供数学计算能力。(试着在 Flow Launcher 输入 5*3-2)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">请输入数字</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">表达错误或不完整(您是否忘记了一些括号?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">将结果复制到剪贴板</system:String>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">計算機</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">為 Flow Launcher 提供數學計算功能。(試著在 Flow Launcher 輸入 5*3-2)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_name">計算機</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_plugin_description">為 Flow Launcher 提供數學計算功能。(試著在 Flow Launcher 輸入 5*3-2)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_not_a_number">不是一個數 (NaN)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_expression_not_complete">Expression wrong or incomplete (Did you forget some parentheses?)</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_calculator_copy_number_to_clipboard">複製此數至剪貼簿</system:String>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Controls;
|
||||
|
|
@ -14,6 +15,9 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
{
|
||||
private static readonly Regex RegValidExpressChar = MainRegexHelper.GetRegValidExpressChar();
|
||||
private static readonly Regex RegBrackets = MainRegexHelper.GetRegBrackets();
|
||||
private static readonly Regex ThousandGroupRegex = MainRegexHelper.GetThousandGroupRegex();
|
||||
private static readonly Regex NumberRegex = MainRegexHelper.GetNumberRegex();
|
||||
|
||||
private static Engine MagesEngine;
|
||||
private const string Comma = ",";
|
||||
private const string Dot = ".";
|
||||
|
|
@ -23,6 +27,16 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
private Settings _settings;
|
||||
private SettingsViewModel _viewModel;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the formatting information for a single query.
|
||||
/// This is used to ensure thread safety by keeping query state local.
|
||||
/// </summary>
|
||||
private class ParsingContext
|
||||
{
|
||||
public string InputDecimalSeparator { get; set; }
|
||||
public bool InputUsesGroupSeparators { get; set; }
|
||||
}
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
{
|
||||
Context = context;
|
||||
|
|
@ -45,20 +59,11 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
return new List<Result>();
|
||||
}
|
||||
|
||||
var context = new ParsingContext();
|
||||
|
||||
try
|
||||
{
|
||||
string expression;
|
||||
|
||||
switch (_settings.DecimalSeparator)
|
||||
{
|
||||
case DecimalSeparator.Comma:
|
||||
case DecimalSeparator.UseSystemLocale when CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator == ",":
|
||||
expression = query.Search.Replace(",", ".");
|
||||
break;
|
||||
default:
|
||||
expression = query.Search;
|
||||
break;
|
||||
}
|
||||
var expression = NumberRegex.Replace(query.Search, m => NormalizeNumber(m.Value, context));
|
||||
|
||||
var result = MagesEngine.Interpret(expression);
|
||||
|
||||
|
|
@ -71,7 +76,7 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
if (!string.IsNullOrEmpty(result?.ToString()))
|
||||
{
|
||||
decimal roundedResult = Math.Round(Convert.ToDecimal(result), _settings.MaxDecimalPlaces, MidpointRounding.AwayFromZero);
|
||||
string newResult = ChangeDecimalSeparator(roundedResult, GetDecimalSeparator());
|
||||
string newResult = FormatResult(roundedResult, context);
|
||||
|
||||
return new List<Result>
|
||||
{
|
||||
|
|
@ -107,9 +112,137 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
return new List<Result>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a string representation of a number, detecting its format. It uses structural analysis
|
||||
/// and falls back to system culture for truly ambiguous cases (e.g., "1,234").
|
||||
/// It populates the provided ParsingContext with the detected format for later use.
|
||||
/// </summary>
|
||||
/// <returns>A normalized number string with '.' as the decimal separator for the Mages engine.</returns>
|
||||
private string NormalizeNumber(string numberStr, ParsingContext context)
|
||||
{
|
||||
var systemGroupSep = CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator;
|
||||
int dotCount = numberStr.Count(f => f == '.');
|
||||
int commaCount = numberStr.Count(f => f == ',');
|
||||
|
||||
// Case 1: Unambiguous mixed separators (e.g., "1.234,56")
|
||||
if (dotCount > 0 && commaCount > 0)
|
||||
{
|
||||
context.InputUsesGroupSeparators = true;
|
||||
if (numberStr.LastIndexOf('.') > numberStr.LastIndexOf(','))
|
||||
{
|
||||
context.InputDecimalSeparator = Dot;
|
||||
return numberStr.Replace(Comma, string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.InputDecimalSeparator = Comma;
|
||||
return numberStr.Replace(Dot, string.Empty).Replace(Comma, Dot);
|
||||
}
|
||||
}
|
||||
|
||||
// Case 2: Only dots
|
||||
if (dotCount > 0)
|
||||
{
|
||||
if (dotCount > 1)
|
||||
{
|
||||
context.InputUsesGroupSeparators = true;
|
||||
return numberStr.Replace(Dot, string.Empty);
|
||||
}
|
||||
// A number is ambiguous if it has a single Dot in the thousands position,
|
||||
// and does not start with a "0." or "."
|
||||
bool isAmbiguous = numberStr.Length - numberStr.LastIndexOf('.') == 4
|
||||
&& !numberStr.StartsWith("0.")
|
||||
&& !numberStr.StartsWith(".");
|
||||
if (isAmbiguous)
|
||||
{
|
||||
if (systemGroupSep == Dot)
|
||||
{
|
||||
context.InputUsesGroupSeparators = true;
|
||||
return numberStr.Replace(Dot, string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.InputDecimalSeparator = Dot;
|
||||
return numberStr;
|
||||
}
|
||||
}
|
||||
else // Unambiguous decimal (e.g., "12.34" or "0.123" or ".123")
|
||||
{
|
||||
context.InputDecimalSeparator = Dot;
|
||||
return numberStr;
|
||||
}
|
||||
}
|
||||
|
||||
// Case 3: Only commas
|
||||
if (commaCount > 0)
|
||||
{
|
||||
if (commaCount > 1)
|
||||
{
|
||||
context.InputUsesGroupSeparators = true;
|
||||
return numberStr.Replace(Comma, string.Empty);
|
||||
}
|
||||
// A number is ambiguous if it has a single Comma in the thousands position,
|
||||
// and does not start with a "0," or ","
|
||||
bool isAmbiguous = numberStr.Length - numberStr.LastIndexOf(',') == 4
|
||||
&& !numberStr.StartsWith("0,")
|
||||
&& !numberStr.StartsWith(",");
|
||||
if (isAmbiguous)
|
||||
{
|
||||
if (systemGroupSep == Comma)
|
||||
{
|
||||
context.InputUsesGroupSeparators = true;
|
||||
return numberStr.Replace(Comma, string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.InputDecimalSeparator = Comma;
|
||||
return numberStr.Replace(Comma, Dot);
|
||||
}
|
||||
}
|
||||
else // Unambiguous decimal (e.g., "12,34" or "0,123" or ",123")
|
||||
{
|
||||
context.InputDecimalSeparator = Comma;
|
||||
return numberStr.Replace(Comma, Dot);
|
||||
}
|
||||
}
|
||||
|
||||
// Case 4: No separators
|
||||
return numberStr;
|
||||
}
|
||||
|
||||
private string FormatResult(decimal roundedResult, ParsingContext context)
|
||||
{
|
||||
string decimalSeparator = context.InputDecimalSeparator ?? GetDecimalSeparator();
|
||||
string groupSeparator = GetGroupSeparator(decimalSeparator);
|
||||
|
||||
string resultStr = roundedResult.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
string[] parts = resultStr.Split('.');
|
||||
string integerPart = parts[0];
|
||||
string fractionalPart = parts.Length > 1 ? parts[1] : string.Empty;
|
||||
|
||||
if (context.InputUsesGroupSeparators && integerPart.Length > 3)
|
||||
{
|
||||
integerPart = ThousandGroupRegex.Replace(integerPart, groupSeparator);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(fractionalPart))
|
||||
{
|
||||
return integerPart + decimalSeparator + fractionalPart;
|
||||
}
|
||||
|
||||
return integerPart;
|
||||
}
|
||||
|
||||
private string GetGroupSeparator(string decimalSeparator)
|
||||
{
|
||||
// This logic is now independent of the system's group separator
|
||||
// to ensure consistent output for unit testing.
|
||||
return decimalSeparator == Dot ? Comma : Dot;
|
||||
}
|
||||
|
||||
private bool CanCalculate(Query query)
|
||||
{
|
||||
// Don't execute when user only input "e" or "i" keyword
|
||||
if (query.Search.Length < 2)
|
||||
{
|
||||
return false;
|
||||
|
|
@ -125,28 +258,10 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
return false;
|
||||
}
|
||||
|
||||
if ((query.Search.Contains(Dot) && GetDecimalSeparator() != Dot) ||
|
||||
(query.Search.Contains(Comma) && GetDecimalSeparator() != Comma))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string ChangeDecimalSeparator(decimal value, string newDecimalSeparator)
|
||||
{
|
||||
if (string.IsNullOrEmpty(newDecimalSeparator))
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
|
||||
var numberFormatInfo = new NumberFormatInfo
|
||||
{
|
||||
NumberDecimalSeparator = newDecimalSeparator
|
||||
};
|
||||
return value.ToString(numberFormatInfo);
|
||||
}
|
||||
|
||||
private string GetDecimalSeparator()
|
||||
private string GetDecimalSeparator()
|
||||
{
|
||||
string systemDecimalSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
|
||||
return _settings.DecimalSeparator switch
|
||||
|
|
@ -179,12 +294,12 @@ namespace Flow.Launcher.Plugin.Calculator
|
|||
|
||||
public string GetTranslatedPluginTitle()
|
||||
{
|
||||
return Localize.flowlauncher_plugin_caculator_plugin_name();
|
||||
return Localize.flowlauncher_plugin_calculator_plugin_name();
|
||||
}
|
||||
|
||||
public string GetTranslatedPluginDescription()
|
||||
{
|
||||
return Localize.flowlauncher_plugin_caculator_plugin_description();
|
||||
return Localize.flowlauncher_plugin_calculator_plugin_description();
|
||||
}
|
||||
|
||||
public Control CreateSettingPanel()
|
||||
|
|
|
|||
|
|
@ -10,4 +10,10 @@ internal static partial class MainRegexHelper
|
|||
|
||||
[GeneratedRegex(@"^(ceil|floor|exp|pi|e|max|min|det|abs|log|ln|sqrt|sin|cos|tan|arcsin|arccos|arctan|eigval|eigvec|eig|sum|polar|plot|round|sort|real|zeta|bin2dec|hex2dec|oct2dec|factorial|sign|isprime|isinfty|==|~=|&&|\|\||(?:\<|\>)=?|[ei]|[0-9]|0x[\da-fA-F]+|[\+\%\-\*\/\^\., ""]|[\(\)\|\!\[\]])+$", RegexOptions.Compiled)]
|
||||
public static partial Regex GetRegValidExpressChar();
|
||||
|
||||
[GeneratedRegex(@"[\d\.,]+", RegexOptions.Compiled)]
|
||||
public static partial Regex GetNumberRegex();
|
||||
|
||||
[GeneratedRegex(@"\B(?=(\d{3})+(?!\d))", RegexOptions.Compiled)]
|
||||
public static partial Regex GetThousandGroupRegex();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,91 +0,0 @@
|
|||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Calculator
|
||||
{
|
||||
/// <summary>
|
||||
/// Tries to convert all numbers in a text from one culture format to another.
|
||||
/// </summary>
|
||||
public class NumberTranslator
|
||||
{
|
||||
private readonly CultureInfo sourceCulture;
|
||||
private readonly CultureInfo targetCulture;
|
||||
private readonly Regex splitRegexForSource;
|
||||
private readonly Regex splitRegexForTarget;
|
||||
|
||||
private NumberTranslator(CultureInfo sourceCulture, CultureInfo targetCulture)
|
||||
{
|
||||
this.sourceCulture = sourceCulture;
|
||||
this.targetCulture = targetCulture;
|
||||
|
||||
this.splitRegexForSource = GetSplitRegex(this.sourceCulture);
|
||||
this.splitRegexForTarget = GetSplitRegex(this.targetCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="NumberTranslator"/> - returns null if no number conversion
|
||||
/// is required between the cultures.
|
||||
/// </summary>
|
||||
/// <param name="sourceCulture">source culture</param>
|
||||
/// <param name="targetCulture">target culture</param>
|
||||
/// <returns></returns>
|
||||
public static NumberTranslator Create(CultureInfo sourceCulture, CultureInfo targetCulture)
|
||||
{
|
||||
bool conversionRequired = sourceCulture.NumberFormat.NumberDecimalSeparator != targetCulture.NumberFormat.NumberDecimalSeparator
|
||||
|| sourceCulture.NumberFormat.PercentGroupSeparator != targetCulture.NumberFormat.PercentGroupSeparator
|
||||
|| sourceCulture.NumberFormat.NumberGroupSizes != targetCulture.NumberFormat.NumberGroupSizes;
|
||||
return conversionRequired
|
||||
? new NumberTranslator(sourceCulture, targetCulture)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translate from source to target culture.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public string Translate(string input)
|
||||
{
|
||||
return this.Translate(input, this.sourceCulture, this.targetCulture, this.splitRegexForSource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translate from target to source culture.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public string TranslateBack(string input)
|
||||
{
|
||||
return this.Translate(input, this.targetCulture, this.sourceCulture, this.splitRegexForTarget);
|
||||
}
|
||||
|
||||
private string Translate(string input, CultureInfo cultureFrom, CultureInfo cultureTo, Regex splitRegex)
|
||||
{
|
||||
var outputBuilder = new StringBuilder();
|
||||
|
||||
string[] tokens = splitRegex.Split(input);
|
||||
foreach (string token in tokens)
|
||||
{
|
||||
decimal number;
|
||||
outputBuilder.Append(
|
||||
decimal.TryParse(token, NumberStyles.Number, cultureFrom, out number)
|
||||
? number.ToString(cultureTo)
|
||||
: token);
|
||||
}
|
||||
|
||||
return outputBuilder.ToString();
|
||||
}
|
||||
|
||||
private Regex GetSplitRegex(CultureInfo culture)
|
||||
{
|
||||
var splitPattern = $"((?:\\d|{Regex.Escape(culture.NumberFormat.NumberDecimalSeparator)}";
|
||||
if (!string.IsNullOrEmpty(culture.NumberFormat.NumberGroupSeparator))
|
||||
{
|
||||
splitPattern += $"|{Regex.Escape(culture.NumberFormat.NumberGroupSeparator)}";
|
||||
}
|
||||
splitPattern += ")+)";
|
||||
return new Regex(splitPattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls;
|
||||
using Flow.Launcher.Plugin.Calculator.ViewModels;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Calculator.Views
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
"ID": "CEA0FDFC6D3B4085823D60DC76F28855",
|
||||
"ActionKeyword": "*",
|
||||
"Name": "Calculator",
|
||||
"Description": "Perform mathematical calculations (including hexadecimal values)",
|
||||
"Author": "cxfksword",
|
||||
"Description": "Perform mathematical calculations (including hexadecimal values). Use ',' or '.' as thousand separator or decimal place.",
|
||||
"Author": "cxfksword, dcog989",
|
||||
"Version": "1.0.0",
|
||||
"Language": "csharp",
|
||||
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
|
||||
|
|
|
|||
Loading…
Reference in a new issue