bloxstrap/Bloxstrap/Extensions/ThemeEx.cs
pizzaboxer 58fb73c127
Refactor class structure for singletons/utilities
cleanup necessary namespaces and adjust namespaces for certain classes to better represent what they're for
models, helpers and tools are all different and shouldnt really be under the same namespace
2023-04-26 21:14:35 +01:00

27 lines
682 B
C#

using Microsoft.Win32;
using Bloxstrap.Enums;
namespace Bloxstrap.Extensions
{
public static class ThemeEx
{
public static Theme GetFinal(this Theme dialogTheme)
{
if (dialogTheme != Theme.Default)
return dialogTheme;
RegistryKey? key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize");
if (key is not null)
{
var value = key.GetValue("AppsUseLightTheme");
if (value is not null && (int)value == 0)
return Theme.Dark;
}
return Theme.Light;
}
}
}