优化项目结构,移除第三方包,单文件生成打包
This commit is contained in:
parent
3a0fda0e56
commit
64e30b4350
@ -10,10 +10,10 @@
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<ApplicationIcon>assets\icon.ico</ApplicationIcon>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<Copyright>Copyright © 2024 czz_y</Copyright>
|
||||
<Copyright>Copyright © 2025 czz_y</Copyright>
|
||||
<FileVersion>$(Version)</FileVersion>
|
||||
<AssemblyVersion>$(Version)</AssemblyVersion>
|
||||
<Version>1.8.3</Version>
|
||||
<Version>1.8.4</Version>
|
||||
<Authors>czz_y</Authors>
|
||||
<Description>基于 Winform UI 框架 AntdUI 设计的 Demo</Description>
|
||||
<PackageProjectUrl>https://gitee.com/mubaiyanghua/antd-uidemo</PackageProjectUrl>
|
||||
@ -30,9 +30,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AntdUI" Version="1.8.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.3.3" />
|
||||
<PackageReference Include="AntdUI" Version="1.8.4" />
|
||||
<PackageReference Include="Costura.Fody" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -50,13 +52,4 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="NLog.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
3
FodyWeavers.xml
Normal file
3
FodyWeavers.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<Costura />
|
||||
</Weavers>
|
||||
176
FodyWeavers.xsd
Normal file
176
FodyWeavers.xsd
Normal file
@ -0,0 +1,176 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
|
||||
<xs:element name="Weavers">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Obsolete, use UnmanagedWinX86Assemblies instead</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinX86Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of unmanaged X86 (32 bit) assembly names to include, delimited with line breaks.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Obsolete, use UnmanagedWinX64Assemblies instead.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinX64Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of unmanaged X64 (64 bit) assembly names to include, delimited with line breaks.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinArm64Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with line breaks.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>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.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="DisableCompression" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="DisableCleanup" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="DisableEventSubscription" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The attach method no longer subscribes to the `AppDomain.AssemblyResolve` (.NET 4.x) and `AssemblyLoadContext.Resolving` (.NET 6.0+) events.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>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.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>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.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="ExcludeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="IncludeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Obsolete, use UnmanagedWinX86Assemblies instead</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="UnmanagedWinX86Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of unmanaged X86 (32 bit) assembly names to include, delimited with |.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Obsolete, use UnmanagedWinX64Assemblies instead</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="UnmanagedWinX64Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of unmanaged X64 (64 bit) assembly names to include, delimited with |.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="UnmanagedWinArm64Assemblies" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with |.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="PreloadOrder" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
<xs:attribute name="VerifyAssembly" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="GenerateXsd" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
23
MainWindow.Designer.cs
generated
23
MainWindow.Designer.cs
generated
@ -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;
|
||||
//
|
||||
|
||||
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,9 +117,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="button_color.IconSvg" xml:space="preserve">
|
||||
<value><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></value>
|
||||
</data>
|
||||
<data name="buttonSZ.IconSvg" xml:space="preserve">
|
||||
<value><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></value>
|
||||
</data>
|
||||
|
||||
18
NLog.config
18
NLog.config
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<targets>
|
||||
<!-- 定义日志文件的目标 -->
|
||||
<target xsi:type="File" name="logfile" fileName="logs/logfile.log"
|
||||
archiveEvery="Day"
|
||||
archiveNumbering="Date"
|
||||
maxArchiveFiles="7"
|
||||
archiveFileName="logs/archived/{##}.log"
|
||||
layout="${longdate} ${message} ${newline} ${exception}" />
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Error" writeTo="logfile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
<h1>AntdUI Demo</h1>
|
||||
|
||||
本项目基于 `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`
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
using NLog;
|
||||
|
||||
namespace AntdUIDemo.Utils
|
||||
{
|
||||
public class LoggerHelper
|
||||
{
|
||||
public static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
}
|
||||
}
|
||||
@ -27,22 +27,22 @@ namespace AntdUIDemo.Utils
|
||||
/// <summary>
|
||||
/// 设置明暗颜色
|
||||
/// </summary>
|
||||
/// <param name="window"></param>
|
||||
/// <param name="isLight"></param>
|
||||
/// <param name="window">父窗口</param>
|
||||
/// <param name="isLight">是否亮色</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
63
Views/SubView/SystemSet.Designer.cs
generated
63
Views/SubView/SystemSet.Designer.cs
generated
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"AppSettings": {
|
||||
"ColorMode": "Auto",
|
||||
"Animation": "True",
|
||||
"ShadowEnabled": "True",
|
||||
"ScrollBarHide": "False",
|
||||
"ShowInWindow": "True",
|
||||
"ShowOffset": 0
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user