From c85052bbccbc39a43d53e4900ba631a6ca5a3288 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 13 Oct 2023 10:26:11 +0800 Subject: [PATCH] fix: TaskbarItemInfo.ProgressState should disappears only when all tasks are complete --- src/Views/Launcher.xaml.cs | 19 +++++++++++++++++++ src/Views/Widgets/Dashboard.xaml.cs | 8 +++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Views/Launcher.xaml.cs b/src/Views/Launcher.xaml.cs index 0e3cee7e..7d67f71e 100644 --- a/src/Views/Launcher.xaml.cs +++ b/src/Views/Launcher.xaml.cs @@ -7,6 +7,7 @@ using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Media; using System.Windows.Shapes; +using System.Windows.Shell; namespace SourceGit.Views { @@ -14,6 +15,7 @@ namespace SourceGit.Views { /// 主窗体 /// public partial class Launcher : Controls.Window { + private int taskBarProgressRequest = 0; public Launcher() { Models.Watcher.Opened += OpenRepository; @@ -21,6 +23,22 @@ namespace SourceGit.Views { tabs.Add(); } + #region TASKBAR_PROGRESS + public void IncreaseProgressBar() { + if (taskBarProgressRequest == 0) TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate; + taskBarProgressRequest++; + } + + public void DecreaseProgressBar() { + taskBarProgressRequest--; + if (taskBarProgressRequest <= 0) { + taskBarProgressRequest = 0; + TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; + } + } + #endregion + + #region WINDOW_EVENTS private void OnClosing(object sender, CancelEventArgs e) { var restore = Models.Preference.Instance.Restore; if (!restore.IsEnabled) return; @@ -46,6 +64,7 @@ namespace SourceGit.Views { Models.Preference.Save(); } + #endregion #region OPEN_REPO private void OpenRepository(Models.Repository repo) { diff --git a/src/Views/Widgets/Dashboard.xaml.cs b/src/Views/Widgets/Dashboard.xaml.cs index 06c4535d..9bb7764a 100644 --- a/src/Views/Widgets/Dashboard.xaml.cs +++ b/src/Views/Widgets/Dashboard.xaml.cs @@ -155,18 +155,20 @@ namespace SourceGit.Views.Widgets { isPopupLocked = true; popupProgressMask.Visibility = Visibility.Visible; processing.IsAnimating = true; - App.Current.MainWindow.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate; + + var launcher = App.Current.MainWindow as Launcher; + launcher.IncreaseProgressBar(); var task = curPopup.Start(); if (task != null) { var close = await task; - App.Current.MainWindow.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; + launcher.DecreaseProgressBar(); if (close) { ClosePopups(true); return; } } else { - App.Current.MainWindow.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; + launcher.DecreaseProgressBar(); } isPopupLocked = false;