@@ -57,7 +57,7 @@ public MainWindow(Settings settings, MainViewModel mainVM)
5757 DataContext = mainVM ;
5858 _viewModel = mainVM ;
5959 _settings = settings ;
60-
60+
6161 InitializeComponent ( ) ;
6262 InitializePosition ( ) ;
6363 animationSound . Open ( new Uri ( AppDomain . CurrentDomain . BaseDirectory + "Resources\\ open.wav" ) ) ;
@@ -67,7 +67,7 @@ public MainWindow()
6767 {
6868 InitializeComponent ( ) ;
6969 }
70-
70+
7171 private void OnCopy ( object sender , ExecutedRoutedEventArgs e )
7272 {
7373 if ( QueryTextBox . SelectionLength == 0 )
@@ -115,6 +115,8 @@ private void OnLoaded(object sender, RoutedEventArgs _)
115115 switch ( e . PropertyName )
116116 {
117117 case nameof ( MainViewModel . MainWindowVisibilityStatus ) :
118+ {
119+ Dispatcher . Invoke ( ( ) =>
118120 {
119121 if ( _viewModel . MainWindowVisibilityStatus )
120122 {
@@ -140,35 +142,35 @@ private void OnLoaded(object sender, RoutedEventArgs _)
140142 isProgressBarStoryboardPaused = false ;
141143 }
142144
143- if ( _settings . UseAnimation )
145+ if ( _settings . UseAnimation )
144146 WindowAnimator ( ) ;
145147 }
146148 else if ( ! isProgressBarStoryboardPaused )
147149 {
148150 _progressBarStoryboard . Stop ( ProgressBar ) ;
149151 isProgressBarStoryboardPaused = true ;
150152 }
151-
152- break ;
153- }
153+ } ) ;
154+ break ;
155+ }
154156 case nameof ( MainViewModel . ProgressBarVisibility ) :
157+ {
158+ Dispatcher . Invoke ( ( ) =>
155159 {
156- Dispatcher . Invoke ( ( ) =>
160+ if ( _viewModel . ProgressBarVisibility == Visibility . Hidden && ! isProgressBarStoryboardPaused )
157161 {
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+ }
172174 case nameof ( MainViewModel . QueryTextCursorMovedToEnd ) :
173175 if ( _viewModel . QueryTextCursorMovedToEnd )
174176 {
@@ -251,35 +253,45 @@ private void InitializeNotifyIcon()
251253
252254 contextMenu = new ContextMenu ( ) ;
253255
254- var openIcon = new FontIcon { Glyph = "\ue71e " } ;
256+ var openIcon = new FontIcon
257+ {
258+ Glyph = "\ue71e "
259+ } ;
255260 var open = new MenuItem
256261 {
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 "
259267 } ;
260- var gamemodeIcon = new FontIcon { Glyph = "\ue7fc " } ;
261268 var gamemode = new MenuItem
262269 {
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 "
265275 } ;
266- var positionresetIcon = new FontIcon { Glyph = "\ue73f " } ;
267276 var positionreset = new MenuItem
268277 {
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 "
271283 } ;
272- var settingsIcon = new FontIcon { Glyph = "\ue713 " } ;
273284 var settings = new MenuItem
274285 {
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 "
277291 } ;
278- var exitIcon = new FontIcon { Glyph = "\ue7e8 " } ;
279292 var exit = new MenuItem
280293 {
281- Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayExit" ) ,
282- Icon = exitIcon
294+ Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayExit" ) , Icon = exitIcon
283295 } ;
284296
285297 open . Click += ( o , e ) => _viewModel . ToggleFlowLauncher ( ) ;
@@ -342,15 +354,15 @@ private void ToggleGameMode()
342354 }
343355 private async void PositionReset ( )
344356 {
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 ( ) ;
349361 }
350362 private void InitProgressbarAnimation ( )
351363 {
352364 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 ) ) ) ;
354366 var da1 = new DoubleAnimation ( ProgressBar . X1 , ActualWidth + 50 , new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
355367 Storyboard . SetTargetProperty ( da , new PropertyPath ( "(Line.X2)" ) ) ;
356368 Storyboard . SetTargetProperty ( da1 , new PropertyPath ( "(Line.X1)" ) ) ;
@@ -392,11 +404,11 @@ public void WindowAnimator()
392404 } ;
393405 var IconMotion = new DoubleAnimation
394406 {
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
400412 } ;
401413
402414 var ClockOpacity = new DoubleAnimation
@@ -468,10 +480,10 @@ private void OnPreviewDragOver(object sender, DragEventArgs e)
468480 private async void OnContextMenusForSettingsClick ( object sender , RoutedEventArgs e )
469481 {
470482 _viewModel . Hide ( ) ;
471-
472- if ( _settings . UseAnimation )
483+
484+ if ( _settings . UseAnimation )
473485 await Task . Delay ( 100 ) ;
474-
486+
475487 App . API . OpenSettingDialog ( ) ;
476488 }
477489
@@ -489,7 +501,7 @@ private async void OnDeactivated(object sender, EventArgs e)
489501 // and always after Settings window is closed.
490502 if ( _settings . UseAnimation )
491503 await Task . Delay ( 100 ) ;
492-
504+
493505 if ( _settings . HideWhenDeactive )
494506 {
495507 _viewModel . Hide ( ) ;
@@ -527,7 +539,7 @@ public void HideStartup()
527539 _viewModel . Show ( ) ;
528540 }
529541 }
530-
542+
531543 public double HorizonCenter ( )
532544 {
533545 var screen = Screen . FromPoint ( System . Windows . Forms . Cursor . Position ) ;
@@ -609,9 +621,9 @@ private void OnKeyDown(object sender, KeyEventArgs e)
609621 && QueryTextBox . Text . Length > 0
610622 && QueryTextBox . CaretIndex == QueryTextBox . Text . Length )
611623 {
612- var queryWithoutActionKeyword =
624+ var queryWithoutActionKeyword =
613625 QueryBuilder . Build ( QueryTextBox . Text . Trim ( ) , PluginManager . NonGlobalPlugins ) ? . Search ;
614-
626+
615627 if ( FilesFolders . IsLocationPathString ( queryWithoutActionKeyword ) )
616628 {
617629 _viewModel . BackspaceCommand . Execute ( null ) ;
@@ -663,7 +675,7 @@ private void MoveQueryTextToEnd()
663675 {
664676 // QueryTextBox seems to be update with a DispatcherPriority as low as ContextIdle.
665677 // 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 ) ;
667679 }
668680
669681 public void InitializeColorScheme ( )
@@ -680,7 +692,7 @@ public void InitializeColorScheme()
680692
681693 private void QueryTextBox_KeyUp ( object sender , KeyEventArgs e )
682694 {
683- if ( _viewModel . QueryText != QueryTextBox . Text )
695+ if ( _viewModel . QueryText != QueryTextBox . Text )
684696 {
685697 BindingExpression be = QueryTextBox . GetBindingExpression ( System . Windows . Controls . TextBox . TextProperty ) ;
686698 be . UpdateSource ( ) ;
0 commit comments