添加Nlog,添加CheckBox demo
This commit is contained in:
parent
a6490a0693
commit
95ee0c02b0
@ -31,6 +31,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AntdUI" Version="1.5.4" />
|
||||
<PackageReference Include="NLog" Version="5.3.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -52,4 +53,10 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="NLog.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
41
MainWindow.Designer.cs
generated
41
MainWindow.Designer.cs
generated
@ -30,12 +30,14 @@
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
|
||||
this.titlebar = new AntdUI.WindowBar();
|
||||
this.button_color = new AntdUI.Button();
|
||||
this.buttonSZ = new AntdUI.Button();
|
||||
this.divider = new AntdUI.Divider();
|
||||
this.menu = new AntdUI.Menu();
|
||||
this.panel_content = new AntdUI.StackPanel();
|
||||
this.button_color = new AntdUI.Button();
|
||||
this.label1 = new AntdUI.Label();
|
||||
this.titlebar.SuspendLayout();
|
||||
this.panel_content.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// titlebar
|
||||
@ -52,11 +54,24 @@
|
||||
this.titlebar.TabIndex = 0;
|
||||
this.titlebar.Text = "AntdUI";
|
||||
//
|
||||
// button_color
|
||||
//
|
||||
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.Location = new System.Drawing.Point(806, 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.WaveSize = 0;
|
||||
//
|
||||
// buttonSZ
|
||||
//
|
||||
this.buttonSZ.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.buttonSZ.Ghost = true;
|
||||
this.buttonSZ.ImageSvg = resources.GetString("buttonSZ.ImageSvg");
|
||||
this.buttonSZ.IconSvg = resources.GetString("buttonSZ.IconSvg");
|
||||
this.buttonSZ.Location = new System.Drawing.Point(856, 0);
|
||||
this.buttonSZ.Name = "buttonSZ";
|
||||
this.buttonSZ.Radius = 0;
|
||||
@ -87,6 +102,7 @@
|
||||
// panel_content
|
||||
//
|
||||
this.panel_content.AutoScroll = true;
|
||||
this.panel_content.Controls.Add(this.label1);
|
||||
this.panel_content.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel_content.Location = new System.Drawing.Point(283, 52);
|
||||
this.panel_content.Name = "panel_content";
|
||||
@ -94,18 +110,15 @@
|
||||
this.panel_content.TabIndex = 10;
|
||||
this.panel_content.Vertical = true;
|
||||
//
|
||||
// button_color
|
||||
// label1
|
||||
//
|
||||
this.button_color.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.button_color.Ghost = true;
|
||||
this.button_color.IconRatio = 0.6F;
|
||||
this.button_color.ImageSvg = resources.GetString("button_color.ImageSvg");
|
||||
this.button_color.Location = new System.Drawing.Point(806, 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.WaveSize = 0;
|
||||
this.label1.Font = new System.Drawing.Font("Microsoft YaHei UI", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label1.Location = new System.Drawing.Point(3, 3);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(719, 563);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "欢迎使用AntdUI Demo";
|
||||
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// MainWindow
|
||||
//
|
||||
@ -123,6 +136,7 @@
|
||||
this.Resizable = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.titlebar.ResumeLayout(false);
|
||||
this.panel_content.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -135,5 +149,6 @@
|
||||
private AntdUI.StackPanel panel_content;
|
||||
private AntdUI.Button buttonSZ;
|
||||
private AntdUI.Button button_color;
|
||||
private AntdUI.Label label1;
|
||||
}
|
||||
}
|
||||
@ -169,10 +169,15 @@ namespace AntdUIDemo
|
||||
case "Steps":
|
||||
control = new StepsDemo();
|
||||
break;
|
||||
case "CheckBox":
|
||||
control = new CheckBoxDemo(this);
|
||||
break;
|
||||
}
|
||||
if (control != null)
|
||||
{
|
||||
AutoDpi(control);
|
||||
//测试日志归档
|
||||
LoggerHelper.Logger.Error(new Exception("测试点击了Menu"), "点击了" + name);
|
||||
panel_content.Controls.Add(control);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,10 +117,10 @@
|
||||
<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.ImageSvg" xml:space="preserve">
|
||||
<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.ImageSvg" xml:space="preserve">
|
||||
<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>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
|
||||
18
NLog.config
Normal file
18
NLog.config
Normal file
@ -0,0 +1,18 @@
|
||||
<?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.{##}.log"
|
||||
layout="${longdate} ${level} ${message} ${newline} ${exception}" />
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Error" writeTo="logfile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
19
Program.cs
19
Program.cs
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using AntdUIDemo.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -14,9 +15,25 @@ namespace AntdUIDemo
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainWindow());
|
||||
}
|
||||
|
||||
// 捕获UI线程中的未处理异常
|
||||
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
|
||||
{
|
||||
LoggerHelper.Logger.Fatal(e.Exception, "未处理的UI线程异常");
|
||||
}
|
||||
|
||||
// 捕获非UI线程中的未处理异常
|
||||
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
LoggerHelper.Logger.Fatal(e.ExceptionObject as Exception, "未处理的非UI线程异常");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
README.md
10
README.md
@ -1,20 +1,20 @@
|
||||
# AntdUIDemo
|
||||
|
||||
本项目基于Winform .NET Framework 4.8开发,是 [AntdUI](https://gitee.com/antdui/AntdUI) 的Demo项目
|
||||
本项目基于 Winform .NET Framework 4.8 开发,是 [AntdUI](https://gitee.com/antdui/AntdUI) 的 Demo 项目
|
||||
|
||||
## ✅ 快速开始
|
||||
```
|
||||
1. git clone 或者直接下载本项目
|
||||
|
||||
2. 若电脑分辨率不是1920×1080(1080P)或者缩放不是100%,使用 Visual Studio 在100%缩放模式下(命令行使用 devenv /noScale 命令启动 Visual Studio)打开项目
|
||||
2. 若电脑分辨率不是 1920×1080(1080P) 或者缩放不是 100%,使用 Visual Studio 在 100% 缩放模式下(命令行使用 devenv /noScale 命令启动 Visual Studio)打开项目
|
||||
|
||||
3. 若电脑没有安装.NET Framework 4.8,编辑项目文件设置 TargetFramework 属性为自己安装的目标框架,兼容框架参照 AntdUI 项目
|
||||
3. 若电脑没有安装 .NET Framework 4.8,编辑项目文件设置 TargetFramework 属性为自己安装的目标框架,兼容框架参照 AntdUI 项目
|
||||
|
||||
4. 编译运行
|
||||
```
|
||||
## ⚠️ 注意事项
|
||||
- 电脑屏幕分辨率低于1920×1080(1080P)请使用大于等于1080P分辨率的屏幕进行开发
|
||||
- 电脑屏幕大于等于1080P分辨率请务必按照上述 **快速开始** 的第二条步骤打开项目,详细原因见 [解决 Visual Studio 中 Windows 窗体设计器的 HDPI/缩放问题](https://learn.microsoft.com/zh-cn/visualstudio/designers/disable-dpi-awareness?view=vs-2022) ,具体启动方式如下图
|
||||
- 电脑屏幕分辨率低于 1920×1080(1080P) 请使用大于等于 1080P 分辨率的屏幕进行开发
|
||||
- 电脑屏幕大于等于 1080P 分辨率或者缩放不是 100% 请务必按照上述 **快速开始** 的第二条步骤打开项目,详细原因见 [解决 Visual Studio 中 Windows 窗体设计器的 HDPI/缩放问题](https://learn.microsoft.com/zh-cn/visualstudio/designers/disable-dpi-awareness?view=vs-2022) ,具体启动方式如下图
|
||||

|
||||
|
||||
## 系统设置
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -11,6 +12,15 @@ namespace AntdUIDemo.Utils
|
||||
{
|
||||
public static void UpdateAppSetting(string key, string value)
|
||||
{
|
||||
// 获取配置文件路径
|
||||
string configFilePath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
|
||||
|
||||
// 检查配置文件是否存在
|
||||
if (!File.Exists(configFilePath))
|
||||
{
|
||||
// 如果文件不存在,可以选择创建默认的配置文件
|
||||
CreateDefaultConfigFile(configFilePath);
|
||||
}
|
||||
// 获取当前配置文件
|
||||
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
|
||||
@ -31,5 +41,22 @@ namespace AntdUIDemo.Utils
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
}
|
||||
|
||||
private static void CreateDefaultConfigFile(string configFilePath)
|
||||
{
|
||||
// 创建一个新的配置文件,并写入默认的appSettings
|
||||
var configXml = @"<?xml version='1.0' encoding='utf-8' ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key='ColorMode' value='Auto' />
|
||||
<add key='Animation' value='True' />
|
||||
<add key='ShadowEnabled' value='True' />
|
||||
<add key='ScrollBarHide' value='False' />
|
||||
<add key='ShowInWindow' value='True' />
|
||||
<add key='ShowOffset' value='0' />
|
||||
</appSettings>
|
||||
</configuration>";
|
||||
|
||||
File.WriteAllText(configFilePath, configXml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
14
Utils/LoggerHelper.cs
Normal file
14
Utils/LoggerHelper.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AntdUIDemo.Utils
|
||||
{
|
||||
public static class LoggerHelper
|
||||
{
|
||||
public static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
}
|
||||
}
|
||||
@ -19,9 +19,8 @@ namespace AntdUIDemo.Views
|
||||
{
|
||||
foreach (Control control in parent.Controls)
|
||||
{
|
||||
if (control is AntdUI.Button antduibutton)
|
||||
if (control is AntdUI.Button button)
|
||||
{
|
||||
var button = (AntdUI.Button)control;
|
||||
var type = button.Type;
|
||||
float borderwidth = button.BorderWidth;
|
||||
int radius = button.Radius;
|
||||
|
||||
250
Views/CheckBoxDemo.Designer.cs
generated
Normal file
250
Views/CheckBoxDemo.Designer.cs
generated
Normal file
@ -0,0 +1,250 @@
|
||||
namespace AntdUIDemo.Views
|
||||
{
|
||||
partial class CheckBoxDemo
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.stackPanel1 = new AntdUI.StackPanel();
|
||||
this.divider1 = new AntdUI.Divider();
|
||||
this.label2 = new AntdUI.Label();
|
||||
this.label1 = new AntdUI.Label();
|
||||
this.label3 = new AntdUI.Label();
|
||||
this.flowPanel1 = new AntdUI.FlowPanel();
|
||||
this.checkbox1 = new AntdUI.Checkbox();
|
||||
this.label5 = new AntdUI.Label();
|
||||
this.flowPanel3 = new AntdUI.FlowPanel();
|
||||
this.checkbox3 = new AntdUI.Checkbox();
|
||||
this.checkbox4 = new AntdUI.Checkbox();
|
||||
this.checkbox5 = new AntdUI.Checkbox();
|
||||
this.label6 = new AntdUI.Label();
|
||||
this.flowPanel4 = new AntdUI.FlowPanel();
|
||||
this.checkbox_autocheckF = new AntdUI.Checkbox();
|
||||
this.checkbox_autocheckT = new AntdUI.Checkbox();
|
||||
this.stackPanel1.SuspendLayout();
|
||||
this.flowPanel1.SuspendLayout();
|
||||
this.flowPanel3.SuspendLayout();
|
||||
this.flowPanel4.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// stackPanel1
|
||||
//
|
||||
this.stackPanel1.Controls.Add(this.flowPanel4);
|
||||
this.stackPanel1.Controls.Add(this.label6);
|
||||
this.stackPanel1.Controls.Add(this.flowPanel3);
|
||||
this.stackPanel1.Controls.Add(this.label5);
|
||||
this.stackPanel1.Controls.Add(this.flowPanel1);
|
||||
this.stackPanel1.Controls.Add(this.label3);
|
||||
this.stackPanel1.Controls.Add(this.divider1);
|
||||
this.stackPanel1.Controls.Add(this.label2);
|
||||
this.stackPanel1.Controls.Add(this.label1);
|
||||
this.stackPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.stackPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.stackPanel1.Name = "stackPanel1";
|
||||
this.stackPanel1.Size = new System.Drawing.Size(700, 451);
|
||||
this.stackPanel1.TabIndex = 0;
|
||||
this.stackPanel1.Text = "stackPanel1";
|
||||
this.stackPanel1.Vertical = true;
|
||||
//
|
||||
// divider1
|
||||
//
|
||||
this.divider1.Location = new System.Drawing.Point(3, 79);
|
||||
this.divider1.Name = "divider1";
|
||||
this.divider1.Size = new System.Drawing.Size(694, 12);
|
||||
this.divider1.TabIndex = 7;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label2.Location = new System.Drawing.Point(3, 49);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(694, 24);
|
||||
this.label2.TabIndex = 6;
|
||||
this.label2.Text = "收集用户的多项选择。";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Font = new System.Drawing.Font("Microsoft YaHei UI", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label1.Location = new System.Drawing.Point(3, 3);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(694, 40);
|
||||
this.label1.TabIndex = 5;
|
||||
this.label1.Text = "Checkbox 多选框";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label3.Location = new System.Drawing.Point(3, 97);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(694, 24);
|
||||
this.label3.TabIndex = 8;
|
||||
this.label3.Text = "基本用法";
|
||||
//
|
||||
// flowPanel1
|
||||
//
|
||||
this.flowPanel1.Controls.Add(this.checkbox1);
|
||||
this.flowPanel1.Location = new System.Drawing.Point(3, 127);
|
||||
this.flowPanel1.Name = "flowPanel1";
|
||||
this.flowPanel1.Size = new System.Drawing.Size(694, 38);
|
||||
this.flowPanel1.TabIndex = 9;
|
||||
this.flowPanel1.Text = "flowPanel1";
|
||||
//
|
||||
// checkbox1
|
||||
//
|
||||
this.checkbox1.AutoCheck = true;
|
||||
this.checkbox1.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
|
||||
this.checkbox1.Location = new System.Drawing.Point(3, 3);
|
||||
this.checkbox1.Name = "checkbox1";
|
||||
this.checkbox1.Size = new System.Drawing.Size(90, 32);
|
||||
this.checkbox1.TabIndex = 0;
|
||||
this.checkbox1.Text = "Checkbox";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label5.Location = new System.Drawing.Point(3, 171);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(694, 24);
|
||||
this.label5.TabIndex = 12;
|
||||
this.label5.Text = "自动大小";
|
||||
//
|
||||
// flowPanel3
|
||||
//
|
||||
this.flowPanel3.Controls.Add(this.checkbox5);
|
||||
this.flowPanel3.Controls.Add(this.checkbox4);
|
||||
this.flowPanel3.Controls.Add(this.checkbox3);
|
||||
this.flowPanel3.Location = new System.Drawing.Point(3, 201);
|
||||
this.flowPanel3.Name = "flowPanel3";
|
||||
this.flowPanel3.Size = new System.Drawing.Size(694, 38);
|
||||
this.flowPanel3.TabIndex = 13;
|
||||
this.flowPanel3.Text = "flowPanel3";
|
||||
//
|
||||
// checkbox3
|
||||
//
|
||||
this.checkbox3.AutoCheck = true;
|
||||
this.checkbox3.AutoSizeMode = AntdUI.TAutoSize.Auto;
|
||||
this.checkbox3.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
|
||||
this.checkbox3.Location = new System.Drawing.Point(3, 3);
|
||||
this.checkbox3.Name = "checkbox3";
|
||||
this.checkbox3.Size = new System.Drawing.Size(99, 37);
|
||||
this.checkbox3.TabIndex = 0;
|
||||
this.checkbox3.Text = "Checkbox";
|
||||
//
|
||||
// checkbox4
|
||||
//
|
||||
this.checkbox4.AutoCheck = true;
|
||||
this.checkbox4.AutoSizeMode = AntdUI.TAutoSize.Width;
|
||||
this.checkbox4.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
|
||||
this.checkbox4.Location = new System.Drawing.Point(108, 3);
|
||||
this.checkbox4.Name = "checkbox4";
|
||||
this.checkbox4.Size = new System.Drawing.Size(99, 32);
|
||||
this.checkbox4.TabIndex = 1;
|
||||
this.checkbox4.Text = "Checkbox";
|
||||
//
|
||||
// checkbox5
|
||||
//
|
||||
this.checkbox5.AutoCheck = true;
|
||||
this.checkbox5.AutoSizeMode = AntdUI.TAutoSize.Height;
|
||||
this.checkbox5.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
|
||||
this.checkbox5.Location = new System.Drawing.Point(213, 3);
|
||||
this.checkbox5.Name = "checkbox5";
|
||||
this.checkbox5.Size = new System.Drawing.Size(120, 37);
|
||||
this.checkbox5.TabIndex = 2;
|
||||
this.checkbox5.Text = "Checkbox";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.label6.Location = new System.Drawing.Point(3, 245);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(694, 24);
|
||||
this.label6.TabIndex = 14;
|
||||
this.label6.Text = "自动选择状态";
|
||||
//
|
||||
// flowPanel4
|
||||
//
|
||||
this.flowPanel4.Controls.Add(this.checkbox_autocheckT);
|
||||
this.flowPanel4.Controls.Add(this.checkbox_autocheckF);
|
||||
this.flowPanel4.Location = new System.Drawing.Point(3, 275);
|
||||
this.flowPanel4.Name = "flowPanel4";
|
||||
this.flowPanel4.Size = new System.Drawing.Size(694, 38);
|
||||
this.flowPanel4.TabIndex = 15;
|
||||
this.flowPanel4.Text = "flowPanel4";
|
||||
//
|
||||
// checkbox_autocheckF
|
||||
//
|
||||
this.checkbox_autocheckF.AutoCheck = true;
|
||||
this.checkbox_autocheckF.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
|
||||
this.checkbox_autocheckF.Location = new System.Drawing.Point(3, 3);
|
||||
this.checkbox_autocheckF.Name = "checkbox_autocheckF";
|
||||
this.checkbox_autocheckF.Size = new System.Drawing.Size(90, 32);
|
||||
this.checkbox_autocheckF.TabIndex = 0;
|
||||
this.checkbox_autocheckF.Text = "Checkbox";
|
||||
//
|
||||
// checkbox_autocheckT
|
||||
//
|
||||
this.checkbox_autocheckT.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
|
||||
this.checkbox_autocheckT.Location = new System.Drawing.Point(99, 3);
|
||||
this.checkbox_autocheckT.Name = "checkbox_autocheckT";
|
||||
this.checkbox_autocheckT.Size = new System.Drawing.Size(90, 32);
|
||||
this.checkbox_autocheckT.TabIndex = 1;
|
||||
this.checkbox_autocheckT.Text = "Checkbox";
|
||||
//
|
||||
// CheckBoxDemo
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.Controls.Add(this.stackPanel1);
|
||||
this.Name = "CheckBoxDemo";
|
||||
this.Size = new System.Drawing.Size(700, 451);
|
||||
this.stackPanel1.ResumeLayout(false);
|
||||
this.flowPanel1.ResumeLayout(false);
|
||||
this.flowPanel3.ResumeLayout(false);
|
||||
this.flowPanel3.PerformLayout();
|
||||
this.flowPanel4.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private AntdUI.StackPanel stackPanel1;
|
||||
private AntdUI.Divider divider1;
|
||||
private AntdUI.Label label2;
|
||||
private AntdUI.Label label1;
|
||||
private AntdUI.Label label3;
|
||||
private AntdUI.FlowPanel flowPanel1;
|
||||
private AntdUI.Checkbox checkbox1;
|
||||
private AntdUI.Label label5;
|
||||
private AntdUI.FlowPanel flowPanel3;
|
||||
private AntdUI.Checkbox checkbox3;
|
||||
private AntdUI.Checkbox checkbox5;
|
||||
private AntdUI.Checkbox checkbox4;
|
||||
private AntdUI.FlowPanel flowPanel4;
|
||||
private AntdUI.Checkbox checkbox_autocheckT;
|
||||
private AntdUI.Checkbox checkbox_autocheckF;
|
||||
private AntdUI.Label label6;
|
||||
}
|
||||
}
|
||||
67
Views/CheckBoxDemo.cs
Normal file
67
Views/CheckBoxDemo.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using AntdUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AntdUIDemo.Views
|
||||
{
|
||||
public partial class CheckBoxDemo : UserControl
|
||||
{
|
||||
private Window window;
|
||||
private AntdUI.TooltipComponent tooltipComponent = new AntdUI.TooltipComponent();
|
||||
public CheckBoxDemo(Window _window)
|
||||
{
|
||||
window = _window;
|
||||
InitializeComponent();
|
||||
// 遍历窗体中的所有控件并绑定 tooltip
|
||||
BindButtonWithToolTip(this);
|
||||
// 绑定事件
|
||||
BindEventHandler();
|
||||
}
|
||||
|
||||
private void BindEventHandler()
|
||||
{
|
||||
checkbox_autocheckF.Click += Checkbox_autocheck_Click;
|
||||
checkbox_autocheckT.Click += Checkbox_autocheck_Click;
|
||||
}
|
||||
|
||||
private void Checkbox_autocheck_Click(object sender, EventArgs e)
|
||||
{
|
||||
var checkbox = sender as AntdUI.Checkbox;
|
||||
AntdUI.Message.info(window, $"Checked: {checkbox.Checked}", autoClose: 1);
|
||||
}
|
||||
|
||||
private void BindButtonWithToolTip(Control parent)
|
||||
{
|
||||
foreach (Control control in parent.Controls)
|
||||
{
|
||||
if (control is AntdUI.Checkbox checkbox)
|
||||
{
|
||||
var autosize = checkbox.AutoSize;
|
||||
var autosizemode = checkbox.AutoSizeMode;
|
||||
var autocheck = checkbox.AutoCheck;
|
||||
// 构建SetTip文本
|
||||
var tooltipText = new StringBuilder();
|
||||
tooltipComponent.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
tooltipText.AppendLine($"AutoSize: {autosize}");
|
||||
tooltipText.AppendLine($"AutoSizeMode: {autosizemode}");
|
||||
tooltipText.AppendLine($"AutoCheck: {autocheck}");
|
||||
// 绑定tooltip
|
||||
tooltipComponent.SetTip(control, tooltipText.ToString());
|
||||
}
|
||||
|
||||
// 递归遍历子控件
|
||||
if (control.HasChildren)
|
||||
{
|
||||
BindButtonWithToolTip(control);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Views/CheckBoxDemo.resx
Normal file
120
Views/CheckBoxDemo.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -7,11 +7,11 @@ namespace AntdUIDemo.Views
|
||||
{
|
||||
public partial class FloatButtonDemo : UserControl
|
||||
{
|
||||
private Form form;
|
||||
private Window window;
|
||||
private Form floatButtonForm = null;
|
||||
public FloatButtonDemo(Form _form)
|
||||
public FloatButtonDemo(Window _window)
|
||||
{
|
||||
form = _form;
|
||||
window = _window;
|
||||
InitializeComponent();
|
||||
//初始化下拉框
|
||||
InitSelectItems();
|
||||
@ -89,7 +89,7 @@ namespace AntdUIDemo.Views
|
||||
{
|
||||
if (floatButtonForm == null || floatButtonForm.IsDisposed)
|
||||
{
|
||||
floatButtonForm = FloatButton.open(new FloatButton.Config(form, new FloatButton.ConfigBtn[]
|
||||
floatButtonForm = FloatButton.open(new FloatButton.Config(window, new FloatButton.ConfigBtn[]
|
||||
{
|
||||
// 使用 svg 图片
|
||||
new FloatButton.ConfigBtn("按钮1","",true)
|
||||
@ -129,7 +129,7 @@ namespace AntdUIDemo.Views
|
||||
}, btn =>
|
||||
{
|
||||
//回调事件
|
||||
AntdUI.Message.info(form, btn.Tooltip, autoClose: 1);
|
||||
AntdUI.Message.info(window, btn.Tooltip, autoClose: 1);
|
||||
})
|
||||
// 浮动全局配置
|
||||
{
|
||||
|
||||
@ -7,10 +7,10 @@ namespace AntdUIDemo.Views
|
||||
{
|
||||
public partial class FlowPanelDemo : UserControl
|
||||
{
|
||||
private Window form;
|
||||
public FlowPanelDemo(Window _form)
|
||||
private Window window;
|
||||
public FlowPanelDemo(Window _window)
|
||||
{
|
||||
form = _form;
|
||||
window = _window;
|
||||
InitializeComponent();
|
||||
//初始化下拉框
|
||||
InitSelectItems();
|
||||
@ -46,7 +46,7 @@ namespace AntdUIDemo.Views
|
||||
|
||||
};
|
||||
// 通过主窗口设置DPI控制添加控件保持缩放比例
|
||||
form.AutoDpi(control);
|
||||
window.AutoDpi(control);
|
||||
flowPanel.Controls.Add(control);
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ namespace AntdUIDemo.Views
|
||||
Size = new Size(90, 42),
|
||||
|
||||
};
|
||||
form.AutoDpi(control);
|
||||
window.AutoDpi(control);
|
||||
flowPanel.Controls.Add(control);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user