mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #2722 from Flow-Launcher/fix-decimal
Fix bug and typo in Calculator Plugin
This commit is contained in:
commit
6eb8ef687c
13 changed files with 28 additions and 34 deletions
|
|
@ -96,13 +96,10 @@ namespace Flow.Launcher.Core.Resource
|
|||
{
|
||||
LoadLanguage(language);
|
||||
}
|
||||
// Culture of this thread
|
||||
// Use CreateSpecificCulture to preserve possible user-override settings in Windows
|
||||
// Culture of main thread
|
||||
// Use CreateSpecificCulture to preserve possible user-override settings in Windows, if Flow's language culture is the same as Windows's
|
||||
CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture(language.LanguageCode);
|
||||
CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture;
|
||||
// App domain
|
||||
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture(language.LanguageCode);
|
||||
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture;
|
||||
|
||||
// Raise event after culture is set
|
||||
Settings.Language = language.LanguageCode;
|
||||
|
|
@ -193,7 +190,7 @@ namespace Flow.Launcher.Core.Resource
|
|||
{
|
||||
p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle();
|
||||
p.Metadata.Description = pluginI18N.GetTranslatedPluginDescription();
|
||||
pluginI18N.OnCultureInfoChanged(CultureInfo.DefaultThreadCurrentCulture);
|
||||
pluginI18N.OnCultureInfoChanged(CultureInfo.CurrentCulture);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class QuerySuggestionBoxConverter : IMultiValueConverter
|
|||
// Check if Text will be larger than our QueryTextBox
|
||||
Typeface typeface = new Typeface(queryTextBox.FontFamily, queryTextBox.FontStyle, queryTextBox.FontWeight, queryTextBox.FontStretch);
|
||||
// TODO: Obsolete warning?
|
||||
var ft = new FormattedText(queryTextBox.Text, CultureInfo.DefaultThreadCurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, queryTextBox.FontSize, Brushes.Black);
|
||||
var ft = new FormattedText(queryTextBox.Text, CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, queryTextBox.FontSize, Brushes.Black);
|
||||
|
||||
var offset = queryTextBox.Padding.Right;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ namespace Flow.Launcher.SettingPages.ViewModels;
|
|||
|
||||
public partial class SettingsPaneThemeViewModel : BaseModel
|
||||
{
|
||||
private CultureInfo Culture => CultureInfo.DefaultThreadCurrentCulture;
|
||||
|
||||
public Settings Settings { get; }
|
||||
|
||||
public static string LinkHowToCreateTheme => @"https://flowlauncher.com/docs/#/how-to-create-a-theme";
|
||||
|
|
@ -136,9 +134,9 @@ public partial class SettingsPaneThemeViewModel : BaseModel
|
|||
set => Settings.DateFormat = value;
|
||||
}
|
||||
|
||||
public string ClockText => DateTime.Now.ToString(TimeFormat, Culture);
|
||||
public string ClockText => DateTime.Now.ToString(TimeFormat, CultureInfo.CurrentCulture);
|
||||
|
||||
public string DateText => DateTime.Now.ToString(DateFormat, Culture);
|
||||
public string DateText => DateTime.Now.ToString(DateFormat, CultureInfo.CurrentCulture);
|
||||
|
||||
public double WindowWidthSize
|
||||
{
|
||||
|
|
|
|||
|
|
@ -485,7 +485,6 @@ namespace Flow.Launcher.ViewModel
|
|||
public Settings Settings { get; }
|
||||
public string ClockText { get; private set; }
|
||||
public string DateText { get; private set; }
|
||||
public CultureInfo Culture => CultureInfo.DefaultThreadCurrentCulture;
|
||||
|
||||
private async Task RegisterClockAndDateUpdateAsync()
|
||||
{
|
||||
|
|
@ -494,9 +493,9 @@ namespace Flow.Launcher.ViewModel
|
|||
while (await timer.WaitForNextTickAsync().ConfigureAwait(false))
|
||||
{
|
||||
if (Settings.UseClock)
|
||||
ClockText = DateTime.Now.ToString(Settings.TimeFormat, Culture);
|
||||
ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture);
|
||||
if (Settings.UseDate)
|
||||
DateText = DateTime.Now.ToString(Settings.DateFormat, Culture);
|
||||
DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System.ComponentModel;
|
||||
using Flow.Launcher.Core.Resource;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Caculator
|
||||
namespace Flow.Launcher.Plugin.Calculator
|
||||
{
|
||||
[TypeConverter(typeof(LocalizationConverter))]
|
||||
public enum DecimalSeparator
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<ProjectGuid>{59BD9891-3837-438A-958D-ADC7F91F6F7E}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Flow.Launcher.Plugin.Caculator</RootNamespace>
|
||||
<AssemblyName>Flow.Launcher.Plugin.Caculator</AssemblyName>
|
||||
<RootNamespace>Flow.Launcher.Plugin.Calculator</RootNamespace>
|
||||
<AssemblyName>Flow.Launcher.Plugin.Calculator</AssemblyName>
|
||||
<UseWPF>true</UseWPF>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>portable</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.Caculator\</OutputPath>
|
||||
<OutputPath>..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.Calculator\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\Release\Plugins\Flow.Launcher.Plugin.Caculator\</OutputPath>
|
||||
<OutputPath>..\..\Output\Release\Plugins\Flow.Launcher.Plugin.Calculator\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ using System.Text.RegularExpressions;
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Mages.Core;
|
||||
using Flow.Launcher.Plugin.Caculator.ViewModels;
|
||||
using Flow.Launcher.Plugin.Caculator.Views;
|
||||
using Flow.Launcher.Plugin.Calculator.ViewModels;
|
||||
using Flow.Launcher.Plugin.Calculator.Views;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Caculator
|
||||
namespace Flow.Launcher.Plugin.Calculator
|
||||
{
|
||||
public class Main : IPlugin, IPluginI18n, ISettingProvider
|
||||
{
|
||||
|
|
@ -62,7 +62,7 @@ namespace Flow.Launcher.Plugin.Caculator
|
|||
switch (_settings.DecimalSeparator)
|
||||
{
|
||||
case DecimalSeparator.Comma:
|
||||
case DecimalSeparator.UseSystemLocale when CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NumberDecimalSeparator == ",":
|
||||
case DecimalSeparator.UseSystemLocale when CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator == ",":
|
||||
expression = query.Search.Replace(",", ".");
|
||||
break;
|
||||
default:
|
||||
|
|
@ -158,7 +158,7 @@ namespace Flow.Launcher.Plugin.Caculator
|
|||
|
||||
private string GetDecimalSeparator()
|
||||
{
|
||||
string systemDecimalSeperator = CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NumberDecimalSeparator;
|
||||
string systemDecimalSeperator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
|
||||
switch (_settings.DecimalSeparator)
|
||||
{
|
||||
case DecimalSeparator.UseSystemLocale: return systemDecimalSeperator;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Caculator
|
||||
namespace Flow.Launcher.Plugin.Calculator
|
||||
{
|
||||
/// <summary>
|
||||
/// Tries to convert all numbers in a text from one culture format to another.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
namespace Flow.Launcher.Plugin.Caculator
|
||||
namespace Flow.Launcher.Plugin.Calculator
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Caculator.ViewModels
|
||||
namespace Flow.Launcher.Plugin.Calculator.ViewModels
|
||||
{
|
||||
public class SettingsViewModel : BaseModel
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
<UserControl
|
||||
x:Class="Flow.Launcher.Plugin.Caculator.Views.CalculatorSettings"
|
||||
x:Class="Flow.Launcher.Plugin.Calculator.Views.CalculatorSettings"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:calculator="clr-namespace:Flow.Launcher.Plugin.Caculator"
|
||||
xmlns:calculator="clr-namespace:Flow.Launcher.Plugin.Calculator"
|
||||
xmlns:core="clr-namespace:Flow.Launcher.Core.Resource;assembly=Flow.Launcher.Core"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="clr-namespace:Flow.Launcher.Infrastructure.UI;assembly=Flow.Launcher.Infrastructure"
|
||||
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Caculator.ViewModels"
|
||||
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Calculator.ViewModels"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
Loaded="CalculatorSettings_Loaded"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Flow.Launcher.Plugin.Caculator.ViewModels;
|
||||
using Flow.Launcher.Plugin.Calculator.ViewModels;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Caculator.Views
|
||||
namespace Flow.Launcher.Plugin.Calculator.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CalculatorSettings.xaml
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
"Name": "Calculator",
|
||||
"Description": "Provide mathematical calculations.(Try 5*3-2 in Flow Launcher)",
|
||||
"Author": "cxfksword",
|
||||
"Version": "3.1.0",
|
||||
"Version": "3.1.1",
|
||||
"Language": "csharp",
|
||||
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
|
||||
"ExecuteFileName": "Flow.Launcher.Plugin.Caculator.dll",
|
||||
"ExecuteFileName": "Flow.Launcher.Plugin.Calculator.dll",
|
||||
"IcoPath": "Images\\calculator.png"
|
||||
}
|
||||
Loading…
Reference in a new issue