mirror of
https://github.com/holgerb83/ModernWpfPlayground.git
synced 2025-12-15 00:26:23 +01:00
refactoring enums
This commit is contained in:
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