diff --git a/NotificationFlyout.Wpf.UI/Extensions/RegistryKeyExtensions.cs b/NotificationFlyout.Wpf.UI/Extensions/RegistryKeyExtensions.cs new file mode 100644 index 0000000..1962139 --- /dev/null +++ b/NotificationFlyout.Wpf.UI/Extensions/RegistryKeyExtensions.cs @@ -0,0 +1,12 @@ +using Microsoft.Win32; + +namespace NotificationFlyout.Wpf.UI.Extensions +{ + public static class RegistryKeyExtensions + { + public static T GetValue(this RegistryKey key, string valueName, T defaultValue = default) + { + return string.IsNullOrWhiteSpace(valueName) ? defaultValue : key.GetValue(valueName, defaultValue) is T value ? value : defaultValue; + } + } +} diff --git a/NotificationFlyout.Wpf.UI/Helpers/SystemPersonalisationHelper.cs b/NotificationFlyout.Wpf.UI/Helpers/SystemPersonalisationHelper.cs index fa7cdb3..6607705 100644 --- a/NotificationFlyout.Wpf.UI/Helpers/SystemPersonalisationHelper.cs +++ b/NotificationFlyout.Wpf.UI/Helpers/SystemPersonalisationHelper.cs @@ -37,8 +37,8 @@ namespace NotificationFlyout.Wpf.UI.Helpers private SystemTheme GetSystemTheme() { - var uiTheme = _settings.GetColorValue(UIColorType.Background).ToString(); - return uiTheme == "#FFFFFFFF" ? SystemTheme.Light : SystemTheme.Dark; + var color = _settings.GetColorValue(UIColorType.Background).ToString(); + return color == "#FFFFFFFF" ? SystemTheme.Light : SystemTheme.Dark; } private void OnColorValuesChanged(UISettings sender, object args)