Auto-detect dark mode preference in GUI

pull/825/head
Oleksii Holub 3 years ago
parent f80a5fe644
commit afb4bc67ae

@ -1,13 +1,14 @@
using DiscordChatExporter.Core.Exporting; using DiscordChatExporter.Core.Exporting;
using Microsoft.Win32;
using Tyrrrz.Settings; using Tyrrrz.Settings;
namespace DiscordChatExporter.Gui.Services; namespace DiscordChatExporter.Gui.Services;
public class SettingsService : SettingsManager public partial class SettingsService : SettingsManager
{ {
public bool IsAutoUpdateEnabled { get; set; } = true; public bool IsAutoUpdateEnabled { get; set; } = true;
public bool IsDarkModeEnabled { get; set; } public bool IsDarkModeEnabled { get; set; } = IsDarkModeEnabledByDefault();
public bool IsTokenPersisted { get; set; } = true; public bool IsTokenPersisted { get; set; } = true;
@ -35,4 +36,21 @@ public class SettingsService : SettingsManager
} }
public bool ShouldSerializeLastToken() => IsTokenPersisted; public bool ShouldSerializeLastToken() => IsTokenPersisted;
}
public partial class SettingsService
{
private static bool IsDarkModeEnabledByDefault()
{
try
{
return Registry.CurrentUser.OpenSubKey(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", false
)?.GetValue("AppsUseLightTheme") is 0;
}
catch
{
return false;
}
}
} }
Loading…
Cancel
Save