@@ -26,6 +26,7 @@ public partial class MainWindow
26
26
#region Private Fields
27
27
28
28
private readonly Storyboard _progressBarStoryboard = new Storyboard ( ) ;
29
+ private bool isProgressBarStoryboardPaused ;
29
30
private Settings _settings ;
30
31
private NotifyIcon _notifyIcon ;
31
32
private MainViewModel _viewModel ;
@@ -52,7 +53,7 @@ private void OnClosing(object sender, CancelEventArgs e)
52
53
53
54
private void OnInitialized ( object sender , EventArgs e )
54
55
{
55
-
56
+
56
57
}
57
58
58
59
private void OnLoaded ( object sender , RoutedEventArgs _ )
@@ -73,7 +74,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
73
74
{
74
75
if ( e . PropertyName == nameof ( MainViewModel . MainWindowVisibility ) )
75
76
{
76
- if ( Visibility == Visibility . Visible )
77
+ if ( _viewModel . MainWindowVisibility == Visibility . Visible )
77
78
{
78
79
Activate ( ) ;
79
80
QueryTextBox . Focus ( ) ;
@@ -84,7 +85,34 @@ private void OnLoaded(object sender, RoutedEventArgs _)
84
85
QueryTextBox . SelectAll ( ) ;
85
86
_viewModel . LastQuerySelected = true ;
86
87
}
88
+
89
+ if ( _viewModel . ProgressBarVisibility == Visibility . Visible && isProgressBarStoryboardPaused )
90
+ {
91
+ _progressBarStoryboard . Resume ( ) ;
92
+ isProgressBarStoryboardPaused = false ;
93
+ }
87
94
}
95
+ else if ( ! isProgressBarStoryboardPaused )
96
+ {
97
+ _progressBarStoryboard . Pause ( ) ;
98
+ isProgressBarStoryboardPaused = true ;
99
+ }
100
+ }
101
+ else if ( e . PropertyName == nameof ( MainViewModel . ProgressBarVisibility ) )
102
+ {
103
+ Dispatcher . Invoke ( ( ) =>
104
+ {
105
+ if ( _viewModel . ProgressBarVisibility == Visibility . Hidden && ! isProgressBarStoryboardPaused )
106
+ {
107
+ _progressBarStoryboard . Pause ( ) ;
108
+ isProgressBarStoryboardPaused = true ;
109
+ }
110
+ else if ( _viewModel . MainWindowVisibility == Visibility . Visible && isProgressBarStoryboardPaused )
111
+ {
112
+ _progressBarStoryboard . Resume ( ) ;
113
+ isProgressBarStoryboardPaused = false ;
114
+ }
115
+ } , System . Windows . Threading . DispatcherPriority . Render ) ;
88
116
}
89
117
} ;
90
118
_settings . PropertyChanged += ( o , e ) =>
@@ -170,6 +198,7 @@ private void InitProgressbarAnimation()
170
198
_progressBarStoryboard . RepeatBehavior = RepeatBehavior . Forever ;
171
199
ProgressBar . BeginStoryboard ( _progressBarStoryboard ) ;
172
200
_viewModel . ProgressBarVisibility = Visibility . Hidden ;
201
+ isProgressBarStoryboardPaused = true ;
173
202
}
174
203
175
204
private void OnMouseDown ( object sender , MouseButtonEventArgs e )
0 commit comments