mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-06-30 09:40:52 +02:00
refactoring enums
This commit is contained in:
30
App/Types/AccentColors.cs
Normal file
30
App/Types/AccentColors.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ModernWpfPlayground.Types
|
||||
{
|
||||
public enum AccentColors
|
||||
{
|
||||
Green,
|
||||
Yellow,
|
||||
Blue,
|
||||
Purple,
|
||||
Red
|
||||
}
|
||||
|
||||
public static class AccentColorExtension
|
||||
{
|
||||
public static Color ToWindowsColor(this AccentColors accentColor)
|
||||
{
|
||||
return accentColor switch
|
||||
{
|
||||
AccentColors.Green => Color.FromRgb(0, 86, 76),
|
||||
AccentColors.Yellow => Color.FromRgb(164, 144, 0),
|
||||
AccentColors.Blue => Color.FromRgb(0, 120, 215),
|
||||
AccentColors.Purple => Color.FromRgb(104, 33, 122),
|
||||
AccentColors.Red => Color.FromRgb(183, 71, 42),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(accentColor), accentColor, null)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
27
App/Types/ThemeMode.cs
Normal file
27
App/Types/ThemeMode.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using ModernWpf;
|
||||
|
||||
namespace ModernWpfPlayground.Types
|
||||
{
|
||||
public enum ThemeMode
|
||||
{
|
||||
[Description("Light")] Light,
|
||||
[Description("Dark")] Dark,
|
||||
[Description("Use system setting")] UseSystemSetting
|
||||
}
|
||||
|
||||
public static class ThemeModeExtension
|
||||
{
|
||||
public static ApplicationTheme? ToApplicationTheme(this ThemeMode themeMode)
|
||||
{
|
||||
return themeMode switch
|
||||
{
|
||||
ThemeMode.Light => ApplicationTheme.Light,
|
||||
ThemeMode.Dark => ApplicationTheme.Dark,
|
||||
ThemeMode.UseSystemSetting => default,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(themeMode), themeMode, null)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user