From 1d56d7959af58e33ab6cfdf324dc469e4976dce2 Mon Sep 17 00:00:00 2001 From: Duka Istvan Date: Mon, 5 Sep 2022 21:29:01 +0300 Subject: [PATCH] Updated theme manager --- CameraControl.Core/Classes/WindowsManager.cs | 8 +++++++- CameraControl/MainWindow.xaml | 6 +++--- CameraControl/windows/SettingsWnd.xaml | 6 +++--- CameraControl/windows/SettingsWnd.xaml.cs | 1 + CameraControl/windows/Welcome.xaml | 12 ++++++++++-- Canon.Eos.Framework/Canon.Eos.Framework.csproj | 5 +++++ 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/CameraControl.Core/Classes/WindowsManager.cs b/CameraControl.Core/Classes/WindowsManager.cs index af2cb795a..b5a01b4d7 100644 --- a/CameraControl.Core/Classes/WindowsManager.cs +++ b/CameraControl.Core/Classes/WindowsManager.cs @@ -98,8 +98,14 @@ public void ApplyTheme() var paletteHelper = new PaletteHelper(); ITheme theme = paletteHelper.GetTheme(); IBaseTheme baseTheme = ServiceProvider.Settings.CurrentThemeNameNew.StartsWith("Dark") ? new MaterialDesignDarkTheme() : (IBaseTheme)new MaterialDesignLightTheme(); - theme.SetPrimaryColor((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(ServiceProvider.Settings.CurrentThemeNameNew.Split('\\')[1])); theme.SetBaseTheme(baseTheme); + foreach (var item in new SwatchesProvider().Swatches) + { + if (item.Name == ServiceProvider.Settings.CurrentThemeNameNew.Split('\\')[1]) + theme.SetPrimaryColor(item.PrimaryHues[item.PrimaryHues.Count / 2].Color); + } +// theme.SetPrimaryColor((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(ServiceProvider.Settings.CurrentThemeNameNew.Split('\\')[1])); + paletteHelper.SetTheme(theme); } diff --git a/CameraControl/MainWindow.xaml b/CameraControl/MainWindow.xaml index e9d84eb95..deb4ca1e4 100644 --- a/CameraControl/MainWindow.xaml +++ b/CameraControl/MainWindow.xaml @@ -1,8 +1,8 @@ - - + diff --git a/CameraControl/windows/SettingsWnd.xaml b/CameraControl/windows/SettingsWnd.xaml index 4af39f064..27ce0c662 100644 --- a/CameraControl/windows/SettingsWnd.xaml +++ b/CameraControl/windows/SettingsWnd.xaml @@ -33,12 +33,12 @@ - - + + - + diff --git a/CameraControl/windows/SettingsWnd.xaml.cs b/CameraControl/windows/SettingsWnd.xaml.cs index 9bbbd7ad1..93a6bddcb 100644 --- a/CameraControl/windows/SettingsWnd.xaml.cs +++ b/CameraControl/windows/SettingsWnd.xaml.cs @@ -97,6 +97,7 @@ private void button1_Click(object sender, RoutedEventArgs e) { ServiceProvider.Settings.EndEdit(); ServiceProvider.Settings.Save(); + ServiceProvider.WindowsManager.ApplyTheme(); this.Close(); } diff --git a/CameraControl/windows/Welcome.xaml b/CameraControl/windows/Welcome.xaml index 1f8a4c919..794d40e69 100644 --- a/CameraControl/windows/Welcome.xaml +++ b/CameraControl/windows/Welcome.xaml @@ -2,8 +2,16 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls" - xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" - Title="digiCamControl by Duka Istvan" Height="380" Width="460" WindowStartupLocation="CenterScreen" ShowInTaskbar="False" Topmost="True" WindowStyle="SingleBorderWindow" ResizeMode="NoResize" > + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + Title="digiCamControl by Duka Istvan" Height="380" Width="460" WindowStartupLocation="CenterScreen" ShowInTaskbar="False" Topmost="True" WindowStyle="SingleBorderWindow" ResizeMode="NoResize" + TextElement.Foreground="{DynamicResource MaterialDesignBody}" + TextElement.FontWeight="Regular" + TextElement.FontSize="13" + TextOptions.TextFormattingMode="Ideal" + TextOptions.TextRenderingMode="Auto" + Background="{DynamicResource MaterialDesignPaper}" + FontFamily="{DynamicResource MaterialDesignFont}" + >