From ec847fd6a54c2b98a7119158429c37e7e7f0ebc1 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Mon, 8 Feb 2021 21:41:46 +0000 Subject: [PATCH] Added RegistryKeyExtensions --- .../Extensions/RegistryKeyExtensions.cs | 12 ++++++++++++ .../Helpers/SystemPersonalisationHelper.cs | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 NotificationFlyout.Wpf.UI/Extensions/RegistryKeyExtensions.cs 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)