2025-04-24 20:56:44 +08:00
|
|
|
|
using WPFluent.Appearance;
|
2025-02-10 20:53:40 +08:00
|
|
|
|
|
|
|
|
|
|
namespace WPFluent;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Lets you set the app theme.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class ThemeService : IThemeService
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public virtual ApplicationTheme GetTheme() => ApplicationThemeManager.GetAppTheme();
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public bool SetAccent(Color accentColor)
|
|
|
|
|
|
{
|
|
|
|
|
|
ApplicationAccentColorManager.Apply(accentColor);
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public bool SetAccent(SolidColorBrush accentSolidBrush)
|
|
|
|
|
|
{
|
|
|
|
|
|
Color color = accentSolidBrush.Color;
|
|
|
|
|
|
color.A = (byte)Math.Round(accentSolidBrush.Opacity * byte.MaxValue);
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationAccentColorManager.Apply(color);
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public virtual bool SetTheme(ApplicationTheme applicationTheme)
|
|
|
|
|
|
{
|
2025-04-24 20:56:44 +08:00
|
|
|
|
if (ApplicationThemeManager.GetAppTheme() == applicationTheme)
|
2025-02-10 20:53:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationThemeManager.Apply(applicationTheme);
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|