@@ -140,7 +140,8 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
140140 _viewModel . Show ( ) ;
141141 }
142142
143- // Show notify icon when flowlauncher is hidden
143+ // Initialize context menu & notify icon
144+ InitializeContextMenu ( ) ;
144145 InitializeNotifyIcon ( ) ;
145146
146147 // Initialize color scheme
@@ -270,6 +271,9 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
270271 case nameof ( Settings . KeepMaxResults ) :
271272 SetupResizeMode ( ) ;
272273 break ;
274+ case nameof ( Settings . SettingWindowFont ) :
275+ InitializeContextMenu ( ) ;
276+ break ;
273277 }
274278 } ;
275279
@@ -563,6 +567,44 @@ private void InitializeNotifyIcon()
563567 Icon = Constant . Version == "1.0.0" ? Properties . Resources . dev : Properties . Resources . app ,
564568 Visible = ! _settings . HideNotifyIcon
565569 } ;
570+
571+ _notifyIcon . MouseClick += ( o , e ) =>
572+ {
573+ switch ( e . Button )
574+ {
575+ case MouseButtons . Left :
576+ _viewModel . ToggleFlowLauncher ( ) ;
577+ break ;
578+ case MouseButtons . Right :
579+
580+ _contextMenu . IsOpen = true ;
581+ // Get context menu handle and bring it to the foreground
582+ if ( PresentationSource . FromVisual ( _contextMenu ) is HwndSource hwndSource )
583+ {
584+ Win32Helper . SetForegroundWindow ( hwndSource . Handle ) ;
585+ }
586+
587+ _contextMenu . Focus ( ) ;
588+ break ;
589+ }
590+ } ;
591+ }
592+
593+ private void UpdateNotifyIconText ( )
594+ {
595+ var menu = _contextMenu ;
596+ ( ( MenuItem ) menu . Items [ 0 ] ) . Header = App . API . GetTranslation ( "iconTrayOpen" ) +
597+ " (" + _settings . Hotkey + ")" ;
598+ ( ( MenuItem ) menu . Items [ 1 ] ) . Header = App . API . GetTranslation ( "GameMode" ) ;
599+ ( ( MenuItem ) menu . Items [ 2 ] ) . Header = App . API . GetTranslation ( "PositionReset" ) ;
600+ ( ( MenuItem ) menu . Items [ 3 ] ) . Header = App . API . GetTranslation ( "iconTraySettings" ) ;
601+ ( ( MenuItem ) menu . Items [ 4 ] ) . Header = App . API . GetTranslation ( "iconTrayExit" ) ;
602+ }
603+
604+ private void InitializeContextMenu ( )
605+ {
606+ var menu = _contextMenu ;
607+ menu . Items . Clear ( ) ;
566608 var openIcon = new FontIcon { Glyph = "\ue71e " } ;
567609 var open = new MenuItem
568610 {
@@ -608,38 +650,6 @@ private void InitializeNotifyIcon()
608650 _contextMenu . Items . Add ( positionreset ) ;
609651 _contextMenu . Items . Add ( settings ) ;
610652 _contextMenu . Items . Add ( exit ) ;
611-
612- _notifyIcon . MouseClick += ( o , e ) =>
613- {
614- switch ( e . Button )
615- {
616- case MouseButtons . Left :
617- _viewModel . ToggleFlowLauncher ( ) ;
618- break ;
619- case MouseButtons . Right :
620-
621- _contextMenu . IsOpen = true ;
622- // Get context menu handle and bring it to the foreground
623- if ( PresentationSource . FromVisual ( _contextMenu ) is HwndSource hwndSource )
624- {
625- Win32Helper . SetForegroundWindow ( hwndSource . Handle ) ;
626- }
627-
628- _contextMenu . Focus ( ) ;
629- break ;
630- }
631- } ;
632- }
633-
634- private void UpdateNotifyIconText ( )
635- {
636- var menu = _contextMenu ;
637- ( ( MenuItem ) menu . Items [ 0 ] ) . Header = App . API . GetTranslation ( "iconTrayOpen" ) +
638- " (" + _settings . Hotkey + ")" ;
639- ( ( MenuItem ) menu . Items [ 1 ] ) . Header = App . API . GetTranslation ( "GameMode" ) ;
640- ( ( MenuItem ) menu . Items [ 2 ] ) . Header = App . API . GetTranslation ( "PositionReset" ) ;
641- ( ( MenuItem ) menu . Items [ 3 ] ) . Header = App . API . GetTranslation ( "iconTraySettings" ) ;
642- ( ( MenuItem ) menu . Items [ 4 ] ) . Header = App . API . GetTranslation ( "iconTrayExit" ) ;
643653 }
644654
645655 #endregion
0 commit comments