mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Use WinRT to get dark theme
This commit is contained in:
parent
5d1aa50753
commit
4795bf8b66
@ -1,4 +1,4 @@
|
||||
using Microsoft.Win32;
|
||||
using Windows.UI.ViewManagement;
|
||||
|
||||
namespace Bloxstrap.Extensions
|
||||
{
|
||||
@ -9,9 +9,9 @@ namespace Bloxstrap.Extensions
|
||||
if (dialogTheme != Theme.Default)
|
||||
return dialogTheme;
|
||||
|
||||
using var key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize");
|
||||
|
||||
if (key?.GetValue("AppsUseLightTheme") is int value && value == 0)
|
||||
var settings = new UISettings();
|
||||
var background = settings.GetColorValue(UIColorType.Background);
|
||||
if (((5 * background.G) + (2 * background.R) + background.B) < (8 * 128))
|
||||
return Theme.Dark;
|
||||
|
||||
return Theme.Light;
|
||||
|
Loading…
Reference in New Issue
Block a user