CSGO-Projects/ConfigManagerV2/ConfigManagerV2/Themes/ThemesController.cs
MathiasL 3d99b1f68b Migrate to .NET 6.0 and create ConfigManagerV2 project
* Make necessary adjustments to have the same working program
* AssemblyInfo is not set via the file anymore, but the csproj file or in the project settings under Package->General (AssemblyVersion is the one displayed in the Help window)
* Add null-forgiving operators etc. for new language version
* Move stuff that is shared between the DamageCalculator and ConfigManagerV2 into its separate project
2022-03-25 19:55:14 +01:00

46 lines
1.4 KiB
C#

using System;
using System.Windows;
namespace REghZyFramework.Themes
{
public static class ThemesController
{
public enum ThemeTypes
{
Light, ColourfulLight,
Dark, ColourfulDark
}
public static ThemeTypes CurrentTheme { get; set; }
private static ResourceDictionary ThemeDictionary
{
get { return Application.Current.Resources.MergedDictionaries[0]; }
set { Application.Current.Resources.MergedDictionaries[0] = value; }
}
private static void ChangeTheme(Uri uri)
{
ThemeDictionary = new ResourceDictionary() { Source = uri };
}
public static void SetTheme(ThemeTypes theme)
{
string themeName = null;
CurrentTheme = theme;
switch (theme)
{
case ThemeTypes.Dark: themeName = "DarkTheme"; break;
case ThemeTypes.Light: themeName = "LightTheme"; break;
case ThemeTypes.ColourfulDark: themeName = "ColourfulDarkTheme"; break;
case ThemeTypes.ColourfulLight: themeName = "ColourfulLightTheme"; break;
}
try
{
if (!string.IsNullOrEmpty(themeName))
ChangeTheme(new Uri($"Themes/{themeName}.xaml", UriKind.Relative));
}
catch { }
}
}
}