From c27ed9288a749d80e91ebb77a51fccad2e01602f Mon Sep 17 00:00:00 2001 From: dathlin Date: Mon, 17 Jul 2017 10:41:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90wpf=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E5=AF=B9=E4=B8=BB=E9=A2=98=E9=80=89=E6=8B=A9=E7=9A=84?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CommonLibrary/BasicSupport/SoftSettings.cs | 2 +- 软件系统客户端Wpf/App.config | 12 ++++++ 软件系统客户端Wpf/LoginWindow.xaml.cs | 1 + 软件系统客户端Wpf/MainWindow.xaml | 4 +- 软件系统客户端Wpf/MainWindow.xaml.cs | 4 ++ .../Properties/Settings.Designer.cs | 42 +++++++++++-------- .../Properties/Settings.settings | 12 +++--- .../Views/PaletteSelectorViewModel.cs | 6 +-- .../Views/UserPaletteSelector.xaml | 5 ++- .../Views/UserPaletteSelector.xaml.cs | 20 ++++++++- 10 files changed, 77 insertions(+), 31 deletions(-) diff --git a/CommonLibrary/BasicSupport/SoftSettings.cs b/CommonLibrary/BasicSupport/SoftSettings.cs index 9dd8843..38f06f7 100644 --- a/CommonLibrary/BasicSupport/SoftSettings.cs +++ b/CommonLibrary/BasicSupport/SoftSettings.cs @@ -117,7 +117,7 @@ namespace CommonLibrary json.Add(nameof(IsNewVersionRunning), new JValue(IsNewVersionRunning)); json.Add(nameof(SystemInfo), new JValue(SystemInfo)); json.Add(nameof(LoginTime), new JValue(LoginTime)); - json.Add(nameof(IsThemeDark), new JValue(false)); + json.Add(nameof(IsThemeDark), new JValue(IsThemeDark)); return json.ToString(); } public override void LoadByString(string content) diff --git a/软件系统客户端Wpf/App.config b/软件系统客户端Wpf/App.config index 8e15646..8553874 100644 --- a/软件系统客户端Wpf/App.config +++ b/软件系统客户端Wpf/App.config @@ -1,6 +1,18 @@  + + +
+ + + + <软件系统客户端Wpf.Properties.Settings> + + + + + \ No newline at end of file diff --git a/软件系统客户端Wpf/LoginWindow.xaml.cs b/软件系统客户端Wpf/LoginWindow.xaml.cs index f7bc6bb..7be5637 100644 --- a/软件系统客户端Wpf/LoginWindow.xaml.cs +++ b/软件系统客户端Wpf/LoginWindow.xaml.cs @@ -18,6 +18,7 @@ using CommonLibrary; using HslCommunication.BasicFramework; using Newtonsoft.Json.Linq; using ClientsLibrary; +using MaterialDesignThemes.Wpf; namespace 软件系统客户端Wpf { diff --git a/软件系统客户端Wpf/MainWindow.xaml b/软件系统客户端Wpf/MainWindow.xaml index 41ba208..f8cdbf0 100644 --- a/软件系统客户端Wpf/MainWindow.xaml +++ b/软件系统客户端Wpf/MainWindow.xaml @@ -164,7 +164,7 @@ - + 随便放点什么东西 @@ -266,7 +266,7 @@ - + diff --git a/软件系统客户端Wpf/MainWindow.xaml.cs b/软件系统客户端Wpf/MainWindow.xaml.cs index 833c744..fcb8f04 100644 --- a/软件系统客户端Wpf/MainWindow.xaml.cs +++ b/软件系统客户端Wpf/MainWindow.xaml.cs @@ -21,6 +21,7 @@ using ClientsLibrary; using System.Threading; using 软件系统客户端Wpf.Views; using System.Windows.Media.Animation; +using MaterialDesignThemes.Wpf; namespace 软件系统客户端Wpf { @@ -162,6 +163,9 @@ namespace 软件系统客户端Wpf //初始化窗口 MainRenderInitialization(); + + //加载主题 + new PaletteHelper().SetLightDark(UserClient.JsonSettings.IsThemeDark); } private void AddStringRenderShow(string str) diff --git a/软件系统客户端Wpf/Properties/Settings.Designer.cs b/软件系统客户端Wpf/Properties/Settings.Designer.cs index 831b858..bfdb268 100644 --- a/软件系统客户端Wpf/Properties/Settings.Designer.cs +++ b/软件系统客户端Wpf/Properties/Settings.Designer.cs @@ -1,30 +1,38 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ -namespace 软件系统客户端Wpf.Properties -{ - - +namespace 软件系统客户端Wpf.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string 设置 { + get { + return ((string)(this["设置"])); + } + set { + this["设置"] = value; + } + } } } diff --git a/软件系统客户端Wpf/Properties/Settings.settings b/软件系统客户端Wpf/Properties/Settings.settings index 033d7a5..f2cd73e 100644 --- a/软件系统客户端Wpf/Properties/Settings.settings +++ b/软件系统客户端Wpf/Properties/Settings.settings @@ -1,7 +1,9 @@  - - - - - + + + + + + + \ No newline at end of file diff --git a/软件系统客户端Wpf/Views/PaletteSelectorViewModel.cs b/软件系统客户端Wpf/Views/PaletteSelectorViewModel.cs index 7d6fdc8..1e5d8e7 100644 --- a/软件系统客户端Wpf/Views/PaletteSelectorViewModel.cs +++ b/软件系统客户端Wpf/Views/PaletteSelectorViewModel.cs @@ -18,7 +18,7 @@ namespace 软件系统客户端Wpf.Views public ICommand ToggleBaseCommand { get; } = new AnotherCommandImplementation(o => ApplyBase((bool)o)); - private static void ApplyBase(bool isDark) + public static void ApplyBase(bool isDark) { new PaletteHelper().SetLightDark(isDark); } @@ -27,14 +27,14 @@ namespace 软件系统客户端Wpf.Views public ICommand ApplyPrimaryCommand { get; } = new AnotherCommandImplementation(o => ApplyPrimary((Swatch)o)); - private static void ApplyPrimary(Swatch swatch) + public static void ApplyPrimary(Swatch swatch) { new PaletteHelper().ReplacePrimaryColor(swatch); } public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o)); - private static void ApplyAccent(Swatch swatch) + public static void ApplyAccent(Swatch swatch) { new PaletteHelper().ReplaceAccentColor(swatch); } diff --git a/软件系统客户端Wpf/Views/UserPaletteSelector.xaml b/软件系统客户端Wpf/Views/UserPaletteSelector.xaml index 1302f79..9caa258 100644 --- a/软件系统客户端Wpf/Views/UserPaletteSelector.xaml +++ b/软件系统客户端Wpf/Views/UserPaletteSelector.xaml @@ -7,7 +7,7 @@ xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf" xmlns:local="clr-namespace:软件系统客户端Wpf.Views" mc:Ignorable="d" - d:DesignHeight="700" d:DesignWidth="400"> + d:DesignHeight="700" d:DesignWidth="400" Loaded="UserControl_Loaded">