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;