This commit is contained in:
Daniel Clark
2021-02-05 01:39:51 +00:00
parent 666067a36c
commit 45a9eb9cd2
73 changed files with 2669 additions and 0 deletions
@@ -0,0 +1,30 @@
using Microsoft.Win32;
using NotificationFlyout.Wpf.UI.Extensions;
using System;
namespace NotificationFlyout.Wpf.UI.Helpers
{
public static class SystemSettingsHelper
{
private static readonly string PersonalizeKey = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
public static SystemTheme DefaultSystemTheme => GetDefaultSystemTheme();
private static SystemTheme GetDefaultSystemTheme()
{
return Environment.OSVersion.IsGreaterThan(OperatingSystemVersion.Windows10_1809) &&
ReadDword(PersonalizeKey, "SystemUsesLightTheme")
? SystemTheme.Light
: SystemTheme.Dark;
}
private static bool ReadDword(string key, string valueName, int defaultValue = 0)
{
using var baseKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64);
using var subKey = baseKey.OpenSubKey(key);
return subKey.GetValue<int>(valueName, defaultValue) > 0;
}
public static bool IsTransparencyEnabled => ReadDword(PersonalizeKey, "EnableTransparency");
}
}