Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Bloxstrap/Extensions/ThemeEx.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Win32;
using Windows.UI.ViewManagement;

namespace Bloxstrap.Extensions
{
Expand All @@ -9,9 +9,9 @@ public static Theme GetFinal(this Theme dialogTheme)
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;
Expand Down
14 changes: 13 additions & 1 deletion Bloxstrap/UI/Elements/Base/WpfUiWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@
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);
Expand All @@ -37,5 +41,13 @@ protected override void OnSourceInitialized(EventArgs e)

base.OnSourceInitialized(e);
}

private async void ColorValuesChanged(UISettings sender, object args)
{
await Dispatcher.InvokeAsync(() =>
{
ApplyTheme();
});
}
}
}
1 change: 1 addition & 0 deletions Bloxstrap/UI/Elements/ContextMenu/ServerHistory.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Height="420"
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
ExtendsContentIntoTitleBar="True"
WindowBackdropType="Mica"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
Expand Down
1 change: 1 addition & 0 deletions Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
ResizeMode="NoResize"
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
ExtendsContentIntoTitleBar="True"
WindowBackdropType="Mica"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
Expand Down
1 change: 1 addition & 0 deletions Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
1 change: 1 addition & 0 deletions Bloxstrap/UI/Elements/Dialogs/ConnectivityDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
SizeToContent="Height"
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
ExtendsContentIntoTitleBar="True"
WindowBackdropType="Mica"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
Expand Down
1 change: 1 addition & 0 deletions Bloxstrap/UI/Elements/Dialogs/FluentMessageBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
ResizeMode="NoResize"
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
ExtendsContentIntoTitleBar="True"
WindowBackdropType="Mica"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
Expand Down
1 change: 1 addition & 0 deletions Bloxstrap/UI/Elements/Dialogs/LanguageSelectorDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ResizeMode="NoResize"
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
ExtendsContentIntoTitleBar="True"
WindowBackdropType="Mica"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
Expand Down
1 change: 1 addition & 0 deletions Bloxstrap/UI/Elements/Dialogs/LaunchMenuDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ResizeMode="NoResize"
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
ExtendsContentIntoTitleBar="True"
WindowBackdropType="Mica"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
Expand Down
1 change: 1 addition & 0 deletions Bloxstrap/UI/Elements/Dialogs/UninstallerDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ResizeMode="NoResize"
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
ExtendsContentIntoTitleBar="True"
WindowBackdropType="Mica"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
Expand Down