diff --git a/AntdUIDemo.csproj b/AntdUIDemo.csproj
index 61677d9..326b762 100644
--- a/AntdUIDemo.csproj
+++ b/AntdUIDemo.csproj
@@ -10,10 +10,10 @@
app.manifest
assets\icon.ico
AnyCPU
- Copyright © 2024 czz_y
+ Copyright © 2025 czz_y
$(Version)
$(Version)
- 1.8.3
+ 1.8.4
czz_y
基于 Winform UI 框架 AntdUI 设计的 Demo
https://gitee.com/mubaiyanghua/antd-uidemo
@@ -30,9 +30,11 @@
-
-
-
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
@@ -50,13 +52,4 @@
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
\ No newline at end of file
diff --git a/FodyWeavers.xml b/FodyWeavers.xml
new file mode 100644
index 0000000..5029e70
--- /dev/null
+++ b/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/FodyWeavers.xsd b/FodyWeavers.xsd
new file mode 100644
index 0000000..f2dbece
--- /dev/null
+++ b/FodyWeavers.xsd
@@ -0,0 +1,176 @@
+
+
+
+
+
+
+
+
+
+
+
+ A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks
+
+
+
+
+ A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.
+
+
+
+
+ A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks
+
+
+
+
+ A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.
+
+
+
+
+ Obsolete, use UnmanagedWinX86Assemblies instead
+
+
+
+
+ A list of unmanaged X86 (32 bit) assembly names to include, delimited with line breaks.
+
+
+
+
+ Obsolete, use UnmanagedWinX64Assemblies instead.
+
+
+
+
+ A list of unmanaged X64 (64 bit) assembly names to include, delimited with line breaks.
+
+
+
+
+ A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with line breaks.
+
+
+
+
+ The order of preloaded assemblies, delimited with line breaks.
+
+
+
+
+
+ This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.
+
+
+
+
+ Controls if .pdbs for reference assemblies are also embedded.
+
+
+
+
+ Controls if runtime assemblies are also embedded.
+
+
+
+
+ Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.
+
+
+
+
+ Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.
+
+
+
+
+ As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.
+
+
+
+
+ The attach method no longer subscribes to the `AppDomain.AssemblyResolve` (.NET 4.x) and `AssemblyLoadContext.Resolving` (.NET 6.0+) events.
+
+
+
+
+ Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.
+
+
+
+
+ Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.
+
+
+
+
+ A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |
+
+
+
+
+ A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.
+
+
+
+
+ A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |
+
+
+
+
+ A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.
+
+
+
+
+ Obsolete, use UnmanagedWinX86Assemblies instead
+
+
+
+
+ A list of unmanaged X86 (32 bit) assembly names to include, delimited with |.
+
+
+
+
+ Obsolete, use UnmanagedWinX64Assemblies instead
+
+
+
+
+ A list of unmanaged X64 (64 bit) assembly names to include, delimited with |.
+
+
+
+
+ A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with |.
+
+
+
+
+ The order of preloaded assemblies, delimited with |.
+
+
+
+
+
+
+
+ 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
+
+
+
+
+ A comma-separated list of error codes that can be safely ignored in assembly verification.
+
+
+
+
+ 'false' to turn off automatic generation of the XML Schema file.
+
+
+
+
+
\ No newline at end of file
diff --git a/MainWindow.Designer.cs b/MainWindow.Designer.cs
index 8960ab5..9a4f326 100644
--- a/MainWindow.Designer.cs
+++ b/MainWindow.Designer.cs
@@ -29,7 +29,7 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
- AntdUI.Tabs.StyleCard styleCard2 = new AntdUI.Tabs.StyleCard();
+ AntdUI.Tabs.StyleCard styleCard3 = new AntdUI.Tabs.StyleCard();
this.titlebar = new AntdUI.PageHeader();
this.input_search = new AntdUI.Input();
this.button_color = new AntdUI.Button();
@@ -59,7 +59,7 @@
this.titlebar.ShowButton = true;
this.titlebar.ShowIcon = true;
this.titlebar.Size = new System.Drawing.Size(1024, 40);
- this.titlebar.SubText = "Demo 1.8.3";
+ this.titlebar.SubText = "Demo 1.8.4";
this.titlebar.TabIndex = 0;
this.titlebar.Text = "AntdUI";
//
@@ -80,12 +80,13 @@
this.button_color.Dock = System.Windows.Forms.DockStyle.Right;
this.button_color.Ghost = true;
this.button_color.IconRatio = 0.6F;
- this.button_color.IconSvg = resources.GetString("button_color.IconSvg");
+ this.button_color.IconSvg = "SunOutlined";
this.button_color.Location = new System.Drawing.Point(780, 0);
this.button_color.Name = "button_color";
this.button_color.Radius = 0;
this.button_color.Size = new System.Drawing.Size(50, 40);
this.button_color.TabIndex = 1;
+ this.button_color.ToggleIconSvg = "MoonOutlined";
this.button_color.WaveSize = 0;
//
// buttonSZ
@@ -130,12 +131,12 @@
this.tabs.Cursor = System.Windows.Forms.Cursors.Default;
this.tabs.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabs.Gap = 20;
- this.tabs.Location = new System.Drawing.Point(70, 40);
+ this.tabs.Location = new System.Drawing.Point(50, 40);
this.tabs.Name = "tabs";
this.tabs.Pages.Add(this.tabPage);
- this.tabs.Size = new System.Drawing.Size(954, 560);
- styleCard2.Closable = true;
- this.tabs.Style = styleCard2;
+ this.tabs.Size = new System.Drawing.Size(974, 560);
+ styleCard3.Closable = true;
+ this.tabs.Style = styleCard3;
this.tabs.TabIndex = 9;
this.tabs.Type = AntdUI.TabType.Card;
//
@@ -146,7 +147,7 @@
this.tabPage.Location = new System.Drawing.Point(3, 40);
this.tabPage.Name = "tabPage";
this.tabPage.ReadOnly = true;
- this.tabPage.Size = new System.Drawing.Size(948, 517);
+ this.tabPage.Size = new System.Drawing.Size(968, 517);
this.tabPage.TabIndex = 1;
this.tabPage.Text = "首页";
//
@@ -157,7 +158,7 @@
this.panel_content.Location = new System.Drawing.Point(0, 0);
this.panel_content.Name = "panel_content";
this.panel_content.Radius = 0;
- this.panel_content.Size = new System.Drawing.Size(948, 517);
+ this.panel_content.Size = new System.Drawing.Size(968, 517);
this.panel_content.TabIndex = 4;
//
// menu
@@ -168,10 +169,8 @@
this.menu.IconRatio = 1F;
this.menu.Indent = true;
this.menu.Location = new System.Drawing.Point(0, 40);
- this.menu.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);
this.menu.Name = "menu";
- this.menu.Padding = new System.Windows.Forms.Padding(6, 6, 0, 6);
- this.menu.Size = new System.Drawing.Size(70, 560);
+ this.menu.Size = new System.Drawing.Size(50, 560);
this.menu.TabIndex = 8;
this.menu.Unique = true;
//
diff --git a/MainWindow.cs b/MainWindow.cs
index d711c58..7f84359 100644
--- a/MainWindow.cs
+++ b/MainWindow.cs
@@ -15,11 +15,10 @@ namespace AntdUIDemo
{
private UserControl currControl;
private bool isUpdatingTabs = false;
+ private bool isLight = true;
public MainWindow()
{
InitializeComponent();
- //加载配置文件
- LoadAppConfig();
//加载菜单
LoadMenu();
//加载欢迎页
@@ -30,6 +29,11 @@ namespace AntdUIDemo
private void InitData()
{
+ //根据系统亮暗初始化一次
+ isLight = ThemeHelper.IsLightMode();
+ button_color.Toggle = !isLight;
+ ThemeHelper.SetColorMode(this, isLight);
+
UserControl control = new Wellcome { Dock = DockStyle.Fill };
AutoDpi(control);
panel_content.Controls.Add(control);
@@ -41,7 +45,7 @@ namespace AntdUIDemo
button_color.Click += Button_color_Click;
input_search.TextChanged += Input_search_textchanged;
menu.SelectChanged += Menu_SelectChanged;
- button_collapse.Click += button_collapse_Click;
+ button_collapse.Click += Button_collapse_Click;
tabs.SelectedIndexChanged += Tabs_SelectedIndexChanged;
//监听系统深浅色变化
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
@@ -78,7 +82,7 @@ namespace AntdUIDemo
menu.SelectIndex(rootIndex, subIndex, true);
}
- private void button_collapse_Click(object sender, EventArgs e)
+ private void Button_collapse_Click(object sender, EventArgs e)
{
if (menu.Collapsed)
{
@@ -86,7 +90,7 @@ namespace AntdUIDemo
}
else
{
- menu.Width = (int)(70 * Config.Dpi);
+ menu.Width = (int)(50 * Config.Dpi);
}
button_collapse.Toggle = !button_collapse.Toggle;
menu.Collapsed = !menu.Collapsed;
@@ -104,62 +108,18 @@ namespace AntdUIDemo
{
if (e.Category == UserPreferenceCategory.General)
{
- ThemeHelper.SetColorMode(this, ThemeHelper.IsLightMode());
+ isLight = ThemeHelper.IsLightMode();
+ button_color.Toggle = !isLight;
+ ThemeHelper.SetColorMode(this, isLight);
}
}
- private void LoadAppConfig()
- {
- // 读取 appsettings.json 文件
- var appSettings = AppSetting.GetAppSettings();
- // 加载色彩模式
- var value = appSettings["ColorMode"]?.ToString();
- if (value == "Auto")
- {
- ThemeHelper.SetColorMode(this, ThemeHelper.IsLightMode());
- }
- else
- {
- ThemeHelper.SetColorMode(this, value == "Light");
- }
-
- // 加载动画
- var animation = appSettings["Animation"]?.ToString();
- AntdUI.Config.Animation = animation == "True";
-
- // 加载阴影
- var shadow = appSettings["ShadowEnabled"]?.ToString();
- AntdUI.Config.ShadowEnabled = shadow == "True";
-
- // 滚动条
- var scrollbar = appSettings["ScrollBarHide"]?.ToString();
- AntdUI.Config.ScrollBarHide = scrollbar == "True";
-
- // 窗口内弹出 Message/Notification
- var popup = appSettings["ShowInWindow"]?.ToString();
- AntdUI.Config.ShowInWindow = popup == "True";
-
- // 通知消息边界偏移量XY(Message/Notification)
- var messageOffset = appSettings["NoticeWindowOffsetXY"]?.ToString();
- AntdUI.Config.NoticeWindowOffsetXY = Convert.ToInt32(messageOffset);
- }
-
private void Button_color_Click(object sender, EventArgs e)
{
- // 读取 appsettings.json 文件
- var appSettings = AppSetting.GetAppSettings();
- var value = appSettings["ColorMode"]?.ToString();
- if (value == "Auto")
- {
- //反向设置
- ThemeHelper.SetColorMode(this, !ThemeHelper.IsLightMode());
- AppSetting.UpdateAppSetting("ColorMode", ThemeHelper.IsLightMode() ? "Dark" : "Light");
- }
- else
- {
- ThemeHelper.SetColorMode(this, value == "Dark");
- AppSetting.UpdateAppSetting("ColorMode", value == "Dark" ? "Light" : "Dark");
- }
+ isLight = !isLight;
+ //这里使用了Toggle属性切换图标
+ button_color.Toggle = !isLight;
+ ThemeHelper.SetColorMode(this, isLight);
}
private void ButtonSZ_Click(object sender, EventArgs e)
@@ -170,8 +130,6 @@ namespace AntdUIDemo
{
CloseIcon = true,
BtnHeight = 0,
- Keyboard = false,
- MaskClosable = false,
});
}
}
diff --git a/MainWindow.resx b/MainWindow.resx
index f1be805..e0b5a38 100644
--- a/MainWindow.resx
+++ b/MainWindow.resx
@@ -117,9 +117,6 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- <svg t="1724123315714" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4689" width="200" height="200"><path d="M512 0C227.84 0 0 227.84 0 512s227.84 512 512 512 512-227.84 512-512S796.16 0 512 0z m0 977.408V46.592c256 0 465.408 209.408 465.408 465.408S768 977.408 512 977.408z" p-id="4690"></path></svg>
-
<svg t="1724122928419" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2893" width="200" height="200"><path d="M920.5 435.9c-7.6-40.3-36.1-66.8-69.8-66.2h-3.4c-36.6 0-66.3-29.7-66.3-66.3 0-7.8 3.6-19.1 6-24.9 15.4-35.1 3.3-78.1-28.9-100.6l-102-56.9-4.2-2c-31.7-13.7-72.7-5.4-96.4 19.2-15.1 15.6-42.2 33.7-54.6 33.7-12.5 0-39.8-18.5-54.9-34.3-23.6-24.9-62.2-34.4-97.4-19.5l-105.4 57.7-4.2 2.7c-31.7 22-43.8 65.3-28.3 100.1 1.9 4.6 6 16.7 6 24.9 0 36.6-29.7 66.3-66.3 66.3h-2.6c-34.9-0.6-63.1 25.8-70.7 66.2-0.9 4.8-8.9 48.2-8.9 84s8 79.2 8.9 84c7.5 39.6 35.3 66.2 69.2 66.2h4.1c36.6 0 66.3 29.7 66.3 66.3 0 8.2-4 20.3-5.8 24.5-15.6 35.2-3.6 78.4 28.9 101.2l99.8 56 4.1 2c10.5 4.6 21.8 6.9 33.6 6.9 24.5 0 47.8-9.9 63.7-27.3 14.8-16.1 43.5-35.8 55.8-35.8 12.8 0 40.8 19.7 56.1 36.5 15.8 17.4 39.8 27.8 64.2 27.8 11.6 0 22.6-2.2 34.3-7.3l103.2-56.9 4.2-2.7c31.6-22 43.7-65.2 28.1-100.4-1.9-4.6-5.9-16.5-5.9-24.6 0-36.6 29.7-66.3 66.3-66.3h4c34 0 61.7-26.4 69.2-65.9 0.1-0.5 9-46.3 9-84.4-0.1-35.9-8.1-79.1-9-83.9z m-71.3 154.6c-0.6 3.3-1.5 5.6-2.2 7.1-76.4 0.1-138.6 62.4-138.6 138.8 0 23 8.4 45.7 12.1 53.9 1.6 3.5 0.4 8.4-3.3 11.5l-96.4 53.3c-4.7 1.6-11.9-0.9-14.3-3.5-5.6-6.2-56.5-60.3-109.8-60.3-54 0-106.9 56.8-109.1 59.2-2.2 2.4-7.4 5.7-14.6 3.1l-93.1-52.1c-3.1-2.5-4.5-7.7-2.8-11.6 1.2-2.8 12-28.1 12-53.7 0-76.5-62.1-138.7-138.6-138.8-0.7-1.5-1.6-3.8-2.3-7.1-0.3-1.6-7.6-40.9-7.6-70.6 0-29.7 7.3-69 7.6-70.6 0.6-3.3 1.5-5.7 2.3-7.1 76.4-0.1 138.6-62.3 138.6-138.8 0-25-9.9-49.1-12.1-54-1.5-3.5-0.4-8.3 3.2-11.4l98.2-53.9c4.8-1.7 12.5 0.8 15 3.4 5.5 5.8 55.7 56.8 107.4 56.8 51.2 0 101.2-50 106.7-55.8 2.4-2.4 8.3-5.6 15.1-3.1l94.9 52.7c3.2 2.5 4.5 7.7 2.9 11.3l-0.7 1.8c-3.1 7.6-11.3 29.8-11.3 52.2 0 76.5 62.1 138.7 138.6 138.8 0.7 1.5 1.6 3.8 2.3 7.1 0.1 0.4 7.6 40.6 7.6 70.6-0.1 25.6-5.7 60.4-7.7 70.8z" p-id="2894"></path><path d="M498.7 355.9c-90.3 0-163.8 73.5-163.8 163.8 0 90.3 73.5 163.8 163.8 163.8 90.3 0 163.8-73.5 163.8-163.8 0-90.4-73.5-163.8-163.8-163.8z m0 273.1c-60.3 0-109.4-49.1-109.4-109.4 0-60.3 49.1-109.4 109.4-109.4 60.3 0 109.4 49.1 109.4 109.4 0 60.3-49.1 109.4-109.4 109.4z" p-id="2895"></path></svg>
diff --git a/NLog.config b/NLog.config
deleted file mode 100644
index bae1761..0000000
--- a/NLog.config
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Program.cs b/Program.cs
index cd6fdb4..ca0f108 100644
--- a/Program.cs
+++ b/Program.cs
@@ -30,14 +30,12 @@ namespace AntdUIDemo
// 捕获UI线程中的未处理异常
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
- LoggerHelper.Logger.Fatal(e.Exception, "未处理的UI线程异常");
AntdUI.Notification.error(mainWindow, "未处理的UI线程异常", e.Exception.Message, autoClose: 3, align: AntdUI.TAlignFrom.TR);
}
// 捕获非UI线程中的未处理异常
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
- LoggerHelper.Logger.Fatal(e.ExceptionObject as Exception, "未处理的非UI线程异常");
AntdUI.Notification.error(mainWindow, "未处理的非UI线程异常", e.ToString(), autoClose: 3, align: AntdUI.TAlignFrom.TR);
}
}
diff --git a/README.md b/README.md
index 14d8f39..6bc81f9 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
AntdUI Demo
-本项目基于 `Winform .NET Framework 4.8` 开发,是 [AntdUI](https://gitee.com/antdui/AntdUI) 的 Demo 项目,当前版本 `1.8.3`
+本项目基于 `Winform .NET Framework 4.8` 开发,是 [AntdUI](https://gitee.com/antdui/AntdUI) 的 Demo 项目,当前版本 `1.8.4`
diff --git a/Utils/AppSetting.cs b/Utils/AppSetting.cs
deleted file mode 100644
index ef89561..0000000
--- a/Utils/AppSetting.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using Newtonsoft.Json.Linq;
-using System.IO;
-
-namespace AntdUIDemo.Utils
-{
- public class AppSetting
- {
- private static readonly string configFilePath = "appsettings.json";
-
- public static JObject GetAppSettings(string configFilePath = "appsettings.json")
- {
- if (!File.Exists(configFilePath))
- {
- // 如果文件不存在,创建默认的配置文件
- CreateDefaultConfigFile(configFilePath);
- }
-
- var json = File.ReadAllText(configFilePath);
- var jsonObj = JObject.Parse(json);
-
- return (JObject)jsonObj["AppSettings"];
- }
-
- public static void UpdateAppSetting(string key, string value)
- {
- // 检查配置文件是否存在
- if (!File.Exists(configFilePath))
- {
- // 如果文件不存在,创建默认的配置文件
- CreateDefaultConfigFile(configFilePath);
- }
-
- // 读取并解析现有的 appsettings.json 文件
- var json = File.ReadAllText(configFilePath);
- var jsonObj = JObject.Parse(json);
-
- // 获取或创建 "AppSettings" 节点
- var appSettings = jsonObj["AppSettings"] as JObject;
- if (appSettings == null)
- {
- appSettings = new JObject();
- jsonObj["AppSettings"] = appSettings;
- }
-
- // 检查 key 是否存在,存在则更新,不存在则添加
- if (appSettings[key] != null)
- {
- appSettings[key] = value;
- }
- else
- {
- appSettings.Add(key, value);
- }
-
- // 保存更改回 appsettings.json 文件
- File.WriteAllText(configFilePath, jsonObj.ToString());
- }
-
- private static void CreateDefaultConfigFile(string configFilePath)
- {
- // 创建一个新的 appsettings.json 文件,并写入默认的 AppSettings
- var configJson = @"{
- ""AppSettings"": {
- ""ColorMode"": ""Auto"",
- ""Animation"": ""True"",
- ""ShadowEnabled"": ""True"",
- ""ScrollBarHide"": ""False"",
- ""ShowInWindow"": ""True"",
- ""ShowOffset"": ""0""
- }
-}";
- File.WriteAllText(configFilePath, configJson);
- }
- }
-}
diff --git a/Utils/LoggerHelper.cs b/Utils/LoggerHelper.cs
deleted file mode 100644
index e5de7f0..0000000
--- a/Utils/LoggerHelper.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using NLog;
-
-namespace AntdUIDemo.Utils
-{
- public class LoggerHelper
- {
- public static readonly Logger Logger = LogManager.GetCurrentClassLogger();
- }
-}
diff --git a/Utils/ThemeHelper.cs b/Utils/ThemeHelper.cs
index c81c45c..ada0a07 100644
--- a/Utils/ThemeHelper.cs
+++ b/Utils/ThemeHelper.cs
@@ -27,22 +27,22 @@ namespace AntdUIDemo.Utils
///
/// 设置明暗颜色
///
- ///
- ///
+ /// 父窗口
+ /// 是否亮色
public static void SetColorMode(AntdUI.Window window, bool isLight)
{
- if (!isLight)
- {
- AntdUI.Config.IsDark = true;// 设置为深色模式
- window.BackColor = Color.FromArgb(31, 31, 31);
- window.ForeColor = Color.White;
- }
- else
+ if (isLight)
{
AntdUI.Config.IsLight = true;
window.BackColor = Color.White;
window.ForeColor = Color.Black;
}
+ else
+ {
+ AntdUI.Config.IsDark = true;// 设置为深色模式
+ window.BackColor = Color.FromArgb(31, 31, 31);
+ window.ForeColor = Color.White;
+ }
}
}
}
diff --git a/Views/FlowPanelDemo.cs b/Views/FlowPanelDemo.cs
index 57d4eb1..ba6e4fe 100644
--- a/Views/FlowPanelDemo.cs
+++ b/Views/FlowPanelDemo.cs
@@ -34,11 +34,11 @@ namespace AntdUIDemo.Views
flowPanel.AutoScroll = switch_autoscroll.Checked;
flowPanel.Controls.Clear();
- for (int i = 0; i < 14; i++)
+ for (int i = 1; i < 15; i++)
{
var control = new AntdUI.Button()
{
- Text = "Button",
+ Text = "Button" + i,
Type = TTypeMini.Primary,
WaveSize = 0,
Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
@@ -48,6 +48,7 @@ namespace AntdUIDemo.Views
// 通过主窗口设置DPI控制添加控件保持缩放比例
window.AutoDpi(control);
flowPanel.Controls.Add(control);
+ control.BringToFront();
}
}
@@ -125,7 +126,7 @@ namespace AntdUIDemo.Views
{
var control = new AntdUI.Button()
{
- Text = "Button",
+ Text = "Button" + (flowPanel.Controls.Count+1),
Type = TTypeMini.Primary,
WaveSize = 0,
Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
@@ -134,6 +135,7 @@ namespace AntdUIDemo.Views
};
window.AutoDpi(control);
flowPanel.Controls.Add(control);
+ control.BringToFront();
}
// 删除按钮
@@ -142,7 +144,7 @@ namespace AntdUIDemo.Views
if (flowPanel.Controls.Count > 0)
{
// 删除最后一个控件
- flowPanel.Controls.RemoveAt(flowPanel.Controls.Count - 1);
+ flowPanel.Controls.RemoveAt(0);
}
}
diff --git a/Views/SubView/SystemSet.Designer.cs b/Views/SubView/SystemSet.Designer.cs
index c646699..debb0c3 100644
--- a/Views/SubView/SystemSet.Designer.cs
+++ b/Views/SubView/SystemSet.Designer.cs
@@ -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;
}
}
diff --git a/Views/SubView/SystemSet.cs b/Views/SubView/SystemSet.cs
index eccf54f..7007416 100644
--- a/Views/SubView/SystemSet.cs
+++ b/Views/SubView/SystemSet.cs
@@ -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
- {
- { "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
diff --git a/appsettings.json b/appsettings.json
deleted file mode 100644
index aace2ba..0000000
--- a/appsettings.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "AppSettings": {
- "ColorMode": "Auto",
- "Animation": "True",
- "ShadowEnabled": "True",
- "ScrollBarHide": "False",
- "ShowInWindow": "True",
- "ShowOffset": 0
- }
-}