bloxstrap/Bloxstrap/Extensions/ThemeEx.cs
2024-09-15 18:26:42 +01:00

21 lines
548 B
C#

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