完成wpf客户端对主题选择的本地存储
This commit is contained in:
@@ -117,7 +117,7 @@ namespace CommonLibrary
|
|||||||
json.Add(nameof(IsNewVersionRunning), new JValue(IsNewVersionRunning));
|
json.Add(nameof(IsNewVersionRunning), new JValue(IsNewVersionRunning));
|
||||||
json.Add(nameof(SystemInfo), new JValue(SystemInfo));
|
json.Add(nameof(SystemInfo), new JValue(SystemInfo));
|
||||||
json.Add(nameof(LoginTime), new JValue(LoginTime));
|
json.Add(nameof(LoginTime), new JValue(LoginTime));
|
||||||
json.Add(nameof(IsThemeDark), new JValue(false));
|
json.Add(nameof(IsThemeDark), new JValue(IsThemeDark));
|
||||||
return json.ToString();
|
return json.ToString();
|
||||||
}
|
}
|
||||||
public override void LoadByString(string content)
|
public override void LoadByString(string content)
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||||
|
<section name="软件系统客户端Wpf.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
|
</sectionGroup>
|
||||||
|
</configSections>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
</startup>
|
</startup>
|
||||||
|
<userSettings>
|
||||||
|
<软件系统客户端Wpf.Properties.Settings>
|
||||||
|
<setting name="设置" serializeAs="String">
|
||||||
|
<value />
|
||||||
|
</setting>
|
||||||
|
</软件系统客户端Wpf.Properties.Settings>
|
||||||
|
</userSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -18,6 +18,7 @@ using CommonLibrary;
|
|||||||
using HslCommunication.BasicFramework;
|
using HslCommunication.BasicFramework;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using ClientsLibrary;
|
using ClientsLibrary;
|
||||||
|
using MaterialDesignThemes.Wpf;
|
||||||
|
|
||||||
namespace 软件系统客户端Wpf
|
namespace 软件系统客户端Wpf
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -164,7 +164,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Width="180" DockPanel.Dock="Left">
|
<Grid Width="180" DockPanel.Dock="Left">
|
||||||
<GroupBox Header="系统信息" Margin="2,5,0,0">
|
<GroupBox Header="系统信息" Margin="0,0,0,0">
|
||||||
<Grid>
|
<Grid>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock>随便放点什么东西</TextBlock>
|
<TextBlock>随便放点什么东西</TextBlock>
|
||||||
@@ -266,7 +266,7 @@
|
|||||||
|
|
||||||
<!--主界面,应该设置成可以放置其他东西-->
|
<!--主界面,应该设置成可以放置其他东西-->
|
||||||
<Grid>
|
<Grid>
|
||||||
<ContentControl Margin="3" x:Name="UserContentControl">
|
<ContentControl Margin="3,0,3,0" x:Name="UserContentControl">
|
||||||
</ContentControl>
|
</ContentControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ using ClientsLibrary;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using 软件系统客户端Wpf.Views;
|
using 软件系统客户端Wpf.Views;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
|
using MaterialDesignThemes.Wpf;
|
||||||
|
|
||||||
namespace 软件系统客户端Wpf
|
namespace 软件系统客户端Wpf
|
||||||
{
|
{
|
||||||
@@ -162,6 +163,9 @@ namespace 软件系统客户端Wpf
|
|||||||
|
|
||||||
//初始化窗口
|
//初始化窗口
|
||||||
MainRenderInitialization();
|
MainRenderInitialization();
|
||||||
|
|
||||||
|
//加载主题
|
||||||
|
new PaletteHelper().SetLightDark(UserClient.JsonSettings.IsThemeDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddStringRenderShow(string str)
|
private void AddStringRenderShow(string str)
|
||||||
|
|||||||
42
软件系统客户端Wpf/Properties/Settings.Designer.cs
generated
42
软件系统客户端Wpf/Properties/Settings.Designer.cs
generated
@@ -1,30 +1,38 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// 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.
|
// 重新生成代码,这些更改将会丢失。
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace 软件系统客户端Wpf.Properties
|
namespace 软件系统客户端Wpf.Properties {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
{
|
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
public static Settings Default
|
public static Settings Default {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return defaultInstance;
|
return defaultInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||||
|
public string 设置 {
|
||||||
|
get {
|
||||||
|
return ((string)(this["设置"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["设置"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="软件系统客户端Wpf.Properties" GeneratedClassName="Settings">
|
||||||
<Profiles>
|
<Profiles />
|
||||||
<Profile Name="(Default)" />
|
<Settings>
|
||||||
</Profiles>
|
<Setting Name="设置" Type="System.String" Scope="User">
|
||||||
<Settings />
|
<Value Profile="(Default)" />
|
||||||
|
</Setting>
|
||||||
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
@@ -18,7 +18,7 @@ namespace 软件系统客户端Wpf.Views
|
|||||||
|
|
||||||
public ICommand ToggleBaseCommand { get; } = new AnotherCommandImplementation(o => ApplyBase((bool)o));
|
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);
|
new PaletteHelper().SetLightDark(isDark);
|
||||||
}
|
}
|
||||||
@@ -27,14 +27,14 @@ namespace 软件系统客户端Wpf.Views
|
|||||||
|
|
||||||
public ICommand ApplyPrimaryCommand { get; } = new AnotherCommandImplementation(o => ApplyPrimary((Swatch)o));
|
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);
|
new PaletteHelper().ReplacePrimaryColor(swatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o));
|
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);
|
new PaletteHelper().ReplaceAccentColor(swatch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
|
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
|
||||||
xmlns:local="clr-namespace:软件系统客户端Wpf.Views"
|
xmlns:local="clr-namespace:软件系统客户端Wpf.Views"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="700" d:DesignWidth="400">
|
d:DesignHeight="700" d:DesignWidth="400" Loaded="UserControl_Loaded">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<Style x:Key="MaterialDesignFloatingHintTextBox" BasedOn="{StaticResource MaterialDesignFloatingHintTextBox}" TargetType="{x:Type TextBox}">
|
<Style x:Key="MaterialDesignFloatingHintTextBox" BasedOn="{StaticResource MaterialDesignFloatingHintTextBox}" TargetType="{x:Type TextBox}">
|
||||||
<Setter Property="FontSize" Value="24" />
|
<Setter Property="FontSize" Value="24" />
|
||||||
@@ -96,7 +96,8 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Orientation="Horizontal" Margin="8">
|
<StackPanel Orientation="Horizontal" Margin="8">
|
||||||
<TextBlock VerticalAlignment="Center">浅色主题</TextBlock>
|
<TextBlock VerticalAlignment="Center">浅色主题</TextBlock>
|
||||||
<ToggleButton Margin="8 0 16 0" Command="{Binding ToggleBaseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}" />
|
<ToggleButton Margin="8 0 16 0" Command="{Binding ToggleBaseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=IsChecked}"
|
||||||
|
x:Name="CheckBox_Theme" Checked="CheckBox_Theme_Checked" Unchecked="CheckBox_Theme_Unchecked"/>
|
||||||
<TextBlock VerticalAlignment="Center">暗色主题</TextBlock>
|
<TextBlock VerticalAlignment="Center">暗色主题</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using MaterialDesignThemes.Wpf;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -24,5 +25,22 @@ namespace 软件系统客户端Wpf.Views
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckBox_Theme_Checked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ClientsLibrary.UserClient.JsonSettings.IsThemeDark = true;
|
||||||
|
ClientsLibrary.UserClient.JsonSettings.SaveToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckBox_Theme_Unchecked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ClientsLibrary.UserClient.JsonSettings.IsThemeDark = false;
|
||||||
|
ClientsLibrary.UserClient.JsonSettings.SaveToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (ClientsLibrary.UserClient.JsonSettings.IsThemeDark) CheckBox_Theme.IsChecked = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user