添加Nlog,添加CheckBox demo

This commit is contained in:
czz_y
2024-08-26 11:30:33 +08:00
parent a6490a0693
commit 95ee0c02b0
15 changed files with 572 additions and 33 deletions
+1 -2
View File
@@ -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
View 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
View 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
View 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>
+5 -5
View File
@@ -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);
})
// 浮动全局配置
{
+5 -5
View File
@@ -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);
}