diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs index 8493d192d..190412f43 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs @@ -2,8 +2,6 @@ using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Infrastructure.UserSettings; -using NHotkey; -using NHotkey.Wpf; using System; using System.Collections.ObjectModel; using System.Linq; diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs index e653e8280..d5fcabace 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -113,5 +113,24 @@ namespace Flow.Launcher.Helper mainViewModel.ChangeQueryText(hotkey.ActionKeyword); }); } + + internal static bool CheckAvailability(HotkeyModel currentHotkey) + { + try + { + HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", currentHotkey.CharKey, currentHotkey.ModifierKeys, (sender, e) => { }); + + return true; + } + catch + { + } + finally + { + HotkeyManager.Current.Remove("HotkeyAvailabilityTest"); + } + + return false; + } } } diff --git a/Flow.Launcher/HotkeyControl.xaml.cs b/Flow.Launcher/HotkeyControl.xaml.cs index ed90e40af..be971c8ab 100644 --- a/Flow.Launcher/HotkeyControl.xaml.cs +++ b/Flow.Launcher/HotkeyControl.xaml.cs @@ -4,8 +4,8 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; -using NHotkey.Wpf; using Flow.Launcher.Core.Resource; +using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Plugin; @@ -92,24 +92,7 @@ namespace Flow.Launcher SetHotkey(new HotkeyModel(keyStr), triggerValidate); } - private bool CheckHotkeyAvailability() - { - try - { - HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", CurrentHotkey.CharKey, CurrentHotkey.ModifierKeys, (sender, e) => { }); - - return true; - } - catch - { - } - finally - { - HotkeyManager.Current.Remove("HotkeyAvailabilityTest"); - } - - return false; - } + private bool CheckHotkeyAvailability() => HotKeyMapper.CheckAvailability(CurrentHotkey); public new bool IsFocused { diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 8e5b647f3..5b9706a32 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -6,8 +6,6 @@ using System.Threading.Tasks; using System.Threading.Tasks.Dataflow; using System.Windows; using System.Windows.Input; -using NHotkey; -using NHotkey.Wpf; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Core.Resource; using Flow.Launcher.Helper;