mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Auto theme change
This commit is contained in:
@@ -27,6 +27,7 @@ namespace GHelper
|
||||
private static IntPtr ds;
|
||||
|
||||
private static long lastAuto;
|
||||
private static long lastTheme;
|
||||
|
||||
// The main entry point for the application
|
||||
public static void Main()
|
||||
@@ -48,6 +49,8 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
SystemEvents.UserPreferenceChanged += OnUserPreferenceChanged;
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
|
||||
ds = settingsForm.Handle;
|
||||
@@ -77,6 +80,30 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void OnUserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
|
||||
{
|
||||
|
||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastTheme) < 2000) return;
|
||||
lastTheme = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
|
||||
switch (e.Category)
|
||||
{
|
||||
case UserPreferenceCategory.General:
|
||||
Debug.WriteLine("Theme Changed");
|
||||
settingsForm.InitTheme();
|
||||
|
||||
if (settingsForm.fans is not null && settingsForm.fans.Text != "")
|
||||
settingsForm.fans.InitTheme();
|
||||
|
||||
if (settingsForm.keyb is not null && settingsForm.keyb.Text != "")
|
||||
settingsForm.keyb.InitTheme();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static async void CheckForUpdates()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user