mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
fix<Launcher>: TaskbarItemInfo.ProgressState should disappears only when all tasks are complete
This commit is contained in:
parent
918eb48663
commit
c85052bbcc
2 changed files with 24 additions and 3 deletions
|
@ -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 {
|
|||
/// 主窗体
|
||||
/// </summary>
|
||||
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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue