Fix theme not applying to notification area menu

This commit is contained in:
pizzaboxer 2023-08-26 20:52:56 +01:00
parent 0cca373833
commit 197429dbf9
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
8 changed files with 46 additions and 25 deletions

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wpf.Ui.Appearance;
using Wpf.Ui.Controls;
using Wpf.Ui.Mvvm.Contracts;
using Wpf.Ui.Mvvm.Services;
namespace Bloxstrap.UI.Elements.Base
{
public class WpfUiWindow : UiWindow
{
private readonly IThemeService _themeService = new ThemeService();
public void ApplyTheme()
{
_themeService.SetTheme(App.Settings.Prop.Theme.GetFinal() == Enums.Theme.Dark ? ThemeType.Dark : ThemeType.Light);
_themeService.SetSystemAccent();
}
}
}

View File

@ -1,9 +1,10 @@
<ui:UiWindow x:Class="Bloxstrap.UI.Elements.Bootstrapper.FluentDialog"
<base:WpfUiWindow x:Class="Bloxstrap.UI.Elements.Bootstrapper.FluentDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:base="clr-namespace:Bloxstrap.UI.Elements.Base"
mc:Ignorable="d"
Width="420"
MinHeight="0"
@ -46,4 +47,4 @@
<Button Margin="0" Content="Cancel" Width="120" HorizontalAlignment="Right" IsEnabled="{Binding CancelEnabled, Mode=OneWay}" Command="{Binding CancelInstallCommand}" />
</Border>
</Grid>
</ui:UiWindow>
</base:WpfUiWindow>

View File

@ -15,8 +15,6 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
/// </summary>
public partial class FluentDialog : IBootstrapperDialog
{
private readonly IThemeService _themeService = new ThemeService();
private readonly BootstrapperDialogViewModel _viewModel;
public Bloxstrap.Bootstrapper? Bootstrapper { get; set; }
@ -69,15 +67,13 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
public FluentDialog()
{
InitializeComponent();
ApplyTheme();
_viewModel = new FluentDialogViewModel(this);
DataContext = _viewModel;
Title = App.Settings.Prop.BootstrapperTitle;
Icon = App.Settings.Prop.BootstrapperIcon.GetIcon().GetImageSource();
_themeService.SetTheme(App.Settings.Prop.Theme.GetFinal() == Enums.Theme.Dark ? ThemeType.Dark : ThemeType.Light);
_themeService.SetSystemAccent();
InitializeComponent();
}
private void UiWindow_Closing(object sender, CancelEventArgs e)

View File

@ -1,10 +1,11 @@
<ui:UiWindow x:Class="Bloxstrap.UI.Elements.ContextMenu.MenuContainer"
<base:WpfUiWindow x:Class="Bloxstrap.UI.Elements.ContextMenu.MenuContainer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.ContextMenu"
xmlns:base="clr-namespace:Bloxstrap.UI.Elements.Base"
mc:Ignorable="d"
Title="ContextMenuContainer"
MinWidth="0"
@ -62,4 +63,4 @@
<MenuItem x:Name="LogTracerMenuItem" Header="Open log tracer" Visibility="Collapsed" Click="LogTracerMenuItem_Click" />
</ContextMenu>
</ui:UiWindow.ContextMenu>
</ui:UiWindow>
</base:WpfUiWindow>

View File

@ -2,6 +2,10 @@
using System.Windows.Controls;
using System.Windows.Interop;
using Wpf.Ui.Appearance;
using Wpf.Ui.Mvvm.Contracts;
using Wpf.Ui.Mvvm.Services;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.UI.WindowsAndMessaging;
@ -26,7 +30,8 @@ namespace Bloxstrap.UI.Elements.ContextMenu
public MenuContainer(ActivityWatcher? activityWatcher, DiscordRichPresence? richPresenceHandler)
{
InitializeComponent();
ApplyTheme();
_activityWatcher = activityWatcher;
_richPresenceHandler = richPresenceHandler;

View File

@ -1,4 +1,4 @@
<ui:UiWindow x:Class="Bloxstrap.UI.Elements.Menu.MainWindow"
<base:WpfUiWindow x:Class="Bloxstrap.UI.Elements.Menu.MainWindow"
x:Name="ConfigurationWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -6,6 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:Bloxstrap.UI.Elements.Menu.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:base="clr-namespace:Bloxstrap.UI.Elements.Base"
mc:Ignorable="d"
Title="Bloxstrap Menu"
MinWidth="960"
@ -79,4 +80,4 @@
</StatusBarItem>
</StatusBar>
</Grid>
</ui:UiWindow>
</base:WpfUiWindow>

View File

@ -14,21 +14,14 @@ namespace Bloxstrap.UI.Elements.Menu
/// </summary>
public partial class MainWindow : INavigationWindow
{
private readonly IThemeService _themeService = new ThemeService();
public MainWindow()
{
InitializeComponent();
ApplyTheme();
App.Logger.WriteLine("MainWindow::MainWindow", "Initializing menu");
DataContext = new MainWindowViewModel(this);
SetTheme();
InitializeComponent();
}
public void SetTheme()
{
_themeService.SetTheme(App.Settings.Prop.Theme.GetFinal() == Enums.Theme.Dark ? ThemeType.Dark : ThemeType.Light);
_themeService.SetSystemAccent();
}
public void OpenWiki(object? sender, EventArgs e) => Utilities.ShellExecute($"https://github.com/{App.ProjectRepository}/wiki");

View File

@ -63,7 +63,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
set
{
App.Settings.Prop.Theme = Themes[value];
((MainWindow)Window.GetWindow(_page)!).SetTheme();
((MainWindow)Window.GetWindow(_page)!).ApplyTheme();
}
}