forked from gitextensions/gitextensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskbarProgress.cs
42 lines (38 loc) · 1.13 KB
/
TaskbarProgress.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using GitCommands.Utils;
using Microsoft.WindowsAPICodePack.Taskbar;
namespace GitUI
{
public static class TaskbarProgress
{
private static void Try(Action<TaskbarManager> action)
{
if (EnvUtils.RunningOnWindowsWithMainWindow() && TaskbarManager.IsPlatformSupported)
{
try
{
action(TaskbarManager.Instance);
}
catch (InvalidOperationException)
{
}
}
}
public static void Clear()
{
Try(taskbar => taskbar.SetProgressState(TaskbarProgressBarState.NoProgress));
}
public static void SetProgress(TaskbarProgressBarState state, int progressValue, int maximumValue)
{
Try(taskbar =>
{
taskbar.SetProgressState(state);
taskbar.SetProgressValue(progressValue, maximumValue);
});
}
public static void SetState(TaskbarProgressBarState state)
{
Try(taskbar => taskbar.SetProgressState(state));
}
}
}