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:local="clr-namespace:Bloxstrap">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="Themes\ColourfulDarkTheme.xaml" />-->
<ResourceDictionary Source="Dialogs\Menu\Themes\LightTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

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

View File

@ -10,14 +10,6 @@
SizeToContent="WidthAndHeight"
ResizeMode="NoResize"
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">
<StackPanel Margin="10">
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Modification Help" VerticalAlignment="Top" FontSize="18" />

View File

@ -1,7 +1,5 @@
using System.Windows;
using Bloxstrap.Enums;
using System;
using System;
using System.Windows;
namespace Bloxstrap.Dialogs.Menu
{
@ -13,17 +11,6 @@ namespace Bloxstrap.Dialogs.Menu
public ModHelp()
{
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)

View File

@ -10,14 +10,6 @@
SizeToContent="WidthAndHeight"
ResizeMode="NoResize"
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">
<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"/>

View File

@ -1,21 +1,20 @@
using System.ComponentModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Win32;
using Bloxstrap.Enums;
using Bloxstrap.Helpers;
using Bloxstrap.Models;
using System.Linq;
namespace Bloxstrap.Dialogs.Menu
{
@ -56,7 +55,7 @@ namespace Bloxstrap.Dialogs.Menu
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) };
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)
@ -81,11 +80,9 @@ namespace Bloxstrap.Dialogs.Menu
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 (result == System.Windows.Forms.DialogResult.OK)
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
ViewModel.InstallLocation = dialog.SelectedPath;
}
}

View File

@ -10,14 +10,6 @@
SizeToContent="WidthAndHeight"
ResizeMode="NoResize"
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">
<StackPanel Margin="10">
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="ReShade Help" VerticalAlignment="Top" FontSize="18" />

View File

@ -1,7 +1,5 @@
using System.Windows;
using Bloxstrap.Enums;
using System;
using System;
using System.Windows;
namespace Bloxstrap.Dialogs.Menu
{
@ -13,17 +11,6 @@ namespace Bloxstrap.Dialogs.Menu
public ReShadeHelp()
{
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)