@@ -28,9 +28,6 @@ namespace Flow.Launcher
2828 public partial class MainWindow
2929 {
3030 #region Private Fields
31-
32- private readonly Storyboard _progressBarStoryboard = new Storyboard ( ) ;
33- private bool isProgressBarStoryboardPaused ;
3431 private Settings _settings ;
3532 private NotifyIcon _notifyIcon ;
3633 private ContextMenu contextMenu ;
@@ -119,39 +116,9 @@ private void OnLoaded(object sender, RoutedEventArgs _)
119116 _viewModel . LastQuerySelected = true ;
120117 }
121118
122- if ( _viewModel . ProgressBarVisibility == Visibility . Visible && isProgressBarStoryboardPaused )
123- {
124- _progressBarStoryboard . Begin ( ProgressBar , true ) ;
125- isProgressBarStoryboardPaused = false ;
126- }
127-
128119 if ( _settings . UseAnimation )
129120 WindowAnimator ( ) ;
130121 }
131- else if ( ! isProgressBarStoryboardPaused )
132- {
133- _progressBarStoryboard . Stop ( ProgressBar ) ;
134- isProgressBarStoryboardPaused = true ;
135- }
136-
137- break ;
138- }
139- case nameof ( MainViewModel . ProgressBarVisibility ) :
140- {
141- Dispatcher . Invoke ( ( ) =>
142- {
143- if ( _viewModel . ProgressBarVisibility == Visibility . Hidden && ! isProgressBarStoryboardPaused )
144- {
145- _progressBarStoryboard . Stop ( ProgressBar ) ;
146- isProgressBarStoryboardPaused = true ;
147- }
148- else if ( _viewModel . MainWindowVisibilityStatus &&
149- isProgressBarStoryboardPaused )
150- {
151- _progressBarStoryboard . Begin ( ProgressBar , true ) ;
152- isProgressBarStoryboardPaused = false ;
153- }
154- } ) ;
155122 break ;
156123 }
157124 case nameof ( MainViewModel . QueryTextCursorMovedToEnd ) :
@@ -291,17 +258,32 @@ private void ToggleGameMode()
291258 }
292259 private void InitProgressbarAnimation ( )
293260 {
294- var da = new DoubleAnimation ( ProgressBar . X2 , ActualWidth + 150 ,
295- new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
261+ var progressBarStoryBoard = new Storyboard ( ) ;
262+
263+ var da = new DoubleAnimation ( ProgressBar . X2 , ActualWidth + 150 , new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
296264 var da1 = new DoubleAnimation ( ProgressBar . X1 , ActualWidth + 50 , new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
297265 Storyboard . SetTargetProperty ( da , new PropertyPath ( "(Line.X2)" ) ) ;
298266 Storyboard . SetTargetProperty ( da1 , new PropertyPath ( "(Line.X1)" ) ) ;
299- _progressBarStoryboard . Children . Add ( da ) ;
300- _progressBarStoryboard . Children . Add ( da1 ) ;
301- _progressBarStoryboard . RepeatBehavior = RepeatBehavior . Forever ;
267+ progressBarStoryBoard . Children . Add ( da ) ;
268+ progressBarStoryBoard . Children . Add ( da1 ) ;
269+ progressBarStoryBoard . RepeatBehavior = RepeatBehavior . Forever ;
270+
271+ da . Freeze ( ) ;
272+ da1 . Freeze ( ) ;
273+
274+ var beginStoryboard = new BeginStoryboard ( ) ;
275+ beginStoryboard . Storyboard = progressBarStoryBoard ;
276+
277+ var trigger = new Trigger { Property = System . Windows . Shapes . Line . VisibilityProperty , Value = Visibility . Visible } ;
278+ trigger . EnterActions . Add ( beginStoryboard ) ;
279+
280+ var progressStyle = new Style ( typeof ( System . Windows . Shapes . Line ) ) ;
281+ progressStyle . BasedOn = FindResource ( "PendingLineStyle" ) as Style ;
282+ progressStyle . Triggers . Add ( trigger ) ;
283+
284+ ProgressBar . Style = progressStyle ;
302285
303286 _viewModel . ProgressBarVisibility = Visibility . Hidden ;
304- isProgressBarStoryboardPaused = true ;
305287 }
306288 public void WindowAnimator ( )
307289 {
0 commit comments