客户端的颜色配置存储在了本地,客户端下次运行将直接恢复之前的颜色设置。

This commit is contained in:
dathlin
2017-07-17 14:50:55 +08:00
parent d612709e65
commit f6ded5b1ef
3 changed files with 21 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ using HslCommunication.BasicFramework;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using ClientsLibrary; using ClientsLibrary;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using System.IO;
namespace Wpf namespace Wpf
{ {
@@ -320,6 +321,18 @@ namespace 软件系统客户端Wpf
if (UserClient.JsonSettings.Password != "") LoginButton.Focus(); if (UserClient.JsonSettings.Password != "") LoginButton.Focus();
else if (UserClient.JsonSettings.LoginName != "") PasswordBox.Focus(); else if (UserClient.JsonSettings.LoginName != "") PasswordBox.Focus();
else NameTextBox.Focus(); else NameTextBox.Focus();
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Palette.txt"))
{
using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\Palette.txt", Encoding.UTF8))
{
string temp = sr.ReadToEnd();
MaterialDesignThemes.Wpf.Palette obj = JObject.Parse(temp).ToObject<MaterialDesignThemes.Wpf.Palette>();
new PaletteHelper().ReplacePalette(obj);
}
}
} }
private void NameTextBox_KeyDown(object sender, KeyEventArgs e) private void NameTextBox_KeyDown(object sender, KeyEventArgs e)

View File

@@ -7,6 +7,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@@ -83,6 +84,12 @@ namespace 软件系统客户端Wpf
//通知服务器退出网络服务 //通知服务器退出网络服务
net_socket_client.ClientClose(); net_socket_client.ClientClose();
//保存当前的颜色选择
var p = new PaletteHelper().QueryPalette();
using (StreamWriter sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + @"\Palette.txt", false, Encoding.UTF8))
{
sw.Write(JObject.FromObject(p).ToString());
}
//等待一秒退出 //等待一秒退出
using (FormWaitInfomation fwm = new FormWaitInfomation("正在退出程序...", 1000)) using (FormWaitInfomation fwm = new FormWaitInfomation("正在退出程序...", 1000))
{ {

View File

@@ -82,7 +82,7 @@
</DataTemplate> </DataTemplate>
</UserControl.Resources> </UserControl.Resources>
<DockPanel> <DockPanel>
<wpf:Card DockPanel.Dock="Top" Margin="2"> <wpf:Card DockPanel.Dock="Top" Margin="2,0,2,0">
<DockPanel> <DockPanel>
<local:Palette DockPanel.Dock="Left" Width="200" /> <local:Palette DockPanel.Dock="Left" Width="200" />
<TextBlock Margin="16" TextWrapping="Wrap" VerticalAlignment="Center">这是你当前的主题配色可以在app.xaml中进行配置和初始化 <TextBlock Margin="16" TextWrapping="Wrap" VerticalAlignment="Center">这是你当前的主题配色可以在app.xaml中进行配置和初始化