更新整理

This commit is contained in:
GG Z
2025-04-24 20:56:44 +08:00
parent 155cef46f8
commit 5b6d67b571
813 changed files with 14437 additions and 12362 deletions

View File

@@ -1,15 +1,16 @@
using WPFluent.Controls;
using System.Windows.Controls;
using WPFluent.Controls;
namespace WPFluent;
/// <summary>
/// Represents a contract with the service that creates <see cref="ContentDialog"/>.
/// </summary>
/// <example>
/// <code lang="xml"> &lt;ContentPresenter x:Name="RootContentDialogPresenter" Grid.Row="0" /&gt;</code> <code
/// lang="csharp"> IContentDialogService contentDialogService = new ContentDialogService();
/// <code lang="xml">&lt;ContentPresenter x:Name="RootContentDialogPresenter" Grid.Row="0" /&gt;</code> <code
/// lang="csharp">IContentDialogService contentDialogService = new ContentDialogService();
/// contentDialogService.SetContentPresenter(RootContentDialogPresenter); await _contentDialogService.ShowAsync( new
/// ContentDialog(){ Title = "The cake?", Content = "IS A LIE!", PrimaryButtonText = "Save", SecondaryButtonText =
/// "Don't Save", CloseButtonText = "Cancel" } );</code>

View File

@@ -1,7 +1,4 @@
using WPFluent.Abstractions;
using WPFluent.Abstractions;
using WPFluent.Controls;
namespace WPFluent;

View File

@@ -1,10 +1,10 @@
using WPFluent.Controls;
using System.Windows.Controls;
using WPFluent.Controls;
namespace WPFluent;
/// <summary>

View File

@@ -1,80 +0,0 @@
using WPFluent.Taskbar;
namespace WPFluent;
/// <summary>
/// Represents a contract with a service that provides methods for manipulating the taskbar.
/// </summary>
public interface ITaskBarService
{
/// <summary>
/// Gets taskbar state of the selected window handle.
/// </summary>
/// <param name="hWnd">Window handle.</param>
/// <returns>The current state of system TaskBar.</returns>
TaskBarProgressState GetState(IntPtr hWnd);
/// <summary>
/// Gets taskbar state of the selected window.
/// </summary>
/// <param name="window">Selected window.</param>
/// <returns>The current state of system TaskBar.</returns>
TaskBarProgressState GetState(Window? window);
/// <summary>
/// Sets taskbar state of the selected window handle.
/// </summary>
/// <param name="hWnd">Window handle to modify.</param>
/// <param name="taskBarProgressState">Progress sate to set.</param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool SetState(IntPtr hWnd, TaskBarProgressState taskBarProgressState);
/// <summary>
/// Sets taskbar state of the selected window.
/// </summary>
/// <param name="window">Window to modify.</param>
/// <param name="taskBarProgressState">Progress sate to set.</param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool SetState(Window? window, TaskBarProgressState taskBarProgressState);
/// <summary>
/// Sets taskbar value of the selected window handle.
/// </summary>
/// <param name="hWnd">Window handle to modify.</param>
/// <param name="current">Current value to display.</param>
/// <param name="max">Maximum number for division.</param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool SetValue(IntPtr hWnd, int current, int max);
/// <summary>
/// Sets taskbar value of the selected window.
/// </summary>
/// <param name="window">Window to modify.</param>
/// <param name="current">Current value to display.</param>
/// <param name="total">Maximum number for division.</param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool SetValue(Window? window, int current, int total);
/// <summary>
/// Sets taskbar value of the selected window handle.
/// </summary>
/// <param name="hWnd">Window handle to modify.</param>
/// <param name="taskBarProgressState">Progress sate to set.</param>
/// <param name="current">Current value to display.</param>
/// <param name="total">Maximum number for division.</param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool SetValue(IntPtr hWnd, TaskBarProgressState taskBarProgressState, int current, int total);
/// <summary>
/// Sets taskbar value of the selected window.
/// </summary>
/// <param name="window">Window to modify.</param>
/// <param name="taskBarProgressState">Progress sate to set.</param>
/// <param name="current">Current value to display.</param>
/// <param name="total">Maximum number for division.</param>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool SetValue(Window? window, TaskBarProgressState taskBarProgressState, int current, int total);
}

View File

@@ -10,18 +10,6 @@ namespace WPFluent;
/// </summary>
public interface IThemeService
{
/// <summary>
/// Gets current system theme.
/// </summary>
/// <returns>Currently set Windows theme using system enumeration.</returns>
SystemTheme GetNativeSystemTheme();
/// <summary>
/// Gets current system theme.
/// </summary>
/// <returns>Currently set Windows theme.</returns>
ApplicationTheme GetSystemTheme();
/// <summary>
/// Gets current application theme.
/// </summary>
@@ -40,12 +28,6 @@ public interface IThemeService
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool SetAccent(SolidColorBrush accentSolidBrush);
/// <summary>
/// Sets currently used Windows OS accent.
/// </summary>
/// <returns><see langword="true"/> if the operation succeeds. <see langword="false"/> otherwise.</returns>
bool SetSystemAccent();
/// <summary>
/// Sets current application theme.
/// </summary>

View File

@@ -23,7 +23,7 @@ public class SnackbarService : ISnackbarService
/// <inheritdoc/>
public void Show(string title, string message, ControlAppearance appearance, IconElement? icon, TimeSpan timeout)
{
if(_presenter is null)
if (_presenter is null)
{
throw new InvalidOperationException($"The SnackbarPresenter was never set");
}

View File

@@ -1,102 +0,0 @@
using WPFluent.Taskbar;
namespace WPFluent;
/// <summary>
/// Allows you to manage the animations of the window icon in the taskbar.
/// </summary>
public partial class TaskBarService : ITaskBarService
{
private readonly Dictionary<IntPtr, TaskBarProgressState> _progressStates = [];
/// <inheritdoc/>
public virtual TaskBarProgressState GetState(IntPtr hWnd)
{
if(!_progressStates.TryGetValue(hWnd, out TaskBarProgressState progressState))
{
return TaskBarProgressState.None;
}
return progressState;
}
/// <inheritdoc/>
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;
}
/// <inheritdoc/>
public virtual bool SetState(Window? window, TaskBarProgressState taskBarProgressState)
{
if(window is null)
{
return false;
}
return TaskBarProgress.SetState(window, taskBarProgressState);
}
/// <inheritdoc/>
public virtual bool SetState(IntPtr hWnd, TaskBarProgressState taskBarProgressState)
{ return TaskBarProgress.SetState(hWnd, taskBarProgressState); }
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public virtual bool SetValue(IntPtr hWnd, TaskBarProgressState taskBarProgressState, int current, int total)
{ return TaskBarProgress.SetValue(hWnd, taskBarProgressState, current, total); }
}

View File

@@ -1,7 +1,4 @@
using WPFluent.Appearance;
using WPFluent.Appearance;
namespace WPFluent;
@@ -10,30 +7,6 @@ namespace WPFluent;
/// </summary>
public partial class ThemeService : IThemeService
{
/// <inheritdoc/>
public virtual SystemTheme GetNativeSystemTheme() => ApplicationThemeManager.GetSystemTheme();
/// <inheritdoc/>
public virtual ApplicationTheme GetSystemTheme()
{
SystemTheme systemTheme = ApplicationThemeManager.GetSystemTheme();
return systemTheme switch
{
SystemTheme.Light => ApplicationTheme.Light,
SystemTheme.Dark => ApplicationTheme.Dark,
SystemTheme.Glow => ApplicationTheme.Dark,
SystemTheme.CapturedMotion => ApplicationTheme.Dark,
SystemTheme.Sunrise => ApplicationTheme.Light,
SystemTheme.Flow => ApplicationTheme.Light,
SystemTheme.HCBlack => ApplicationTheme.HighContrast,
SystemTheme.HC1 => ApplicationTheme.HighContrast,
SystemTheme.HC2 => ApplicationTheme.HighContrast,
SystemTheme.HCWhite => ApplicationTheme.HighContrast,
_ => ApplicationTheme.Unknown,
};
}
/// <inheritdoc/>
public virtual ApplicationTheme GetTheme() => ApplicationThemeManager.GetAppTheme();
@@ -56,18 +29,10 @@ public partial class ThemeService : IThemeService
return true;
}
/// <inheritdoc/>
public bool SetSystemAccent()
{
ApplicationAccentColorManager.ApplySystemAccent();
return true;
}
/// <inheritdoc/>
public virtual bool SetTheme(ApplicationTheme applicationTheme)
{
if(ApplicationThemeManager.GetAppTheme() == applicationTheme)
if (ApplicationThemeManager.GetAppTheme() == applicationTheme)
{
return false;
}