2727using DataObject = System . Windows . DataObject ;
2828using Key = System . Windows . Input . Key ;
2929using MouseButtons = System . Windows . Forms . MouseButtons ;
30- using NotifyIcon = System . Windows . Forms . NotifyIcon ;
3130using Screen = System . Windows . Forms . Screen ;
3231
3332namespace Flow . Launcher
@@ -47,11 +46,10 @@ public partial class MainWindow : IDisposable
4746 private readonly Settings _settings ;
4847 private readonly Theme _theme ;
4948
50- // Window Notify Icon
51- private NotifyIcon _notifyIcon ;
52-
5349 // Window Context Menu
54- private readonly ContextMenu _contextMenu = new ( ) ;
50+ private static readonly ContextMenu _contextMenu = new ( ) ;
51+
52+ // Window View Model
5553 private readonly MainViewModel _viewModel ;
5654
5755 // Window Event: Key Event
@@ -243,7 +241,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
243241 }
244242 break ;
245243 case nameof ( MainViewModel . GameModeStatus ) :
246- _notifyIcon . Icon = _viewModel . GameModeStatus
244+ App . NotifyIcon . Icon = _viewModel . GameModeStatus
247245 ? Properties . Resources . gamemode
248246 : Properties . Resources . app ;
249247 break ;
@@ -256,7 +254,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
256254 switch ( e . PropertyName )
257255 {
258256 case nameof ( Settings . HideNotifyIcon ) :
259- _notifyIcon . Visible = ! _settings . HideNotifyIcon ;
257+ App . NotifyIcon . Visible = ! _settings . HideNotifyIcon ;
260258 break ;
261259 case nameof ( Settings . Language ) :
262260 UpdateNotifyIconText ( ) ;
@@ -317,7 +315,7 @@ private async void OnClosing(object sender, CancelEventArgs e)
317315 if ( ! CanClose )
318316 {
319317 CanClose = true ;
320- _notifyIcon . Visible = false ;
318+ App . NotifyIcon . Visible = false ;
321319 App . API . SaveAppAllSettings ( ) ;
322320 e . Cancel = true ;
323321 await ImageLoader . WaitSaveAsync ( ) ;
@@ -663,14 +661,7 @@ private void SoundPlay()
663661
664662 private void InitializeNotifyIcon ( )
665663 {
666- _notifyIcon = new NotifyIcon
667- {
668- Text = Constant . FlowLauncherFullName ,
669- Icon = Constant . Version == "1.0.0" ? Properties . Resources . dev : Properties . Resources . app ,
670- Visible = ! _settings . HideNotifyIcon
671- } ;
672-
673- _notifyIcon . MouseClick += ( o , e ) =>
664+ App . NotifyIcon . MouseClick += ( o , e ) =>
674665 {
675666 switch ( e . Button )
676667 {
@@ -1322,7 +1313,7 @@ protected virtual void Dispose(bool disposing)
13221313 if ( disposing )
13231314 {
13241315 _hwndSource ? . Dispose ( ) ;
1325- _notifyIcon ? . Dispose ( ) ;
1316+ App . NotifyIcon ? . Dispose ( ) ;
13261317 animationSoundWMP ? . Close ( ) ;
13271318 animationSoundWPF ? . Dispose ( ) ;
13281319 ModernWpf . ThemeManager . Current . ActualApplicationThemeChanged -= ThemeManager_ActualApplicationThemeChanged ;
0 commit comments