From 5688f377e03fc8f58c1baba1934a164ef6b493f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Sat, 16 Jan 2021 02:34:26 +0800 Subject: [PATCH 1/6] Stop ProgressBar animation when Flow is hidden Co-Authored-By: imsh <9258159+imsh@users.noreply.github.com> --- Flow.Launcher/MainWindow.xaml | 2 +- Flow.Launcher/MainWindow.xaml.cs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index a2cfe569d..4cc0b4428 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -97,7 +97,7 @@ Background="Transparent"/> diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 3812b4e1f..87155ea17 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -84,8 +84,15 @@ namespace Flow.Launcher QueryTextBox.SelectAll(); _viewModel.LastQuerySelected = true; } + + ProgressBar.BeginStoryboard(_progressBarStoryboard); + } + else + { + _progressBarStoryboard.Stop(); } } + }; _settings.PropertyChanged += (o, e) => { From 07309568226695e73f46e44d38531385b9e1405f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Tue, 19 Jan 2021 22:42:32 +0800 Subject: [PATCH 2/6] Make pause and resume when progressbarvisibility changed. --- Flow.Launcher/MainWindow.xaml.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 87155ea17..114b6cd7f 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -52,7 +52,7 @@ namespace Flow.Launcher private void OnInitialized(object sender, EventArgs e) { - + } private void OnLoaded(object sender, RoutedEventArgs _) @@ -85,14 +85,27 @@ namespace Flow.Launcher _viewModel.LastQuerySelected = true; } - ProgressBar.BeginStoryboard(_progressBarStoryboard); } else { - _progressBarStoryboard.Stop(); } } - + else if (e.PropertyName == nameof(MainViewModel.ProgressBarVisibility)) + { + Dispatcher.Invoke(() => + { + if (ProgressBar.Visibility == Visibility.Hidden) + { + _progressBarStoryboard.Pause(); + } + else + { + _progressBarStoryboard.Resume(); + } + }, System.Windows.Threading.DispatcherPriority.Render); + + } + }; _settings.PropertyChanged += (o, e) => { From 5d1790cb0eda18afb6de232ce8cfd198f2905c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Thu, 21 Jan 2021 12:11:01 +0800 Subject: [PATCH 3/6] change visibility from ProgressBar.Visibility to _viewModel.ProgressBarVisibility --- Flow.Launcher/MainWindow.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 114b6cd7f..96efda94d 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -94,7 +94,7 @@ namespace Flow.Launcher { Dispatcher.Invoke(() => { - if (ProgressBar.Visibility == Visibility.Hidden) + if (_viewModel.ProgressBarVisibility == Visibility.Hidden) { _progressBarStoryboard.Pause(); } From 2db3f829e48331337fcf5c27878cda96282144a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Fri, 22 Jan 2021 17:13:35 +0800 Subject: [PATCH 4/6] change logic 1. Disable animation when progressbar is hidden or mainwindow is collapsed 2. resume only when both visibility and progressbar visibility is visible --- Flow.Launcher/MainWindow.xaml.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 96efda94d..77fec72a1 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -1,4 +1,5 @@ -using System; + +using System; using System.ComponentModel; using System.Windows; using System.Windows.Input; @@ -85,9 +86,14 @@ namespace Flow.Launcher _viewModel.LastQuerySelected = true; } + if (_viewModel.ProgressBarVisibility == Visibility.Visible) + { + _progressBarStoryboard.Resume(); + } } else { + _progressBarStoryboard.Pause(); } } else if (e.PropertyName == nameof(MainViewModel.ProgressBarVisibility)) @@ -98,7 +104,7 @@ namespace Flow.Launcher { _progressBarStoryboard.Pause(); } - else + else if (Visibility == Visibility.Visible) { _progressBarStoryboard.Resume(); } From db63833e93c0b89290fa30a79533b82e28051dfc Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 25 Jan 2021 07:15:11 +1100 Subject: [PATCH 5/6] add condition for progress bar to control pause and resume --- Flow.Launcher/MainWindow.xaml.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 77fec72a1..f9f4bd511 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -1,5 +1,4 @@ - -using System; +using System; using System.ComponentModel; using System.Windows; using System.Windows.Input; @@ -27,6 +26,7 @@ namespace Flow.Launcher #region Private Fields private readonly Storyboard _progressBarStoryboard = new Storyboard(); + private bool isProgressBarStoryboardPaused; private Settings _settings; private NotifyIcon _notifyIcon; private MainViewModel _viewModel; @@ -86,32 +86,34 @@ namespace Flow.Launcher _viewModel.LastQuerySelected = true; } - if (_viewModel.ProgressBarVisibility == Visibility.Visible) + if (_viewModel.ProgressBarVisibility == Visibility.Visible && isProgressBarStoryboardPaused) { _progressBarStoryboard.Resume(); + isProgressBarStoryboardPaused = false; } } - else + else if (!isProgressBarStoryboardPaused) { _progressBarStoryboard.Pause(); + isProgressBarStoryboardPaused = true; } } else if (e.PropertyName == nameof(MainViewModel.ProgressBarVisibility)) { Dispatcher.Invoke(() => { - if (_viewModel.ProgressBarVisibility == Visibility.Hidden) + if (_viewModel.ProgressBarVisibility == Visibility.Hidden && !isProgressBarStoryboardPaused) { _progressBarStoryboard.Pause(); + isProgressBarStoryboardPaused = true; } - else if (Visibility == Visibility.Visible) + else if (Visibility == Visibility.Visible && isProgressBarStoryboardPaused) { _progressBarStoryboard.Resume(); + isProgressBarStoryboardPaused = false; } }, System.Windows.Threading.DispatcherPriority.Render); - } - }; _settings.PropertyChanged += (o, e) => { @@ -196,6 +198,7 @@ namespace Flow.Launcher _progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever; ProgressBar.BeginStoryboard(_progressBarStoryboard); _viewModel.ProgressBarVisibility = Visibility.Hidden; + isProgressBarStoryboardPaused = true; } private void OnMouseDown(object sender, MouseButtonEventArgs e) From 36e6f5eccb6cbd482ffbf13801a015ffc8a8598e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BC=98=E9=9F=AC?= Date: Mon, 25 Jan 2021 04:45:24 +0800 Subject: [PATCH 6/6] Use _viewModel.MainWindowVisibility instead of Visibility --- Flow.Launcher/MainWindow.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index f9f4bd511..04a1063f8 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -74,7 +74,7 @@ namespace Flow.Launcher { if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility)) { - if (Visibility == Visibility.Visible) + if (_viewModel.MainWindowVisibility == Visibility.Visible) { Activate(); QueryTextBox.Focus(); @@ -107,7 +107,7 @@ namespace Flow.Launcher _progressBarStoryboard.Pause(); isProgressBarStoryboardPaused = true; } - else if (Visibility == Visibility.Visible && isProgressBarStoryboardPaused) + else if (_viewModel.MainWindowVisibility == Visibility.Visible && isProgressBarStoryboardPaused) { _progressBarStoryboard.Resume(); isProgressBarStoryboardPaused = false;