mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use binding for ime conversion mode
This commit is contained in:
parent
a93bafedd8
commit
ce303156fb
4 changed files with 39 additions and 31 deletions
31
Flow.Launcher/Converters/BoolToIMEConversionModeConverter.cs
Normal file
31
Flow.Launcher/Converters/BoolToIMEConversionModeConverter.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Flow.Launcher.Converters
|
||||
{
|
||||
internal class BoolToIMEConversionModeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool v)
|
||||
{
|
||||
if (v)
|
||||
{
|
||||
return ImeConversionModeValues.Alphanumeric;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ImeConversionModeValues.DoNotCare;
|
||||
}
|
||||
}
|
||||
return ImeConversionModeValues.DoNotCare;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
|
||||
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
|
||||
Name="FlowMainWindow"
|
||||
Title="Flow Launcher"
|
||||
MinWidth="{Binding MainWindowWidth, Mode=OneWay}"
|
||||
|
|
@ -37,6 +38,7 @@
|
|||
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
|
||||
<converters:BorderClipConverter x:Key="BorderClipConverter" />
|
||||
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
|
||||
<converters:BoolToIMEConversionModeConverter x:Key="BoolToIMEConversionModeConverter"/>
|
||||
</Window.Resources>
|
||||
<Window.InputBindings>
|
||||
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
|
||||
|
|
@ -204,6 +206,7 @@
|
|||
PreviewKeyUp="QueryTextBox_KeyUp"
|
||||
Style="{DynamicResource QueryBoxStyle}"
|
||||
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}"
|
||||
Visibility="Visible">
|
||||
<TextBox.CommandBindings>
|
||||
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
|
||||
|
|
|
|||
|
|
@ -20,22 +20,9 @@ using Flow.Launcher.Infrastructure;
|
|||
using System.Windows.Media;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using System.Text;
|
||||
using DataObject = System.Windows.DataObject;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.IO;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows.Data;
|
||||
using ModernWpf.Controls;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms.Design.Behavior;
|
||||
using System.Security.Cryptography;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.VisualBasic.Devices;
|
||||
using Microsoft.FSharp.Data.UnitSystems.SI.UnitNames;
|
||||
using NLog.Targets;
|
||||
using YamlDotNet.Core.Tokens;
|
||||
using Key = System.Windows.Input.Key;
|
||||
|
||||
namespace Flow.Launcher
|
||||
|
|
@ -131,7 +118,6 @@ namespace Flow.Launcher
|
|||
UpdatePosition();
|
||||
PreviewReset();
|
||||
Activate();
|
||||
QueryTextBox_StartEn();
|
||||
QueryTextBox.Focus();
|
||||
_settings.ActivateTimes++;
|
||||
if (!_viewModel.LastQuerySelected)
|
||||
|
|
@ -195,9 +181,6 @@ namespace Flow.Launcher
|
|||
case nameof(Settings.Language):
|
||||
UpdateNotifyIconText();
|
||||
break;
|
||||
case nameof(Settings.AlwaysStartEn):
|
||||
QueryTextBox_StartEn();
|
||||
break;
|
||||
case nameof(Settings.Hotkey):
|
||||
UpdateNotifyIconText();
|
||||
break;
|
||||
|
|
@ -703,19 +686,5 @@ namespace Flow.Launcher
|
|||
be.UpdateSource();
|
||||
}
|
||||
}
|
||||
|
||||
private void QueryTextBox_StartEn()
|
||||
{
|
||||
if (_settings.AlwaysStartEn)
|
||||
{
|
||||
QueryTextBox.SetValue(InputMethod.PreferredImeConversionModeProperty, ImeConversionModeValues.Alphanumeric);
|
||||
QueryTextBox.SetValue(InputMethod.PreferredImeStateProperty, InputMethodState.Off);
|
||||
}
|
||||
else
|
||||
{
|
||||
QueryTextBox.ClearValue(InputMethod.PreferredImeConversionModeProperty);
|
||||
QueryTextBox.ClearValue(InputMethod.PreferredImeStateProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ namespace Flow.Launcher.ViewModel
|
|||
case nameof(Settings.WindowSize):
|
||||
OnPropertyChanged(nameof(MainWindowWidth));
|
||||
break;
|
||||
case nameof(Settings.AlwaysStartEn):
|
||||
OnPropertyChanged(nameof(StartWithEnglishMode));
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -514,6 +517,8 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
public string Image => Constant.QueryTextBoxIconImagePath;
|
||||
|
||||
public bool StartWithEnglishMode => Settings.AlwaysStartEn;
|
||||
|
||||
#endregion
|
||||
|
||||
public void Query()
|
||||
|
|
|
|||
Loading…
Reference in a new issue