18
18
using Flow . Launcher . Plugin . SharedCommands ;
19
19
using Flow . Launcher . Plugin . SharedModels ;
20
20
using Flow . Launcher . ViewModel ;
21
- using ModernWpf . Controls ;
22
21
using DataObject = System . Windows . DataObject ;
23
22
using Key = System . Windows . Input . Key ;
24
- using MouseButtons = System . Windows . Forms . MouseButtons ;
25
- using NotifyIcon = System . Windows . Forms . NotifyIcon ;
26
23
27
24
namespace Flow . Launcher
28
25
{
@@ -44,11 +41,6 @@ public partial class MainWindow : IDisposable
44
41
private readonly Settings _settings ;
45
42
private readonly Theme _theme ;
46
43
47
- // Window Notify Icon
48
- private NotifyIcon _notifyIcon ;
49
-
50
- // Window Context Menu
51
- private readonly ContextMenu _contextMenu = new ( ) ;
52
44
private readonly MainViewModel _viewModel ;
53
45
54
46
// Window Event: Key Event
@@ -128,10 +120,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
128
120
_viewModel . Show ( ) ;
129
121
}
130
122
131
- // Initialize context menu & notify icon
132
- InitializeContextMenu ( ) ;
133
- InitializeNotifyIcon ( ) ;
134
-
135
123
// Initialize color scheme
136
124
if ( _settings . ColorScheme == Constant . Light )
137
125
{
@@ -198,11 +186,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
198
186
_viewModel . QueryTextCursorMovedToEnd = false ;
199
187
}
200
188
break ;
201
- case nameof ( MainViewModel . GameModeStatus ) :
202
- _notifyIcon . Icon = _viewModel . GameModeStatus
203
- ? Properties . Resources . gamemode
204
- : Properties . Resources . app ;
205
- break ;
206
189
}
207
190
} ;
208
191
@@ -211,19 +194,12 @@ private void OnLoaded(object sender, RoutedEventArgs _)
211
194
{
212
195
switch ( e . PropertyName )
213
196
{
214
- case nameof ( Settings . HideNotifyIcon ) :
215
- _notifyIcon . Visible = ! _settings . HideNotifyIcon ;
216
- break ;
217
197
case nameof ( Settings . Language ) :
218
- UpdateNotifyIconText ( ) ;
219
198
if ( _settings . ShowHomePage && _viewModel . QueryResultsSelected ( ) && string . IsNullOrEmpty ( _viewModel . QueryText ) )
220
199
{
221
200
_viewModel . QueryResults ( ) ;
222
201
}
223
202
break ;
224
- case nameof ( Settings . Hotkey ) :
225
- UpdateNotifyIconText ( ) ;
226
- break ;
227
203
case nameof ( Settings . WindowLeft ) :
228
204
Left = _settings . WindowLeft ;
229
205
break ;
@@ -257,7 +233,6 @@ private async void OnClosing(object sender, CancelEventArgs e)
257
233
if ( ! CanClose )
258
234
{
259
235
CanClose = true ;
260
- _notifyIcon . Visible = false ;
261
236
App . API . SaveAppAllSettings ( ) ;
262
237
e . Cancel = true ;
263
238
await PluginManager . DisposePluginsAsync ( ) ;
@@ -535,103 +510,6 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
535
510
536
511
#endregion
537
512
538
- #region Window Notify Icon
539
-
540
- private void InitializeNotifyIcon ( )
541
- {
542
- _notifyIcon = new NotifyIcon
543
- {
544
- Text = Constant . FlowLauncherFullName ,
545
- Icon = Constant . Version == "1.0.0" ? Properties . Resources . dev : Properties . Resources . app ,
546
- Visible = ! _settings . HideNotifyIcon
547
- } ;
548
-
549
- _notifyIcon . MouseClick += ( o , e ) =>
550
- {
551
- switch ( e . Button )
552
- {
553
- case MouseButtons . Left :
554
- _viewModel . ToggleFlowLauncher ( ) ;
555
- break ;
556
- case MouseButtons . Right :
557
-
558
- _contextMenu . IsOpen = true ;
559
- // Get context menu handle and bring it to the foreground
560
- if ( PresentationSource . FromVisual ( _contextMenu ) is HwndSource hwndSource )
561
- {
562
- Win32Helper . SetForegroundWindow ( hwndSource . Handle ) ;
563
- }
564
-
565
- _contextMenu . Focus ( ) ;
566
- break ;
567
- }
568
- } ;
569
- }
570
-
571
- private void UpdateNotifyIconText ( )
572
- {
573
- var menu = _contextMenu ;
574
- ( ( MenuItem ) menu . Items [ 0 ] ) . Header = App . API . GetTranslation ( "iconTrayOpen" ) +
575
- " (" + _settings . Hotkey + ")" ;
576
- ( ( MenuItem ) menu . Items [ 1 ] ) . Header = App . API . GetTranslation ( "GameMode" ) ;
577
- ( ( MenuItem ) menu . Items [ 2 ] ) . Header = App . API . GetTranslation ( "PositionReset" ) ;
578
- ( ( MenuItem ) menu . Items [ 3 ] ) . Header = App . API . GetTranslation ( "iconTraySettings" ) ;
579
- ( ( MenuItem ) menu . Items [ 4 ] ) . Header = App . API . GetTranslation ( "iconTrayExit" ) ;
580
- }
581
-
582
- private void InitializeContextMenu ( )
583
- {
584
- var menu = _contextMenu ;
585
- menu . Items . Clear ( ) ;
586
- var openIcon = new FontIcon { Glyph = "\ue71e " } ;
587
- var open = new MenuItem
588
- {
589
- Header = App . API . GetTranslation ( "iconTrayOpen" ) + " (" + _settings . Hotkey + ")" ,
590
- Icon = openIcon
591
- } ;
592
- var gamemodeIcon = new FontIcon { Glyph = "\ue7fc " } ;
593
- var gamemode = new MenuItem
594
- {
595
- Header = App . API . GetTranslation ( "GameMode" ) ,
596
- Icon = gamemodeIcon
597
- } ;
598
- var positionresetIcon = new FontIcon { Glyph = "\ue73f " } ;
599
- var positionreset = new MenuItem
600
- {
601
- Header = App . API . GetTranslation ( "PositionReset" ) ,
602
- Icon = positionresetIcon
603
- } ;
604
- var settingsIcon = new FontIcon { Glyph = "\ue713 " } ;
605
- var settings = new MenuItem
606
- {
607
- Header = App . API . GetTranslation ( "iconTraySettings" ) ,
608
- Icon = settingsIcon
609
- } ;
610
- var exitIcon = new FontIcon { Glyph = "\ue7e8 " } ;
611
- var exit = new MenuItem
612
- {
613
- Header = App . API . GetTranslation ( "iconTrayExit" ) ,
614
- Icon = exitIcon
615
- } ;
616
-
617
- open . Click += ( o , e ) => _viewModel . ToggleFlowLauncher ( ) ;
618
- gamemode . Click += ( o , e ) => _viewModel . ToggleGameMode ( ) ;
619
- positionreset . Click += ( o , e ) => _ = PositionResetAsync ( ) ;
620
- settings . Click += ( o , e ) => App . API . OpenSettingDialog ( ) ;
621
- exit . Click += ( o , e ) => Close ( ) ;
622
-
623
- gamemode . ToolTip = App . API . GetTranslation ( "GameModeToolTip" ) ;
624
- positionreset . ToolTip = App . API . GetTranslation ( "PositionResetToolTip" ) ;
625
-
626
- _contextMenu . Items . Add ( open ) ;
627
- _contextMenu . Items . Add ( gamemode ) ;
628
- _contextMenu . Items . Add ( positionreset ) ;
629
- _contextMenu . Items . Add ( settings ) ;
630
- _contextMenu . Items . Add ( exit ) ;
631
- }
632
-
633
- #endregion
634
-
635
513
#region Window Position
636
514
637
515
private void UpdatePosition ( )
@@ -914,7 +792,6 @@ protected virtual void Dispose(bool disposing)
914
792
if ( disposing )
915
793
{
916
794
_hwndSource ? . Dispose ( ) ;
917
- _notifyIcon ? . Dispose ( ) ;
918
795
_viewModel . ActualApplicationThemeChanged -= ViewModel_ActualApplicationThemeChanged ;
919
796
}
920
797
0 commit comments