diff --git a/app/CustomControls.cs b/app/CustomControls.cs index a0b07b85..34a68868 100644 --- a/app/CustomControls.cs +++ b/app/CustomControls.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using Microsoft.Win32; +using System.ComponentModel; using System.Drawing.Drawing2D; using System.Runtime.InteropServices; @@ -20,9 +21,18 @@ namespace CustomControls public bool darkTheme = false; + private static bool IsDarkTheme() + { + using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"); + var registryValueObject = key?.GetValue("AppsUseLightTheme"); + + if (registryValueObject == null) return false; + return (int)registryValueObject <= 0; + } + public void InitTheme(bool setDPI = true) { - bool newDarkTheme = CheckSystemDarkModeStatus(); + bool newDarkTheme = IsDarkTheme(); bool changed = (darkTheme != newDarkTheme); darkTheme = newDarkTheme; diff --git a/app/Program.cs b/app/Program.cs index 5d7d2436..e729a9aa 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -92,6 +92,7 @@ namespace GHelper { case UserPreferenceCategory.General: Debug.WriteLine("Theme Changed"); + Thread.Sleep(100); settingsForm.InitTheme(false); if (settingsForm.fans is not null && settingsForm.fans.Text != "")