@@ -57,7 +57,7 @@ public MainWindow(Settings settings, MainViewModel mainVM)
57
57
DataContext = mainVM ;
58
58
_viewModel = mainVM ;
59
59
_settings = settings ;
60
-
60
+
61
61
InitializeComponent ( ) ;
62
62
InitializePosition ( ) ;
63
63
animationSound . Open ( new Uri ( AppDomain . CurrentDomain . BaseDirectory + "Resources\\ open.wav" ) ) ;
@@ -67,7 +67,7 @@ public MainWindow()
67
67
{
68
68
InitializeComponent ( ) ;
69
69
}
70
-
70
+
71
71
private void OnCopy ( object sender , ExecutedRoutedEventArgs e )
72
72
{
73
73
if ( QueryTextBox . SelectionLength == 0 )
@@ -115,6 +115,8 @@ private void OnLoaded(object sender, RoutedEventArgs _)
115
115
switch ( e . PropertyName )
116
116
{
117
117
case nameof ( MainViewModel . MainWindowVisibilityStatus ) :
118
+ {
119
+ Dispatcher . Invoke ( ( ) =>
118
120
{
119
121
if ( _viewModel . MainWindowVisibilityStatus )
120
122
{
@@ -140,35 +142,35 @@ private void OnLoaded(object sender, RoutedEventArgs _)
140
142
isProgressBarStoryboardPaused = false ;
141
143
}
142
144
143
- if ( _settings . UseAnimation )
145
+ if ( _settings . UseAnimation )
144
146
WindowAnimator ( ) ;
145
147
}
146
148
else if ( ! isProgressBarStoryboardPaused )
147
149
{
148
150
_progressBarStoryboard . Stop ( ProgressBar ) ;
149
151
isProgressBarStoryboardPaused = true ;
150
152
}
151
-
152
- break ;
153
- }
153
+ } ) ;
154
+ break ;
155
+ }
154
156
case nameof ( MainViewModel . ProgressBarVisibility ) :
157
+ {
158
+ Dispatcher . Invoke ( ( ) =>
155
159
{
156
- Dispatcher . Invoke ( ( ) =>
160
+ if ( _viewModel . ProgressBarVisibility == Visibility . Hidden && ! isProgressBarStoryboardPaused )
157
161
{
158
- if ( _viewModel . ProgressBarVisibility == Visibility . Hidden && ! isProgressBarStoryboardPaused )
159
- {
160
- _progressBarStoryboard . Stop ( ProgressBar ) ;
161
- isProgressBarStoryboardPaused = true ;
162
- }
163
- else if ( _viewModel . MainWindowVisibilityStatus &&
164
- isProgressBarStoryboardPaused )
165
- {
166
- _progressBarStoryboard . Begin ( ProgressBar , true ) ;
167
- isProgressBarStoryboardPaused = false ;
168
- }
169
- } ) ;
170
- break ;
171
- }
162
+ _progressBarStoryboard . Stop ( ProgressBar ) ;
163
+ isProgressBarStoryboardPaused = true ;
164
+ }
165
+ else if ( _viewModel . MainWindowVisibilityStatus &&
166
+ isProgressBarStoryboardPaused )
167
+ {
168
+ _progressBarStoryboard . Begin ( ProgressBar , true ) ;
169
+ isProgressBarStoryboardPaused = false ;
170
+ }
171
+ } ) ;
172
+ break ;
173
+ }
172
174
case nameof ( MainViewModel . QueryTextCursorMovedToEnd ) :
173
175
if ( _viewModel . QueryTextCursorMovedToEnd )
174
176
{
@@ -251,35 +253,45 @@ private void InitializeNotifyIcon()
251
253
252
254
contextMenu = new ContextMenu ( ) ;
253
255
254
- var openIcon = new FontIcon { Glyph = "\ue71e " } ;
256
+ var openIcon = new FontIcon
257
+ {
258
+ Glyph = "\ue71e "
259
+ } ;
255
260
var open = new MenuItem
256
261
{
257
- Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayOpen" ) + " (" + _settings . Hotkey + ")" ,
258
- Icon = openIcon
262
+ Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayOpen" ) + " (" + _settings . Hotkey + ")" , Icon = openIcon
263
+ } ;
264
+ var gamemodeIcon = new FontIcon
265
+ {
266
+ Glyph = "\ue7fc "
259
267
} ;
260
- var gamemodeIcon = new FontIcon { Glyph = "\ue7fc " } ;
261
268
var gamemode = new MenuItem
262
269
{
263
- Header = InternationalizationManager . Instance . GetTranslation ( "GameMode" ) ,
264
- Icon = gamemodeIcon
270
+ Header = InternationalizationManager . Instance . GetTranslation ( "GameMode" ) , Icon = gamemodeIcon
271
+ } ;
272
+ var positionresetIcon = new FontIcon
273
+ {
274
+ Glyph = "\ue73f "
265
275
} ;
266
- var positionresetIcon = new FontIcon { Glyph = "\ue73f " } ;
267
276
var positionreset = new MenuItem
268
277
{
269
- Header = InternationalizationManager . Instance . GetTranslation ( "PositionReset" ) ,
270
- Icon = positionresetIcon
278
+ Header = InternationalizationManager . Instance . GetTranslation ( "PositionReset" ) , Icon = positionresetIcon
279
+ } ;
280
+ var settingsIcon = new FontIcon
281
+ {
282
+ Glyph = "\ue713 "
271
283
} ;
272
- var settingsIcon = new FontIcon { Glyph = "\ue713 " } ;
273
284
var settings = new MenuItem
274
285
{
275
- Header = InternationalizationManager . Instance . GetTranslation ( "iconTraySettings" ) ,
276
- Icon = settingsIcon
286
+ Header = InternationalizationManager . Instance . GetTranslation ( "iconTraySettings" ) , Icon = settingsIcon
287
+ } ;
288
+ var exitIcon = new FontIcon
289
+ {
290
+ Glyph = "\ue7e8 "
277
291
} ;
278
- var exitIcon = new FontIcon { Glyph = "\ue7e8 " } ;
279
292
var exit = new MenuItem
280
293
{
281
- Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayExit" ) ,
282
- Icon = exitIcon
294
+ Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayExit" ) , Icon = exitIcon
283
295
} ;
284
296
285
297
open . Click += ( o , e ) => _viewModel . ToggleFlowLauncher ( ) ;
@@ -342,15 +354,15 @@ private void ToggleGameMode()
342
354
}
343
355
private async void PositionReset ( )
344
356
{
345
- _viewModel . Show ( ) ;
346
- await Task . Delay ( 300 ) ; // If don't give a time, Positioning will be weird.
347
- Left = HorizonCenter ( ) ;
348
- Top = VerticalCenter ( ) ;
357
+ _viewModel . Show ( ) ;
358
+ await Task . Delay ( 300 ) ; // If don't give a time, Positioning will be weird.
359
+ Left = HorizonCenter ( ) ;
360
+ Top = VerticalCenter ( ) ;
349
361
}
350
362
private void InitProgressbarAnimation ( )
351
363
{
352
364
var da = new DoubleAnimation ( ProgressBar . X2 , ActualWidth + 150 ,
353
- new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
365
+ new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
354
366
var da1 = new DoubleAnimation ( ProgressBar . X1 , ActualWidth + 50 , new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
355
367
Storyboard . SetTargetProperty ( da , new PropertyPath ( "(Line.X2)" ) ) ;
356
368
Storyboard . SetTargetProperty ( da1 , new PropertyPath ( "(Line.X1)" ) ) ;
@@ -392,11 +404,11 @@ public void WindowAnimator()
392
404
} ;
393
405
var IconMotion = new DoubleAnimation
394
406
{
395
- From = 12 ,
396
- To = 0 ,
397
- EasingFunction = easing ,
398
- Duration = TimeSpan . FromSeconds ( 0.36 ) ,
399
- FillBehavior = FillBehavior . Stop
407
+ From = 12 ,
408
+ To = 0 ,
409
+ EasingFunction = easing ,
410
+ Duration = TimeSpan . FromSeconds ( 0.36 ) ,
411
+ FillBehavior = FillBehavior . Stop
400
412
} ;
401
413
402
414
var ClockOpacity = new DoubleAnimation
@@ -468,10 +480,10 @@ private void OnPreviewDragOver(object sender, DragEventArgs e)
468
480
private async void OnContextMenusForSettingsClick ( object sender , RoutedEventArgs e )
469
481
{
470
482
_viewModel . Hide ( ) ;
471
-
472
- if ( _settings . UseAnimation )
483
+
484
+ if ( _settings . UseAnimation )
473
485
await Task . Delay ( 100 ) ;
474
-
486
+
475
487
App . API . OpenSettingDialog ( ) ;
476
488
}
477
489
@@ -489,7 +501,7 @@ private async void OnDeactivated(object sender, EventArgs e)
489
501
// and always after Settings window is closed.
490
502
if ( _settings . UseAnimation )
491
503
await Task . Delay ( 100 ) ;
492
-
504
+
493
505
if ( _settings . HideWhenDeactive )
494
506
{
495
507
_viewModel . Hide ( ) ;
@@ -527,7 +539,7 @@ public void HideStartup()
527
539
_viewModel . Show ( ) ;
528
540
}
529
541
}
530
-
542
+
531
543
public double HorizonCenter ( )
532
544
{
533
545
var screen = Screen . FromPoint ( System . Windows . Forms . Cursor . Position ) ;
@@ -609,9 +621,9 @@ private void OnKeyDown(object sender, KeyEventArgs e)
609
621
&& QueryTextBox . Text . Length > 0
610
622
&& QueryTextBox . CaretIndex == QueryTextBox . Text . Length )
611
623
{
612
- var queryWithoutActionKeyword =
624
+ var queryWithoutActionKeyword =
613
625
QueryBuilder . Build ( QueryTextBox . Text . Trim ( ) , PluginManager . NonGlobalPlugins ) ? . Search ;
614
-
626
+
615
627
if ( FilesFolders . IsLocationPathString ( queryWithoutActionKeyword ) )
616
628
{
617
629
_viewModel . BackspaceCommand . Execute ( null ) ;
@@ -663,7 +675,7 @@ private void MoveQueryTextToEnd()
663
675
{
664
676
// QueryTextBox seems to be update with a DispatcherPriority as low as ContextIdle.
665
677
// To ensure QueryTextBox is up to date with QueryText from the View, we need to Dispatch with such a priority
666
- Dispatcher . Invoke ( ( ) => QueryTextBox . CaretIndex = QueryTextBox . Text . Length , System . Windows . Threading . DispatcherPriority . ContextIdle ) ;
678
+ Dispatcher . Invoke ( ( ) => QueryTextBox . CaretIndex = QueryTextBox . Text . Length ) ;
667
679
}
668
680
669
681
public void InitializeColorScheme ( )
@@ -680,7 +692,7 @@ public void InitializeColorScheme()
680
692
681
693
private void QueryTextBox_KeyUp ( object sender , KeyEventArgs e )
682
694
{
683
- if ( _viewModel . QueryText != QueryTextBox . Text )
695
+ if ( _viewModel . QueryText != QueryTextBox . Text )
684
696
{
685
697
BindingExpression be = QueryTextBox . GetBindingExpression ( System . Windows . Controls . TextBox . TextProperty ) ;
686
698
be . UpdateSource ( ) ;
0 commit comments