From 988c9e11dd89773e972679d6ab33e8e44358e481 Mon Sep 17 00:00:00 2001 From: seerge Date: Fri, 7 Apr 2023 13:37:00 +0200 Subject: [PATCH] Theme change fix --- app/CustomControls.cs | 2 +- app/Program.cs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/CustomControls.cs b/app/CustomControls.cs index 555c489d..211a63c4 100644 --- a/app/CustomControls.cs +++ b/app/CustomControls.cs @@ -28,7 +28,7 @@ namespace CustomControls [DllImport("DwmApi")] //System.Runtime.InteropServices private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, int[] attrValue, int attrSize); - public bool darkTheme; + public bool darkTheme = false; public static void InitColors(bool darkTheme) { diff --git a/app/Program.cs b/app/Program.cs index 483d5717..b80e584c 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -100,14 +100,16 @@ namespace GHelper { if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastTheme) < 2000) return; - lastTheme = DateTimeOffset.Now.ToUnixTimeMilliseconds(); switch (e.Category) { case UserPreferenceCategory.General: - Debug.WriteLine("Theme Changed"); - Thread.Sleep(1000); - settingsForm.InitTheme(); + bool changed = settingsForm.InitTheme(); + if (changed) + { + Debug.WriteLine("Theme Changed"); + lastTheme = DateTimeOffset.Now.ToUnixTimeMilliseconds(); + } if (settingsForm.fans is not null && settingsForm.fans.Text != "") settingsForm.fans.InitTheme();