From 4795bf8b66df1b74cc77aa43eee6f355ca03e9e3 Mon Sep 17 00:00:00 2001 From: Bugadinho <31747009+Bugadinho@users.noreply.github.com> Date: Sun, 5 Jan 2025 23:37:01 -0300 Subject: [PATCH] Use WinRT to get dark theme --- Bloxstrap/Extensions/ThemeEx.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Bloxstrap/Extensions/ThemeEx.cs b/Bloxstrap/Extensions/ThemeEx.cs index f5fc70c..2a1b924 100644 --- a/Bloxstrap/Extensions/ThemeEx.cs +++ b/Bloxstrap/Extensions/ThemeEx.cs @@ -1,4 +1,4 @@ -using Microsoft.Win32; +using Windows.UI.ViewManagement; namespace Bloxstrap.Extensions { @@ -9,9 +9,9 @@ namespace Bloxstrap.Extensions if (dialogTheme != Theme.Default) return dialogTheme; - using var key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"); - - if (key?.GetValue("AppsUseLightTheme") is int value && value == 0) + var settings = new UISettings(); + var background = settings.GetColorValue(UIColorType.Background); + if (((5 * background.G) + (2 * background.R) + background.B) < (8 * 128)) return Theme.Dark; return Theme.Light;