11using Flow . Launcher . Core . Resource ;
2- using Flow . Launcher . Helper ;
32using Flow . Launcher . Infrastructure . UserSettings ;
4- using System . Collections . ObjectModel ;
5- using System . Linq ;
3+ using System ;
64using System . Windows ;
75using System . Windows . Input ;
8- using System . Windows . Controls ;
9- using System . Collections . Generic ;
106
117namespace Flow . Launcher
128{
139 public partial class CustomShortcutSetting : Window
1410 {
15- private SettingWindow _settingWidow ;
16- private bool update ;
17- private CustomPluginHotkey updateCustomHotkey ;
1811 private Settings _settings ;
19-
12+ private bool update = false ;
2013 public string Key { get ; set ; }
2114 public string Value { get ; set ; }
22- public ShortCutModel ShortCut => ( Key , Value ) ;
23- public CustomShortcutSetting ( )
15+ public CustomShortcutModel ShortCut => ( Key , Value ) ;
16+
17+ public CustomShortcutSetting ( Settings settings )
2418 {
19+ _settings = settings ;
2520 InitializeComponent ( ) ;
2621 }
2722
28- public CustomShortcutSetting ( ( string , string ) shortcut )
23+ public CustomShortcutSetting ( CustomShortcutModel shortcut , Settings settings )
2924 {
30- ( Key , Value ) = shortcut ;
25+ Key = shortcut . Key ;
26+ Value = shortcut . Value ;
27+ _settings = settings ;
28+ update = true ;
3129 InitializeComponent ( ) ;
3230 }
3331
@@ -37,8 +35,18 @@ private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
3735 Close ( ) ;
3836 }
3937
40- private void btnAdd_OnClick ( object sender , RoutedEventArgs e )
38+ private void BtnAdd_OnClick ( object sender , RoutedEventArgs e )
4139 {
40+ if ( String . IsNullOrEmpty ( Key ) || String . IsNullOrEmpty ( Value ) )
41+ {
42+ MessageBox . Show ( InternationalizationManager . Instance . GetTranslation ( "emptyShortcut" ) ) ;
43+ return ;
44+ }
45+ if ( ! update && ( _settings . CustomShortcuts . Contains ( new CustomShortcutModel ( Key , Value ) ) || _settings . BuiltinShortcuts . Contains ( new BuiltinShortcutModel ( Key , Value , null ) ) ) )
46+ {
47+ MessageBox . Show ( InternationalizationManager . Instance . GetTranslation ( "dulplicateShortcut" ) ) ;
48+ return ;
49+ }
4250 DialogResult = true ;
4351 Close ( ) ;
4452 }
@@ -48,5 +56,13 @@ private void cmdEsc_OnPress(object sender, ExecutedRoutedEventArgs e)
4856 DialogResult = false ;
4957 Close ( ) ;
5058 }
59+
60+ private void BtnTestShortcut_OnClick ( object sender , RoutedEventArgs e )
61+ {
62+ App . API . ChangeQuery ( tbExpand . Text ) ;
63+ Application . Current . MainWindow . Show ( ) ;
64+ Application . Current . MainWindow . Opacity = 1 ;
65+ Application . Current . MainWindow . Focus ( ) ;
66+ }
5167 }
5268}
0 commit comments