Theme change fix

This commit is contained in:
seerge
2023-04-07 13:37:00 +02:00
parent 13ec0f8911
commit 988c9e11dd
2 changed files with 7 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ namespace CustomControls
[DllImport("DwmApi")] //System.Runtime.InteropServices [DllImport("DwmApi")] //System.Runtime.InteropServices
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, int[] attrValue, int attrSize); 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) public static void InitColors(bool darkTheme)
{ {

View File

@@ -100,14 +100,16 @@ namespace GHelper
{ {
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastTheme) < 2000) return; if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastTheme) < 2000) return;
lastTheme = DateTimeOffset.Now.ToUnixTimeMilliseconds();
switch (e.Category) switch (e.Category)
{ {
case UserPreferenceCategory.General: case UserPreferenceCategory.General:
Debug.WriteLine("Theme Changed"); bool changed = settingsForm.InitTheme();
Thread.Sleep(1000); if (changed)
settingsForm.InitTheme(); {
Debug.WriteLine("Theme Changed");
lastTheme = DateTimeOffset.Now.ToUnixTimeMilliseconds();
}
if (settingsForm.fans is not null && settingsForm.fans.Text != "") if (settingsForm.fans is not null && settingsForm.fans.Text != "")
settingsForm.fans.InitTheme(); settingsForm.fans.InitTheme();