mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-06-23 23:00:23 -07:00
Compare commits
4 Commits
e7fc640664
...
a5d4b1e85f
Author | SHA1 | Date | |
---|---|---|---|
|
a5d4b1e85f | ||
|
f23d2bce88 | ||
|
e983814176 | ||
|
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;
|
||||
|
@ -4,23 +4,27 @@ using Wpf.Ui.Appearance;
|
||||
using Wpf.Ui.Controls;
|
||||
using Wpf.Ui.Mvvm.Contracts;
|
||||
using Wpf.Ui.Mvvm.Services;
|
||||
using Windows.UI.ViewManagement;
|
||||
|
||||
namespace Bloxstrap.UI.Elements.Base
|
||||
{
|
||||
public abstract class WpfUiWindow : UiWindow
|
||||
{
|
||||
private readonly IThemeService _themeService = new ThemeService();
|
||||
private UISettings _settings;
|
||||
|
||||
public WpfUiWindow()
|
||||
{
|
||||
ApplyTheme();
|
||||
_settings = new UISettings();
|
||||
_settings.ColorValuesChanged += ColorValuesChanged;
|
||||
}
|
||||
|
||||
public void ApplyTheme()
|
||||
{
|
||||
_themeService.SetTheme(App.Settings.Prop.Theme.GetFinal() == Enums.Theme.Dark ? ThemeType.Dark : ThemeType.Light);
|
||||
_themeService.SetSystemAccent();
|
||||
|
||||
|
||||
#if QA_BUILD
|
||||
this.BorderBrush = System.Windows.Media.Brushes.Red;
|
||||
this.BorderThickness = new Thickness(4);
|
||||
@ -37,5 +41,13 @@ namespace Bloxstrap.UI.Elements.Base
|
||||
|
||||
base.OnSourceInitialized(e);
|
||||
}
|
||||
|
||||
private async void ColorValuesChanged(UISettings sender, object args)
|
||||
{
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
ApplyTheme();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
Height="420"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -18,6 +18,7 @@
|
||||
ResizeMode="NoResize"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -16,6 +16,7 @@
|
||||
ResizeMode="NoResize"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<ui:UiWindow.Resources>
|
||||
<converters:RangeConverter x:Key="ValidationConverter" From="0" />
|
||||
|
@ -15,6 +15,7 @@
|
||||
Title="{x:Static resources:Strings.Dialog_Connectivity_Title}"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -16,6 +16,7 @@
|
||||
SizeToContent="Height"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -18,6 +18,7 @@
|
||||
ResizeMode="NoResize"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -16,6 +16,7 @@
|
||||
ResizeMode="NoResize"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -17,6 +17,7 @@
|
||||
ResizeMode="NoResize"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -19,6 +19,7 @@
|
||||
ResizeMode="NoResize"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
Loading…
Reference in New Issue
Block a user