Match system theme

Automatically match Bloxstrap's theme to progress light/dark mode based on system default app theme
This commit is contained in:
rjindael 2022-09-04 14:54:14 -07:00
parent c71c2b1f5f
commit 54888b4e30
2 changed files with 18 additions and 1 deletions

View File

@ -20,6 +20,7 @@ namespace Bloxstrap.Dialogs
{ "Legacy (2011 - 2014)", BootstrapperStyle.LegacyDialog2011 },
{ "Progress (~2014)", BootstrapperStyle.ProgressDialog },
{ "Progress (Dark)", BootstrapperStyle.ProgressDialogDark },
{ "Match system theme", BootstrapperStyle.SystemTheme }
};
private static readonly IReadOnlyDictionary<string, BootstrapperIcon> SelectableIcons = new Dictionary<string, BootstrapperIcon>()

View File

@ -1,4 +1,5 @@
using Bloxstrap.Dialogs.BootstrapperStyles;
using Microsoft.Win32;
using Bloxstrap.Dialogs.BootstrapperStyles;
namespace Bloxstrap.Enums
{
@ -9,6 +10,7 @@ namespace Bloxstrap.Enums
LegacyDialog2011,
ProgressDialog,
ProgressDialogDark,
SystemTheme,
}
public static class BootstrapperStyleEx
@ -39,6 +41,20 @@ namespace Bloxstrap.Enums
case BootstrapperStyle.ProgressDialogDark:
dialog = new ProgressDialogDark(bootstrapper);
break;
case BootstrapperStyle.SystemTheme:
bool darkMode = false;
using (RegistryKey? key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"))
{
var value = key?.GetValue("AppsUseLightTheme");
if (value != null)
{
darkMode = (int)value <= 0;
}
}
dialog = !darkMode ? new ProgressDialog(bootstrapper) : new ProgressDialogDark(bootstrapper);
break;
}
if (bootstrapper is null)