mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 18:11:27 -07:00
Match system theme
Automatically match Bloxstrap's theme to progress light/dark mode based on system default app theme
This commit is contained in:
parent
c71c2b1f5f
commit
54888b4e30
@ -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>()
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user