@@ -73,11 +73,7 @@ public MainWindow(Settings settings, MainViewModel mainVM)
73
73
} ;
74
74
}
75
75
76
- DispatcherTimer timer = new DispatcherTimer
77
- {
78
- Interval = new TimeSpan ( 0 , 0 , 0 , 0 , 500 ) ,
79
- IsEnabled = false
80
- } ;
76
+ DispatcherTimer timer = new DispatcherTimer { Interval = new TimeSpan ( 0 , 0 , 0 , 0 , 500 ) , IsEnabled = false } ;
81
77
82
78
public MainWindow ( )
83
79
{
@@ -88,6 +84,7 @@ public MainWindow()
88
84
private const int WM_EXITSIZEMOVE = 0x0232 ;
89
85
private int _initialWidth ;
90
86
private int _initialHeight ;
87
+
91
88
private IntPtr WndProc ( IntPtr hwnd , int msg , IntPtr wParam , IntPtr lParam , ref bool handled )
92
89
{
93
90
if ( msg == WM_ENTERSIZEMOVE )
@@ -96,18 +93,22 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
96
93
_initialHeight = ( int ) Height ;
97
94
handled = true ;
98
95
}
96
+
99
97
if ( msg == WM_EXITSIZEMOVE )
100
98
{
101
- if ( _initialHeight != ( int ) Height )
99
+ if ( _initialHeight != ( int ) Height )
102
100
{
103
101
OnResizeEnd ( ) ;
104
102
}
103
+
105
104
if ( _initialWidth != ( int ) Width )
106
105
{
107
106
FlowMainWindow . SizeToContent = SizeToContent . Height ;
108
107
}
108
+
109
109
handled = true ;
110
110
}
111
+
111
112
return IntPtr . Zero ;
112
113
}
113
114
@@ -132,6 +133,7 @@ private void OnResizeEnd()
132
133
_settings . MaxResultsToShow = Convert . ToInt32 ( Math . Truncate ( itemCount ) ) ;
133
134
}
134
135
}
136
+
135
137
FlowMainWindow . SizeToContent = SizeToContent . Height ;
136
138
_viewModel . MainWindowWidth = Width ;
137
139
}
@@ -176,6 +178,7 @@ private async void OnClosing(object sender, CancelEventArgs e)
176
178
private void OnInitialized ( object sender , EventArgs e )
177
179
{
178
180
}
181
+
179
182
private void OnLoaded ( object sender , RoutedEventArgs _ )
180
183
{
181
184
// MouseEventHandler
@@ -208,6 +211,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
208
211
{
209
212
SoundPlay ( ) ;
210
213
}
214
+
211
215
UpdatePosition ( ) ;
212
216
PreviewReset ( ) ;
213
217
Activate ( ) ;
@@ -219,7 +223,8 @@ private void OnLoaded(object sender, RoutedEventArgs _)
219
223
_viewModel . LastQuerySelected = true ;
220
224
}
221
225
222
- if ( _viewModel . ProgressBarVisibility == Visibility . Visible && isProgressBarStoryboardPaused )
226
+ if ( _viewModel . ProgressBarVisibility == Visibility . Visible &&
227
+ isProgressBarStoryboardPaused )
223
228
{
224
229
_progressBarStoryboard . Begin ( ProgressBar , true ) ;
225
230
isProgressBarStoryboardPaused = false ;
@@ -260,9 +265,12 @@ private void OnLoaded(object sender, RoutedEventArgs _)
260
265
MoveQueryTextToEnd ( ) ;
261
266
_viewModel . QueryTextCursorMovedToEnd = false ;
262
267
}
268
+
263
269
break ;
264
270
case nameof ( MainViewModel . GameModeStatus ) :
265
- _notifyIcon . Icon = _viewModel . GameModeStatus ? Properties . Resources . gamemode : Properties . Resources . app ;
271
+ _notifyIcon . Icon = _viewModel . GameModeStatus
272
+ ? Properties . Resources . gamemode
273
+ : Properties . Resources . app ;
266
274
break ;
267
275
}
268
276
} ;
@@ -292,50 +300,58 @@ private void OnLoaded(object sender, RoutedEventArgs _)
292
300
293
301
private void InitializePosition ( )
294
302
{
295
- if ( _settings . SearchWindowScreen == SearchWindowScreens . RememberLastLaunchLocation )
296
- {
297
- Top = _settings . WindowTop ;
298
- Left = _settings . WindowLeft ;
299
- }
300
- else
303
+ InitializePositionInner ( ) ;
304
+ InitializePositionInner ( ) ;
305
+ return ;
306
+
307
+ void InitializePositionInner ( )
301
308
{
302
- var screen = SelectedScreen ( ) ;
303
- switch ( _settings . SearchWindowAlign )
309
+ if ( _settings . SearchWindowScreen == SearchWindowScreens . RememberLastLaunchLocation )
304
310
{
305
- case SearchWindowAligns . Center :
306
- Left = HorizonCenter ( screen ) ;
307
- Top = VerticalCenter ( screen ) ;
308
- break ;
309
- case SearchWindowAligns . CenterTop :
310
- Left = HorizonCenter ( screen ) ;
311
- Top = 10 ;
312
- break ;
313
- case SearchWindowAligns . LeftTop :
314
- Left = HorizonLeft ( screen ) ;
315
- Top = 10 ;
316
- break ;
317
- case SearchWindowAligns . RightTop :
318
- Left = HorizonRight ( screen ) ;
319
- Top = 10 ;
320
- break ;
321
- case SearchWindowAligns . Custom :
322
- Left = WindowsInteropHelper . TransformPixelsToDIP ( this , screen . WorkingArea . X + _settings . CustomWindowLeft , 0 ) . X ;
323
- Top = WindowsInteropHelper . TransformPixelsToDIP ( this , 0 , screen . WorkingArea . Y + _settings . CustomWindowTop ) . Y ;
324
- break ;
311
+ Top = _settings . WindowTop ;
312
+ Left = _settings . WindowLeft ;
313
+ }
314
+ else
315
+ {
316
+ var screen = SelectedScreen ( ) ;
317
+ switch ( _settings . SearchWindowAlign )
318
+ {
319
+ case SearchWindowAligns . Center :
320
+ Left = HorizonCenter ( screen ) ;
321
+ Top = VerticalCenter ( screen ) ;
322
+ break ;
323
+ case SearchWindowAligns . CenterTop :
324
+ Left = HorizonCenter ( screen ) ;
325
+ Top = 10 ;
326
+ break ;
327
+ case SearchWindowAligns . LeftTop :
328
+ Left = HorizonLeft ( screen ) ;
329
+ Top = 10 ;
330
+ break ;
331
+ case SearchWindowAligns . RightTop :
332
+ Left = HorizonRight ( screen ) ;
333
+ Top = 10 ;
334
+ break ;
335
+ case SearchWindowAligns . Custom :
336
+ Left = WindowsInteropHelper . TransformPixelsToDIP ( this ,
337
+ screen . WorkingArea . X + _settings . CustomWindowLeft , 0 ) . X ;
338
+ Top = WindowsInteropHelper . TransformPixelsToDIP ( this , 0 ,
339
+ screen . WorkingArea . Y + _settings . CustomWindowTop ) . Y ;
340
+ break ;
341
+ }
325
342
}
326
343
}
327
-
328
344
}
329
345
330
346
private void UpdateNotifyIconText ( )
331
347
{
332
348
var menu = contextMenu ;
333
- ( ( MenuItem ) menu . Items [ 0 ] ) . Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayOpen" ) + " (" + _settings . Hotkey + ")" ;
349
+ ( ( MenuItem ) menu . Items [ 0 ] ) . Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayOpen" ) +
350
+ " (" + _settings . Hotkey + ")" ;
334
351
( ( MenuItem ) menu . Items [ 1 ] ) . Header = InternationalizationManager . Instance . GetTranslation ( "GameMode" ) ;
335
352
( ( MenuItem ) menu . Items [ 2 ] ) . Header = InternationalizationManager . Instance . GetTranslation ( "PositionReset" ) ;
336
353
( ( MenuItem ) menu . Items [ 3 ] ) . Header = InternationalizationManager . Instance . GetTranslation ( "iconTraySettings" ) ;
337
354
( ( MenuItem ) menu . Items [ 4 ] ) . Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayExit" ) ;
338
-
339
355
}
340
356
341
357
private void InitializeNotifyIcon ( )
@@ -347,50 +363,34 @@ private void InitializeNotifyIcon()
347
363
Visible = ! _settings . HideNotifyIcon
348
364
} ;
349
365
350
- var openIcon = new FontIcon
351
- {
352
- Glyph = "\ue71e "
353
- } ;
366
+ var openIcon = new FontIcon { Glyph = "\ue71e " } ;
354
367
var open = new MenuItem
355
368
{
356
- Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayOpen" ) + " (" + _settings . Hotkey + ")" ,
369
+ Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayOpen" ) + " (" +
370
+ _settings . Hotkey + ")" ,
357
371
Icon = openIcon
358
372
} ;
359
- var gamemodeIcon = new FontIcon
360
- {
361
- Glyph = "\ue7fc "
362
- } ;
373
+ var gamemodeIcon = new FontIcon { Glyph = "\ue7fc " } ;
363
374
var gamemode = new MenuItem
364
375
{
365
- Header = InternationalizationManager . Instance . GetTranslation ( "GameMode" ) ,
366
- Icon = gamemodeIcon
367
- } ;
368
- var positionresetIcon = new FontIcon
369
- {
370
- Glyph = "\ue73f "
376
+ Header = InternationalizationManager . Instance . GetTranslation ( "GameMode" ) , Icon = gamemodeIcon
371
377
} ;
378
+ var positionresetIcon = new FontIcon { Glyph = "\ue73f " } ;
372
379
var positionreset = new MenuItem
373
380
{
374
381
Header = InternationalizationManager . Instance . GetTranslation ( "PositionReset" ) ,
375
382
Icon = positionresetIcon
376
383
} ;
377
- var settingsIcon = new FontIcon
378
- {
379
- Glyph = "\ue713 "
380
- } ;
384
+ var settingsIcon = new FontIcon { Glyph = "\ue713 " } ;
381
385
var settings = new MenuItem
382
386
{
383
387
Header = InternationalizationManager . Instance . GetTranslation ( "iconTraySettings" ) ,
384
388
Icon = settingsIcon
385
389
} ;
386
- var exitIcon = new FontIcon
387
- {
388
- Glyph = "\ue7e8 "
389
- } ;
390
+ var exitIcon = new FontIcon { Glyph = "\ue7e8 " } ;
390
391
var exit = new MenuItem
391
392
{
392
- Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayExit" ) ,
393
- Icon = exitIcon
393
+ Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayExit" ) , Icon = exitIcon
394
394
} ;
395
395
396
396
open . Click += ( o , e ) => _viewModel . ToggleFlowLauncher ( ) ;
@@ -423,6 +423,7 @@ private void InitializeNotifyIcon()
423
423
{
424
424
_ = SetForegroundWindow ( hwndSource . Handle ) ;
425
425
}
426
+
426
427
contextMenu . Focus ( ) ;
427
428
break ;
428
429
}
@@ -456,8 +457,10 @@ private async void PositionReset()
456
457
457
458
private void InitProgressbarAnimation ( )
458
459
{
459
- var da = new DoubleAnimation ( ProgressBar . X2 , ActualWidth + 100 , new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
460
- var da1 = new DoubleAnimation ( ProgressBar . X1 , ActualWidth + 0 , new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
460
+ var da = new DoubleAnimation ( ProgressBar . X2 , ActualWidth + 100 ,
461
+ new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
462
+ var da1 = new DoubleAnimation ( ProgressBar . X1 , ActualWidth + 0 ,
463
+ new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
461
464
Storyboard . SetTargetProperty ( da , new PropertyPath ( "(Line.X2)" ) ) ;
462
465
Storyboard . SetTargetProperty ( da1 , new PropertyPath ( "(Line.X1)" ) ) ;
463
466
_progressBarStoryboard . Children . Add ( da ) ;
@@ -567,6 +570,7 @@ public void WindowAnimator()
567
570
{
568
571
clocksb . Begin ( ClockPanel ) ;
569
572
}
573
+
570
574
iconsb . Begin ( SearchIcon ) ;
571
575
windowsb . Begin ( FlowMainWindow ) ;
572
576
}
@@ -674,7 +678,7 @@ public void HideStartup()
674
678
public Screen SelectedScreen ( )
675
679
{
676
680
Screen screen = null ;
677
- switch ( _settings . SearchWindowScreen )
681
+ switch ( _settings . SearchWindowScreen )
678
682
{
679
683
case SearchWindowScreens . Cursor :
680
684
screen = Screen . FromPoint ( System . Windows . Forms . Cursor . Position ) ;
@@ -696,6 +700,7 @@ public Screen SelectedScreen()
696
700
screen = Screen . AllScreens [ 0 ] ;
697
701
break ;
698
702
}
703
+
699
704
return screen ?? Screen . AllScreens [ 0 ] ;
700
705
}
701
706
@@ -765,13 +770,15 @@ private void OnKeyDown(object sender, KeyEventArgs e)
765
770
_viewModel . LoadContextMenuCommand . Execute ( null ) ;
766
771
e . Handled = true ;
767
772
}
773
+
768
774
break ;
769
775
case Key . Left :
770
776
if ( ! _viewModel . SelectedIsFromQueryResults ( ) && QueryTextBox . CaretIndex == 0 )
771
777
{
772
778
_viewModel . EscCommand . Execute ( null ) ;
773
779
e . Handled = true ;
774
780
}
781
+
775
782
break ;
776
783
case Key . Back :
777
784
if ( specialKeyState . CtrlPressed )
@@ -790,12 +797,13 @@ private void OnKeyDown(object sender, KeyEventArgs e)
790
797
}
791
798
}
792
799
}
800
+
793
801
break ;
794
802
default :
795
803
break ;
796
-
797
804
}
798
805
}
806
+
799
807
private void OnKeyUp ( object sender , KeyEventArgs e )
800
808
{
801
809
if ( e . Key == Key . Up || e . Key == Key . Down )
@@ -811,6 +819,7 @@ private void MainPreviewMouseMove(object sender, System.Windows.Input.MouseEvent
811
819
e . Handled = true ; // Ignore Mouse Hover when press Arrowkeys
812
820
}
813
821
}
822
+
814
823
public void PreviewReset ( )
815
824
{
816
825
_viewModel . ResetPreview ( ) ;
0 commit comments