using WPFluent.Taskbar;
namespace WPFluent;
///
/// Allows you to manage the animations of the window icon in the taskbar.
///
public partial class TaskBarService : ITaskBarService
{
private readonly Dictionary _progressStates = [];
///
public virtual TaskBarProgressState GetState(IntPtr hWnd)
{
if(!_progressStates.TryGetValue(hWnd, out TaskBarProgressState progressState))
{
return TaskBarProgressState.None;
}
return progressState;
}
///
public virtual TaskBarProgressState GetState(Window? window)
{
if(window is null)
{
return TaskBarProgressState.None;
}
IntPtr windowHandle = new WindowInteropHelper(window).Handle;
if(!_progressStates.TryGetValue(windowHandle, out TaskBarProgressState progressState))
{
return TaskBarProgressState.None;
}
return progressState;
}
///
public virtual bool SetState(Window? window, TaskBarProgressState taskBarProgressState)
{
if(window is null)
{
return false;
}
return TaskBarProgress.SetState(window, taskBarProgressState);
}
///
public virtual bool SetState(IntPtr hWnd, TaskBarProgressState taskBarProgressState)
{ return TaskBarProgress.SetState(hWnd, taskBarProgressState); }
///
public virtual bool SetValue(Window? window, int current, int total)
{
if(window == null)
{
return false;
}
IntPtr windowHandle = new WindowInteropHelper(window).Handle;
if(!_progressStates.TryGetValue(windowHandle, out TaskBarProgressState progressState))
{
return TaskBarProgress.SetValue(window, TaskBarProgressState.Normal, current, total);
}
return TaskBarProgress.SetValue(window, progressState, current, total);
}
///
public virtual bool SetValue(IntPtr hWnd, int current, int total)
{
if(!_progressStates.TryGetValue(hWnd, out TaskBarProgressState progressState))
{
return TaskBarProgress.SetValue(hWnd, TaskBarProgressState.Normal, current, total);
}
return TaskBarProgress.SetValue(hWnd, progressState, current, total);
}
///
public virtual bool SetValue(Window? window, TaskBarProgressState taskBarProgressState, int current, int total)
{
if(window is null)
{
return false;
}
return TaskBarProgress.SetValue(window, taskBarProgressState, current, total);
}
///
public virtual bool SetValue(IntPtr hWnd, TaskBarProgressState taskBarProgressState, int current, int total)
{ return TaskBarProgress.SetValue(hWnd, taskBarProgressState, current, total); }
}