Skip to content

Commit f6ded5b

Browse files
committed
客户端的颜色配置存储在了本地,客户端下次运行将直接恢复之前的颜色设置。
1 parent d612709 commit f6ded5b

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

软件系统客户端Wpf/LoginWindow.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Newtonsoft.Json.Linq;
2020
using ClientsLibrary;
2121
using MaterialDesignThemes.Wpf;
22+
using System.IO;
2223

2324
namespace 软件系统客户端Wpf
2425
{
@@ -320,6 +321,18 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
320321
if (UserClient.JsonSettings.Password != "") LoginButton.Focus();
321322
else if (UserClient.JsonSettings.LoginName != "") PasswordBox.Focus();
322323
else NameTextBox.Focus();
324+
325+
326+
327+
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Palette.txt"))
328+
{
329+
using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\Palette.txt", Encoding.UTF8))
330+
{
331+
string temp = sr.ReadToEnd();
332+
MaterialDesignThemes.Wpf.Palette obj = JObject.Parse(temp).ToObject<MaterialDesignThemes.Wpf.Palette>();
333+
new PaletteHelper().ReplacePalette(obj);
334+
}
335+
}
323336
}
324337

325338
private void NameTextBox_KeyDown(object sender, KeyEventArgs e)

软件系统客户端Wpf/MainWindow.xaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Collections.Generic;
88
using System.Linq;
99
using System.Text;
10+
using System.IO;
1011
using System.Threading.Tasks;
1112
using System.Windows;
1213
using System.Windows.Controls;
@@ -83,6 +84,12 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
8384
//通知服务器退出网络服务
8485
net_socket_client.ClientClose();
8586

87+
//保存当前的颜色选择
88+
var p = new PaletteHelper().QueryPalette();
89+
using (StreamWriter sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + @"\Palette.txt", false, Encoding.UTF8))
90+
{
91+
sw.Write(JObject.FromObject(p).ToString());
92+
}
8693
//等待一秒退出
8794
using (FormWaitInfomation fwm = new FormWaitInfomation("正在退出程序...", 1000))
8895
{

软件系统客户端Wpf/Views/UserPaletteSelector.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
</DataTemplate>
8383
</UserControl.Resources>
8484
<DockPanel>
85-
<wpf:Card DockPanel.Dock="Top" Margin="2">
85+
<wpf:Card DockPanel.Dock="Top" Margin="2,0,2,0">
8686
<DockPanel>
8787
<local:Palette DockPanel.Dock="Left" Width="200" />
8888
<TextBlock Margin="16" TextWrapping="Wrap" VerticalAlignment="Center">这是你当前的主题配色,可以在app.xaml中进行配置和初始化,

0 commit comments

Comments
 (0)