refactoring enums

This commit is contained in:
2020-07-11 15:46:20 +02:00
parent 94f5eced01
commit b1e70f09b1
7 changed files with 68 additions and 51 deletions

30
App/Types/AccentColors.cs Normal file
View 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
View 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)
};
}
}
}