优化项目结构,移除第三方包,单文件生成打包

This commit is contained in:
czz_y
2025-01-16 15:35:34 +08:00
parent 3a0fda0e56
commit 64e30b4350
16 changed files with 248 additions and 340 deletions
+5 -58
View File
@@ -41,9 +41,6 @@
this.stackPanel3 = new AntdUI.StackPanel();
this.switch_animation = new AntdUI.Switch();
this.label2 = new AntdUI.Label();
this.stackPanel2 = new AntdUI.StackPanel();
this.select_colormode = new AntdUI.Select();
this.label1 = new AntdUI.Label();
this.tabPage2 = new AntdUI.TabPage();
this.stackPanel6 = new AntdUI.StackPanel();
this.stackPanel8 = new AntdUI.StackPanel();
@@ -58,7 +55,6 @@
this.stackPanel5.SuspendLayout();
this.stackPanel4.SuspendLayout();
this.stackPanel3.SuspendLayout();
this.stackPanel2.SuspendLayout();
this.tabPage2.SuspendLayout();
this.stackPanel6.SuspendLayout();
this.stackPanel8.SuspendLayout();
@@ -68,7 +64,7 @@
// tabs
//
this.tabs.Alignment = System.Windows.Forms.TabAlignment.Left;
this.tabs.Cursor = System.Windows.Forms.Cursors.Default;
this.tabs.Cursor = System.Windows.Forms.Cursors.Hand;
this.tabs.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabs.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.tabs.Gap = 12;
@@ -85,7 +81,6 @@
// tabPage1
//
this.tabPage1.Controls.Add(this.stackPanel1);
this.tabPage1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabPage1.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F);
this.tabPage1.Location = new System.Drawing.Point(90, 6);
this.tabPage1.Name = "tabPage1";
@@ -98,7 +93,6 @@
this.stackPanel1.Controls.Add(this.stackPanel5);
this.stackPanel1.Controls.Add(this.stackPanel4);
this.stackPanel1.Controls.Add(this.stackPanel3);
this.stackPanel1.Controls.Add(this.stackPanel2);
this.stackPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.stackPanel1.Location = new System.Drawing.Point(0, 0);
this.stackPanel1.Name = "stackPanel1";
@@ -111,7 +105,7 @@
//
this.stackPanel5.Controls.Add(this.switch_scrollbar);
this.stackPanel5.Controls.Add(this.label4);
this.stackPanel5.Location = new System.Drawing.Point(3, 117);
this.stackPanel5.Location = new System.Drawing.Point(3, 79);
this.stackPanel5.Name = "stackPanel5";
this.stackPanel5.Size = new System.Drawing.Size(496, 32);
this.stackPanel5.TabIndex = 3;
@@ -119,7 +113,6 @@
//
// switch_scrollbar
//
this.switch_scrollbar.AutoCheck = true;
this.switch_scrollbar.CheckedText = "";
this.switch_scrollbar.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.switch_scrollbar.Location = new System.Drawing.Point(129, 3);
@@ -143,7 +136,7 @@
//
this.stackPanel4.Controls.Add(this.switch_shadow);
this.stackPanel4.Controls.Add(this.label3);
this.stackPanel4.Location = new System.Drawing.Point(3, 79);
this.stackPanel4.Location = new System.Drawing.Point(3, 41);
this.stackPanel4.Name = "stackPanel4";
this.stackPanel4.Size = new System.Drawing.Size(496, 32);
this.stackPanel4.TabIndex = 2;
@@ -151,7 +144,6 @@
//
// switch_shadow
//
this.switch_shadow.AutoCheck = true;
this.switch_shadow.Checked = true;
this.switch_shadow.CheckedText = "";
this.switch_shadow.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@@ -176,7 +168,7 @@
//
this.stackPanel3.Controls.Add(this.switch_animation);
this.stackPanel3.Controls.Add(this.label2);
this.stackPanel3.Location = new System.Drawing.Point(3, 41);
this.stackPanel3.Location = new System.Drawing.Point(3, 3);
this.stackPanel3.Name = "stackPanel3";
this.stackPanel3.Size = new System.Drawing.Size(496, 32);
this.stackPanel3.TabIndex = 1;
@@ -184,7 +176,6 @@
//
// switch_animation
//
this.switch_animation.AutoCheck = true;
this.switch_animation.Checked = true;
this.switch_animation.CheckedText = "";
this.switch_animation.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@@ -205,49 +196,11 @@
this.label2.Text = "开启动画";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// stackPanel2
//
this.stackPanel2.Controls.Add(this.select_colormode);
this.stackPanel2.Controls.Add(this.label1);
this.stackPanel2.Location = new System.Drawing.Point(3, 3);
this.stackPanel2.Name = "stackPanel2";
this.stackPanel2.Size = new System.Drawing.Size(496, 32);
this.stackPanel2.TabIndex = 0;
this.stackPanel2.Text = "stackPanel2";
//
// select_colormode
//
this.select_colormode.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
this.select_colormode.Items.AddRange(new object[] {
"Auto",
"Light",
"Dark"});
this.select_colormode.List = true;
this.select_colormode.Location = new System.Drawing.Point(129, 3);
this.select_colormode.Name = "select_colormode";
this.select_colormode.SelectedIndex = 0;
this.select_colormode.SelectedValue = "Auto";
this.select_colormode.Size = new System.Drawing.Size(65, 26);
this.select_colormode.TabIndex = 2;
this.select_colormode.Text = "Auto";
this.select_colormode.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.select_colormode.WaveSize = 0;
//
// label1
//
this.label1.Location = new System.Drawing.Point(3, 3);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(120, 26);
this.label1.TabIndex = 0;
this.label1.Text = "色彩模式";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.stackPanel6);
this.tabPage2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabPage2.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tabPage2.Location = new System.Drawing.Point(90, 6);
this.tabPage2.Location = new System.Drawing.Point(-502, -384);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(502, 384);
this.tabPage2.TabIndex = 0;
@@ -305,7 +258,6 @@
//
// switch_showinwindow
//
this.switch_showinwindow.AutoCheck = true;
this.switch_showinwindow.CheckedText = "";
this.switch_showinwindow.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.switch_showinwindow.Location = new System.Drawing.Point(129, 3);
@@ -327,7 +279,6 @@
//
// SystemSet
//
this.Controls.Add(this.tabs);
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "SystemSet";
@@ -338,7 +289,6 @@
this.stackPanel5.ResumeLayout(false);
this.stackPanel4.ResumeLayout(false);
this.stackPanel3.ResumeLayout(false);
this.stackPanel2.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.stackPanel6.ResumeLayout(false);
this.stackPanel8.ResumeLayout(false);
@@ -362,8 +312,6 @@
private AntdUI.StackPanel stackPanel3;
private AntdUI.Switch switch_animation;
private AntdUI.Label label2;
private AntdUI.StackPanel stackPanel2;
private AntdUI.Label label1;
private AntdUI.StackPanel stackPanel6;
private AntdUI.StackPanel stackPanel7;
private AntdUI.Switch switch_showinwindow;
@@ -371,6 +319,5 @@
private AntdUI.StackPanel stackPanel8;
private AntdUI.Label label6;
private AntdUI.InputNumber input_offset;
private AntdUI.Select select_colormode;
}
}
+14 -67
View File
@@ -1,6 +1,5 @@
using AntdUI;
using AntdUIDemo.Utils;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
@@ -9,7 +8,7 @@ namespace AntdUIDemo.Controls
{
public partial class SystemSet : UserControl
{
private Window Window;
private readonly Window Window;
public SystemSet(Window _window)
{
Window = _window;
@@ -22,11 +21,10 @@ namespace AntdUIDemo.Controls
private void BindingEventHandler()
{
select_colormode.SelectedIndexChanged += Select_colormode_SelectedIndexChanged;
switch_animation.CheckedChanged += switch_animation_CheckedChanged;
switch_shadow.CheckedChanged += switch_shadow_CheckedChanged;
switch_scrollbar.CheckedChanged += switch_scrollbar_CheckedChanged;
switch_showinwindow.CheckedChanged += switch_showinwindow_CheckedChanged;
switch_animation.CheckedChanged += Switch_animation_CheckedChanged;
switch_shadow.CheckedChanged += Switch_shadow_CheckedChanged;
switch_scrollbar.CheckedChanged += Switch_scrollbar_CheckedChanged;
switch_showinwindow.CheckedChanged += Switch_showinwindow_CheckedChanged;
input_offset.ValueChanged += Input_offset_ValueChanged;
}
@@ -34,89 +32,38 @@ namespace AntdUIDemo.Controls
private void InitData()
{
tabs.SelectedIndex = 0;
// 读取 appsettings.json 文件
var configFilePath = "appsettings.json";
var json = File.ReadAllText(configFilePath);
var jsonObj = JObject.Parse(json);
var appSettings = jsonObj["AppSettings"];
// 色彩模式
var colormode = appSettings["ColorMode"]?.ToString();
var modeIndexMapping = new Dictionary<string, int>
{
{ "Dark", 2 },
{ "Light", 1 },
{ "Auto", 0 }
};
select_colormode.SelectedIndex = modeIndexMapping.ContainsKey(colormode)
? modeIndexMapping[colormode]
: 0;
// 开启动画
var animation = appSettings["Animation"]?.ToString();
switch_animation.Checked = animation == "True";
// 启用阴影
var shadow = appSettings["ShadowEnabled"]?.ToString();
switch_shadow.Checked = shadow == "True";
// 隐藏滚动条
var scrollbar = appSettings["ScrollBarHide"]?.ToString();
switch_scrollbar.Checked = scrollbar == "True";
// 消息窗口弹出
var showinwindow = appSettings["ShowInWindow"]?.ToString();
switch_showinwindow.Checked = showinwindow == "True";
// 消息偏移
var offset = appSettings["ShowOffset"]?.ToString();
input_offset.Value = decimal.Parse(offset ?? "0");
switch_animation.Checked = Config.Animation;
switch_shadow.Checked = Config.ShadowEnabled;
switch_scrollbar.Checked = Config.ScrollBarHide;
switch_showinwindow.Checked = Config.ShowInWindow;
input_offset.Value = Config.NoticeWindowOffsetXY;
}
#region 事件
private void Select_colormode_SelectedIndexChanged(object sender, IntEventArgs e)
private void Switch_animation_CheckedChanged(object sender, BoolEventArgs e)
{
AppSetting.UpdateAppSetting("ColorMode", select_colormode.SelectedValue.ToString());
if (e.Value == 0)
{
ThemeHelper.SetColorMode(Window, ThemeHelper.IsLightMode());
}
else
{
ThemeHelper.SetColorMode(Window, e.Value == 1);
}
}
private void switch_animation_CheckedChanged(object sender, BoolEventArgs e)
{
AppSetting.UpdateAppSetting("Animation", switch_animation.Checked.ToString());
AntdUI.Config.Animation = e.Value;
}
private void Input_offset_ValueChanged(object sender, DecimalEventArgs e)
{
AppSetting.UpdateAppSetting("ShowOffset", input_offset.Value.ToString());
AntdUI.Config.NoticeWindowOffsetXY = (int)e.Value;
}
private void switch_showinwindow_CheckedChanged(object sender, BoolEventArgs e)
private void Switch_showinwindow_CheckedChanged(object sender, BoolEventArgs e)
{
AppSetting.UpdateAppSetting("ShowInWindow", e.Value ? "True" : "False");
AntdUI.Config.ShowInWindow = e.Value;
AntdUI.Message.success(Window, "切换成功!", autoClose: 1);
AntdUI.Notification.success(Window, "提示", "切换成功!", autoClose: 1);
}
private void switch_scrollbar_CheckedChanged(object sender, BoolEventArgs e)
private void Switch_scrollbar_CheckedChanged(object sender, BoolEventArgs e)
{
AppSetting.UpdateAppSetting("ScrollBarHide", e.Value ? "True" : "False");
AntdUI.Config.ScrollBarHide = e.Value;
}
private void switch_shadow_CheckedChanged(object sender, BoolEventArgs e)
private void Switch_shadow_CheckedChanged(object sender, BoolEventArgs e)
{
AppSetting.UpdateAppSetting("ShadowEnabled", e.Value ? "True" : "False");
AntdUI.Config.ShadowEnabled = e.Value;
}
#endregion