From 6e8faff62406b856dc3018d37db2e260c238c7fb Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Sun, 15 Sep 2024 18:26:42 +0100 Subject: [PATCH] Improve querying of app theme preference --- Bloxstrap/Extensions/ThemeEx.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Bloxstrap/Extensions/ThemeEx.cs b/Bloxstrap/Extensions/ThemeEx.cs index 30da539..f5fc70c 100644 --- a/Bloxstrap/Extensions/ThemeEx.cs +++ b/Bloxstrap/Extensions/ThemeEx.cs @@ -9,15 +9,10 @@ namespace Bloxstrap.Extensions if (dialogTheme != Theme.Default) return dialogTheme; - RegistryKey? key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"); + using var 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; - } + if (key?.GetValue("AppsUseLightTheme") is int value && value == 0) + return Theme.Dark; return Theme.Light; }