@@ -36,6 +36,7 @@ namespace Flow.Launcher
3636 public partial class MainWindow
3737 {
3838 #region Private Fields
39+
3940 private Settings _settings ;
4041 private NotifyIcon _notifyIcon ;
4142 private ContextMenu contextMenu ;
@@ -50,7 +51,7 @@ public MainWindow(Settings settings, MainViewModel mainVM)
5051 DataContext = mainVM ;
5152 _viewModel = mainVM ;
5253 _settings = settings ;
53-
54+
5455 InitializeComponent ( ) ;
5556 InitializePosition ( ) ;
5657 animationSound . Open ( new Uri ( AppDomain . CurrentDomain . BaseDirectory + "Resources\\ open.wav" ) ) ;
@@ -60,7 +61,7 @@ public MainWindow()
6061 {
6162 InitializeComponent ( ) ;
6263 }
63-
64+
6465 private void OnCopy ( object sender , ExecutedRoutedEventArgs e )
6566 {
6667 if ( QueryTextBox . SelectionLength == 0 )
@@ -108,29 +109,29 @@ private void OnLoaded(object sender, RoutedEventArgs _)
108109 switch ( e . PropertyName )
109110 {
110111 case nameof ( MainViewModel . MainWindowVisibilityStatus ) :
112+ {
113+ if ( _viewModel . MainWindowVisibilityStatus )
111114 {
112- if ( _viewModel . MainWindowVisibilityStatus )
115+ if ( _settings . UseSound )
113116 {
114- if ( _settings . UseSound )
115- {
116- animationSound . Position = TimeSpan . Zero ;
117- animationSound . Play ( ) ;
118- }
119- UpdatePosition ( ) ;
120- Activate ( ) ;
121- QueryTextBox . Focus ( ) ;
122- _settings . ActivateTimes ++ ;
123- if ( ! _viewModel . LastQuerySelected )
124- {
125- QueryTextBox . SelectAll ( ) ;
126- _viewModel . LastQuerySelected = true ;
127- }
128-
129- if ( _settings . UseAnimation )
130- WindowAnimator ( ) ;
117+ animationSound . Position = TimeSpan . Zero ;
118+ animationSound . Play ( ) ;
131119 }
132- break ;
120+ UpdatePosition ( ) ;
121+ Activate ( ) ;
122+ QueryTextBox . Focus ( ) ;
123+ _settings . ActivateTimes ++ ;
124+ if ( ! _viewModel . LastQuerySelected )
125+ {
126+ QueryTextBox . SelectAll ( ) ;
127+ _viewModel . LastQuerySelected = true ;
128+ }
129+
130+ if ( _settings . UseAnimation )
131+ WindowAnimator ( ) ;
133132 }
133+ break ;
134+ }
134135 case nameof ( MainViewModel . QueryTextCursorMovedToEnd ) :
135136 if ( _viewModel . QueryTextCursorMovedToEnd )
136137 {
@@ -211,35 +212,45 @@ private void InitializeNotifyIcon()
211212 Visible = ! _settings . HideNotifyIcon
212213 } ;
213214 contextMenu = new ContextMenu ( ) ;
214- var openIcon = new FontIcon { Glyph = "\ue71e " } ;
215+ var openIcon = new FontIcon
216+ {
217+ Glyph = "\ue71e "
218+ } ;
215219 var open = new MenuItem
216220 {
217- Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayOpen" ) + " (" + _settings . Hotkey + ")" ,
218- Icon = openIcon
221+ Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayOpen" ) + " (" + _settings . Hotkey + ")" , Icon = openIcon
222+ } ;
223+ var gamemodeIcon = new FontIcon
224+ {
225+ Glyph = "\ue7fc "
219226 } ;
220- var gamemodeIcon = new FontIcon { Glyph = "\ue7fc " } ;
221227 var gamemode = new MenuItem
222228 {
223- Header = InternationalizationManager . Instance . GetTranslation ( "GameMode" ) ,
224- Icon = gamemodeIcon
229+ Header = InternationalizationManager . Instance . GetTranslation ( "GameMode" ) , Icon = gamemodeIcon
230+ } ;
231+ var positionresetIcon = new FontIcon
232+ {
233+ Glyph = "\ue73f "
225234 } ;
226- var positionresetIcon = new FontIcon { Glyph = "\ue73f " } ;
227235 var positionreset = new MenuItem
228236 {
229- Header = InternationalizationManager . Instance . GetTranslation ( "PositionReset" ) ,
230- Icon = positionresetIcon
237+ Header = InternationalizationManager . Instance . GetTranslation ( "PositionReset" ) , Icon = positionresetIcon
238+ } ;
239+ var settingsIcon = new FontIcon
240+ {
241+ Glyph = "\ue713 "
231242 } ;
232- var settingsIcon = new FontIcon { Glyph = "\ue713 " } ;
233243 var settings = new MenuItem
234244 {
235- Header = InternationalizationManager . Instance . GetTranslation ( "iconTraySettings" ) ,
236- Icon = settingsIcon
245+ Header = InternationalizationManager . Instance . GetTranslation ( "iconTraySettings" ) , Icon = settingsIcon
246+ } ;
247+ var exitIcon = new FontIcon
248+ {
249+ Glyph = "\ue7e8 "
237250 } ;
238- var exitIcon = new FontIcon { Glyph = "\ue7e8 " } ;
239251 var exit = new MenuItem
240252 {
241- Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayExit" ) ,
242- Icon = exitIcon
253+ Header = InternationalizationManager . Instance . GetTranslation ( "iconTrayExit" ) , Icon = exitIcon
243254 } ;
244255
245256 open . Click += ( o , e ) => _viewModel . ToggleFlowLauncher ( ) ;
@@ -300,10 +311,10 @@ private void ToggleGameMode()
300311 }
301312 private async void PositionReset ( )
302313 {
303- _viewModel . Show ( ) ;
304- await Task . Delay ( 300 ) ; // If don't give a time, Positioning will be weird.
305- Left = HorizonCenter ( ) ;
306- Top = VerticalCenter ( ) ;
314+ _viewModel . Show ( ) ;
315+ await Task . Delay ( 300 ) ; // If don't give a time, Positioning will be weird.
316+ Left = HorizonCenter ( ) ;
317+ Top = VerticalCenter ( ) ;
307318 }
308319 private void InitProgressbarAnimation ( )
309320 {
@@ -320,14 +331,30 @@ private void InitProgressbarAnimation()
320331 da . Freeze ( ) ;
321332 da1 . Freeze ( ) ;
322333
323- var beginStoryboard = new BeginStoryboard ( ) ;
324- beginStoryboard . Storyboard = progressBarStoryBoard ;
334+ const string progressBarAnimationName = "ProgressBarAnimation" ;
335+ var beginStoryboard = new BeginStoryboard
336+ {
337+ Name = progressBarAnimationName , Storyboard = progressBarStoryBoard
338+ } ;
339+
340+ var stopStoryboard = new StopStoryboard ( )
341+ {
342+ BeginStoryboardName = progressBarAnimationName
343+ } ;
325344
326- var trigger = new Trigger { Property = System . Windows . Shapes . Line . VisibilityProperty , Value = Visibility . Visible } ;
345+ var trigger = new Trigger
346+ {
347+ Property = VisibilityProperty , Value = Visibility . Visible
348+ } ;
327349 trigger . EnterActions . Add ( beginStoryboard ) ;
350+ trigger . ExitActions . Add ( stopStoryboard ) ;
351+
328352
329- var progressStyle = new Style ( typeof ( System . Windows . Shapes . Line ) ) ;
330- progressStyle . BasedOn = FindResource ( "PendingLineStyle" ) as Style ;
353+ var progressStyle = new Style ( typeof ( System . Windows . Shapes . Line ) )
354+ {
355+ BasedOn = FindResource ( "PendingLineStyle" ) as Style
356+ } ;
357+ progressStyle . RegisterName ( progressBarAnimationName , beginStoryboard ) ;
331358 progressStyle . Triggers . Add ( trigger ) ;
332359
333360 ProgressBar . Style = progressStyle ;
@@ -343,7 +370,7 @@ public void WindowAnimator()
343370 UpdatePosition ( ) ;
344371 Storyboard sb = new Storyboard ( ) ;
345372 Storyboard iconsb = new Storyboard ( ) ;
346- CircleEase easing = new CircleEase ( ) ; // or whatever easing class you want
373+ CircleEase easing = new CircleEase ( ) ; // or whatever easing class you want
347374 easing . EasingMode = EasingMode . EaseInOut ;
348375 var da = new DoubleAnimation
349376 {
@@ -360,14 +387,14 @@ public void WindowAnimator()
360387 Duration = TimeSpan . FromSeconds ( 0.25 ) ,
361388 FillBehavior = FillBehavior . Stop
362389 } ;
363- var da3 = new DoubleAnimation
364- {
365- From = 12 ,
366- To = 0 ,
367- EasingFunction = easing ,
368- Duration = TimeSpan . FromSeconds ( 0.36 ) ,
369- FillBehavior = FillBehavior . Stop
370- } ;
390+ var da3 = new DoubleAnimation
391+ {
392+ From = 12 ,
393+ To = 0 ,
394+ EasingFunction = easing ,
395+ Duration = TimeSpan . FromSeconds ( 0.36 ) ,
396+ FillBehavior = FillBehavior . Stop
397+ } ;
371398 Storyboard . SetTarget ( da , this ) ;
372399 Storyboard . SetTargetProperty ( da , new PropertyPath ( Window . OpacityProperty ) ) ;
373400 Storyboard . SetTargetProperty ( da2 , new PropertyPath ( Window . TopProperty ) ) ;
@@ -395,10 +422,10 @@ private void OnPreviewDragOver(object sender, DragEventArgs e)
395422 private async void OnContextMenusForSettingsClick ( object sender , RoutedEventArgs e )
396423 {
397424 _viewModel . Hide ( ) ;
398-
399- if ( _settings . UseAnimation )
425+
426+ if ( _settings . UseAnimation )
400427 await Task . Delay ( 100 ) ;
401-
428+
402429 App . API . OpenSettingDialog ( ) ;
403430 }
404431
@@ -416,7 +443,7 @@ private async void OnDeactivated(object sender, EventArgs e)
416443 // and always after Settings window is closed.
417444 if ( _settings . UseAnimation )
418445 await Task . Delay ( 100 ) ;
419-
446+
420447 if ( _settings . HideWhenDeactive )
421448 {
422449 _viewModel . Hide ( ) ;
@@ -454,7 +481,7 @@ public void HideStartup()
454481 _viewModel . Show ( ) ;
455482 }
456483 }
457-
484+
458485 public double HorizonCenter ( )
459486 {
460487 var screen = Screen . FromPoint ( System . Windows . Forms . Cursor . Position ) ;
@@ -536,9 +563,9 @@ private void OnKeyDown(object sender, KeyEventArgs e)
536563 && QueryTextBox . Text . Length > 0
537564 && QueryTextBox . CaretIndex == QueryTextBox . Text . Length )
538565 {
539- var queryWithoutActionKeyword =
566+ var queryWithoutActionKeyword =
540567 QueryBuilder . Build ( QueryTextBox . Text . Trim ( ) , PluginManager . NonGlobalPlugins ) . Search ;
541-
568+
542569 if ( FilesFolders . IsLocationPathString ( queryWithoutActionKeyword ) )
543570 {
544571 _viewModel . BackspaceCommand . Execute ( null ) ;
@@ -574,7 +601,7 @@ public void InitializeColorScheme()
574601
575602 private void QueryTextBox_KeyUp ( object sender , KeyEventArgs e )
576603 {
577- if ( _viewModel . QueryText != QueryTextBox . Text )
604+ if ( _viewModel . QueryText != QueryTextBox . Text )
578605 {
579606 BindingExpression be = QueryTextBox . GetBindingExpression ( System . Windows . Controls . TextBox . TextProperty ) ;
580607 be . UpdateSource ( ) ;
0 commit comments