Centralize WPF theme management

This commit is contained in:
pizzaboxer 2023-01-27 19:35:51 +00:00
parent 000de99c37
commit 4ad11af9ee
8 changed files with 19 additions and 67 deletions

View File

@ -3,6 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Bloxstrap"> xmlns:local="clr-namespace:Bloxstrap">
<Application.Resources> <Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="Themes\ColourfulDarkTheme.xaml" />-->
<ResourceDictionary Source="Dialogs\Menu\Themes\LightTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </Application>

View File

@ -128,7 +128,7 @@ namespace Bloxstrap
string commandLine = ""; string commandLine = "";
#if false//DEBUG #if DEBUG
new Preferences().ShowDialog(); new Preferences().ShowDialog();
#else #else
if (LaunchArgs.Length > 0) if (LaunchArgs.Length > 0)

View File

@ -10,14 +10,6 @@
SizeToContent="WidthAndHeight" SizeToContent="WidthAndHeight"
ResizeMode="NoResize" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="Themes\ColourfulDarkTheme.xaml" />-->
<ResourceDictionary Source="Themes\LightTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid Width="420" Height="260"> <Grid Width="420" Height="260">
<StackPanel Margin="10"> <StackPanel Margin="10">
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Modification Help" VerticalAlignment="Top" FontSize="18" /> <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Modification Help" VerticalAlignment="Top" FontSize="18" />

View File

@ -1,7 +1,5 @@
using System.Windows; using System;
using System.Windows;
using Bloxstrap.Enums;
using System;
namespace Bloxstrap.Dialogs.Menu namespace Bloxstrap.Dialogs.Menu
{ {
@ -13,17 +11,6 @@ namespace Bloxstrap.Dialogs.Menu
public ModHelp() public ModHelp()
{ {
InitializeComponent(); InitializeComponent();
SetTheme();
}
public void SetTheme()
{
string theme = "Light";
if (App.Settings.Theme.GetFinal() == Theme.Dark)
theme = "ColourfulDark";
this.Resources.MergedDictionaries[0] = new ResourceDictionary() { Source = new Uri($"Dialogs/Menu/Themes/{theme}Theme.xaml", UriKind.Relative) };
} }
private void ButtonClose_Click(object sender, EventArgs e) private void ButtonClose_Click(object sender, EventArgs e)

View File

@ -10,14 +10,6 @@
SizeToContent="WidthAndHeight" SizeToContent="WidthAndHeight"
ResizeMode="NoResize" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="Themes\ColourfulDarkTheme.xaml" />-->
<ResourceDictionary Source="Themes\LightTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid Width="480" Height="360"> <Grid Width="480" Height="360">
<TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="Configure Bloxstrap" VerticalAlignment="Top" FontSize="18"/> <TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="Configure Bloxstrap" VerticalAlignment="Top" FontSize="18"/>
<TextBlock HorizontalAlignment="Right" Margin="0,14,10,0" TextWrapping="Wrap" Text="{Binding BloxstrapVersion, Mode=OneTime}" VerticalAlignment="Top" FontSize="12"/> <TextBlock HorizontalAlignment="Right" Margin="0,14,10,0" TextWrapping="Wrap" Text="{Binding BloxstrapVersion, Mode=OneTime}" VerticalAlignment="Top" FontSize="12"/>

View File

@ -1,21 +1,20 @@
using System.ComponentModel; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Interop; using System.Windows.Interop;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Win32; using Microsoft.Win32;
using Bloxstrap.Enums; using Bloxstrap.Enums;
using Bloxstrap.Helpers; using Bloxstrap.Helpers;
using Bloxstrap.Models; using Bloxstrap.Models;
using System.Linq;
namespace Bloxstrap.Dialogs.Menu namespace Bloxstrap.Dialogs.Menu
{ {
@ -56,7 +55,7 @@ namespace Bloxstrap.Dialogs.Menu
if (App.Settings.Theme.GetFinal() == Theme.Dark) if (App.Settings.Theme.GetFinal() == Theme.Dark)
theme = "ColourfulDark"; theme = "ColourfulDark";
this.Resources.MergedDictionaries[0] = new ResourceDictionary() { Source = new Uri($"Dialogs/Menu/Themes/{theme}Theme.xaml", UriKind.Relative) }; Application.Current.Resources.MergedDictionaries[0] = new ResourceDictionary() { Source = new Uri($"Dialogs/Menu/Themes/{theme}Theme.xaml", UriKind.Relative) };
} }
private void ButtonOpenReShadeFolder_Click(object sender, EventArgs e) private void ButtonOpenReShadeFolder_Click(object sender, EventArgs e)
@ -81,11 +80,9 @@ namespace Bloxstrap.Dialogs.Menu
private void ButtonLocationBrowse_Click(object sender, EventArgs e) private void ButtonLocationBrowse_Click(object sender, EventArgs e)
{ {
using (var dialog = new FolderBrowserDialog()) using (var dialog = new System.Windows.Forms.FolderBrowserDialog())
{ {
DialogResult result = dialog.ShowDialog(); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (result == System.Windows.Forms.DialogResult.OK)
ViewModel.InstallLocation = dialog.SelectedPath; ViewModel.InstallLocation = dialog.SelectedPath;
} }
} }

View File

@ -10,14 +10,6 @@
SizeToContent="WidthAndHeight" SizeToContent="WidthAndHeight"
ResizeMode="NoResize" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="Themes\ColourfulDarkTheme.xaml" />-->
<ResourceDictionary Source="Themes\LightTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid Width="420" Height="220"> <Grid Width="420" Height="220">
<StackPanel Margin="10"> <StackPanel Margin="10">
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="ReShade Help" VerticalAlignment="Top" FontSize="18" /> <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="ReShade Help" VerticalAlignment="Top" FontSize="18" />

View File

@ -1,7 +1,5 @@
using System.Windows; using System;
using System.Windows;
using Bloxstrap.Enums;
using System;
namespace Bloxstrap.Dialogs.Menu namespace Bloxstrap.Dialogs.Menu
{ {
@ -13,17 +11,6 @@ namespace Bloxstrap.Dialogs.Menu
public ReShadeHelp() public ReShadeHelp()
{ {
InitializeComponent(); InitializeComponent();
SetTheme();
}
public void SetTheme()
{
string theme = "Light";
if (App.Settings.Theme.GetFinal() == Theme.Dark)
theme = "ColourfulDark";
this.Resources.MergedDictionaries[0] = new ResourceDictionary() { Source = new Uri($"Dialogs/Menu/Themes/{theme}Theme.xaml", UriKind.Relative) };
} }
private void ButtonClose_Click(object sender, EventArgs e) private void ButtonClose_Click(object sender, EventArgs e)