Skip to content

Commit

Permalink
Improve querying of app theme preference
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Sep 15, 2024
1 parent 83e3c48 commit 6e8faff
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions Bloxstrap/Extensions/ThemeEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@ public static Theme GetFinal(this Theme dialogTheme)
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;
}
Expand Down

0 comments on commit 6e8faff

Please sign in to comment.