7
7
using System . Windows . Input ;
8
8
using System . Windows . Controls ;
9
9
using Flow . Launcher . Core ;
10
+ using Flow . Launcher . ViewModel ;
10
11
11
12
namespace Flow . Launcher
12
13
{
13
14
public partial class CustomQueryHotkeySetting : Window
14
15
{
15
16
private SettingWindow _settingWidow ;
17
+ private readonly Settings _settings ;
18
+ private readonly MainViewModel _mainViewModel ;
16
19
private bool update ;
17
20
private CustomPluginHotkey updateCustomHotkey ;
18
- public Settings Settings { get ; }
19
21
20
- public CustomQueryHotkeySetting ( SettingWindow settingWidow , Settings settings )
22
+ public CustomQueryHotkeySetting ( SettingWindow settingWidow , Settings settings , MainViewModel mainVM )
21
23
{
22
24
_settingWidow = settingWidow ;
23
- Settings = settings ;
25
+ _settings = settings ;
26
+ _mainViewModel = mainVM ;
24
27
InitializeComponent ( ) ;
25
28
}
26
29
@@ -33,13 +36,13 @@ private void btnAdd_OnClick(object sender, RoutedEventArgs e)
33
36
{
34
37
if ( ! update )
35
38
{
36
- Settings . CustomPluginHotkeys ??= new ObservableCollection < CustomPluginHotkey > ( ) ;
39
+ _settings . CustomPluginHotkeys ??= new ObservableCollection < CustomPluginHotkey > ( ) ;
37
40
38
41
var pluginHotkey = new CustomPluginHotkey
39
42
{
40
43
Hotkey = HotkeyControl . CurrentHotkey . ToString ( ) , ActionKeyword = tbAction . Text
41
44
} ;
42
- Settings . CustomPluginHotkeys . Add ( pluginHotkey ) ;
45
+ _settings . CustomPluginHotkeys . Add ( pluginHotkey ) ;
43
46
44
47
HotKeyMapper . SetCustomQueryHotkey ( pluginHotkey ) ;
45
48
}
@@ -59,7 +62,7 @@ private void btnAdd_OnClick(object sender, RoutedEventArgs e)
59
62
60
63
public void UpdateItem ( CustomPluginHotkey item )
61
64
{
62
- updateCustomHotkey = Settings . CustomPluginHotkeys . FirstOrDefault ( o =>
65
+ updateCustomHotkey = _settings . CustomPluginHotkeys . FirstOrDefault ( o =>
63
66
o . ActionKeyword == item . ActionKeyword && o . Hotkey == item . Hotkey ) ;
64
67
if ( updateCustomHotkey == null )
65
68
{
@@ -77,8 +80,7 @@ public void UpdateItem(CustomPluginHotkey item)
77
80
private void BtnTestActionKeyword_OnClick ( object sender , RoutedEventArgs e )
78
81
{
79
82
App . API . ChangeQuery ( tbAction . Text ) ;
80
- Application . Current . MainWindow . Show ( ) ;
81
- Application . Current . MainWindow . Opacity = 1 ;
83
+ _mainViewModel . Show ( false ) ;
82
84
Application . Current . MainWindow . Focus ( ) ;
83
85
}
84
86
0 commit comments