mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-21 18:35:15 -04:00
Auto-detect dark mode preference in GUI
This commit is contained in:
parent
f80a5fe644
commit
afb4bc67ae
1 changed files with 20 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue