新增Table部分功能

This commit is contained in:
czz_y 2024-08-30 17:36:30 +08:00
parent 6ceb46eb93
commit d220164622
6 changed files with 1352 additions and 619 deletions

View File

@ -232,6 +232,9 @@ namespace AntdUIDemo
case "Segmented": case "Segmented":
control = new SegmentedDemo(); control = new SegmentedDemo();
break; break;
case "Table":
control = new TableDemo(this);
break;
} }
if (control != null) if (control != null)
{ {

171
Models/User.cs Normal file
View File

@ -0,0 +1,171 @@
using AntdUI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AntdUIDemo.Models
{
internal class User : NotifyProperty
{
private int id { get; set; }
private bool selected;
private string name;
private int age;
private string address;
private bool enabled;
private CellImage[] cellImages;
private CellTag[] cellTags;
private CellBadge cellBadge;
private CellText cellText;
private CellLink[] cellLinks;
private CellProgress cellProgress;
private CellDivider cellDivider;
public int Id
{
get { return id; }
set
{
if (id == value) return;
id = value;
OnPropertyChanged(nameof(Id));
}
}
public bool Selected
{
get { return selected; }
set
{
if (selected == value) return;
selected = value;
OnPropertyChanged(nameof(Selected));
}
}
public string Name
{
get { return name; }
set
{
if (name == value) return;
name = value;
OnPropertyChanged(nameof(Name));
}
}
public int Age
{
get { return age; }
set
{
if (age == value) return;
age = value;
OnPropertyChanged(nameof(Age));
}
}
public string Address
{
get { return address; }
set
{
if (address == value) return;
address = value;
OnPropertyChanged(nameof(Address));
}
}
public bool Enabled
{
get { return enabled; }
set
{
if (enabled == value) return;
enabled = value;
OnPropertyChanged(nameof(Enabled));
}
}
public CellImage[] CellImages
{
get { return cellImages; }
set
{
if (cellImages == value) return;
cellImages = value;
OnPropertyChanged(nameof(CellImages));
}
}
public CellTag[] CellTags
{
get { return cellTags; }
set
{
if (cellTags == value) return;
cellTags = value;
OnPropertyChanged(nameof(CellTags));
}
}
public CellBadge CellBadge
{
get { return cellBadge; }
set
{
if (cellBadge == value) return;
cellBadge = value;
OnPropertyChanged(nameof(CellBadge));
}
}
public CellText CellText
{
get { return cellText; }
set
{
if (cellText == value) return;
cellText = value;
OnPropertyChanged(nameof(CellText));
}
}
public CellLink[] CellLinks
{
get { return cellLinks; }
set
{
if (cellLinks == value) return;
cellLinks = value;
OnPropertyChanged(nameof(CellLinks));
}
}
public CellProgress CellProgress
{
get { return cellProgress; }
set
{
if (cellProgress == value) return;
cellProgress = value;
OnPropertyChanged(nameof(CellProgress));
}
}
public CellDivider CellDivider
{
get { return cellDivider; }
set
{
if (cellDivider == value) return;
cellDivider = value;
OnPropertyChanged(nameof(CellDivider));
}
}
}
}

File diff suppressed because it is too large Load Diff

270
Views/TableDemo.Designer.cs generated Normal file
View File

@ -0,0 +1,270 @@
namespace AntdUIDemo.Views
{
partial class TableDemo
{
/// <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.table_base = new AntdUI.Table();
this.flowPanel1 = new AntdUI.FlowPanel();
this.checkbox5 = new AntdUI.Checkbox();
this.checkbox4 = new AntdUI.Checkbox();
this.checkbox3 = new AntdUI.Checkbox();
this.checkbox2 = new AntdUI.Checkbox();
this.checkbox6 = new AntdUI.Checkbox();
this.checkbox1 = new AntdUI.Checkbox();
this.flowPanel3 = new AntdUI.FlowPanel();
this.button5 = new AntdUI.Button();
this.button2 = new AntdUI.Button();
this.label3 = new AntdUI.Label();
this.divider1 = new AntdUI.Divider();
this.label2 = new AntdUI.Label();
this.label1 = new AntdUI.Label();
this.label4 = new AntdUI.Label();
this.stackPanel1.SuspendLayout();
this.flowPanel1.SuspendLayout();
this.flowPanel3.SuspendLayout();
this.SuspendLayout();
//
// stackPanel1
//
this.stackPanel1.Controls.Add(this.label4);
this.stackPanel1.Controls.Add(this.table_base);
this.stackPanel1.Controls.Add(this.flowPanel1);
this.stackPanel1.Controls.Add(this.flowPanel3);
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, 770);
this.stackPanel1.TabIndex = 0;
this.stackPanel1.Text = "stackPanel1";
this.stackPanel1.Vertical = true;
//
// table_base
//
this.table_base.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.table_base.Location = new System.Drawing.Point(3, 199);
this.table_base.Name = "table_base";
this.table_base.Size = new System.Drawing.Size(694, 304);
this.table_base.TabIndex = 30;
this.table_base.Text = "table1";
//
// flowPanel1
//
this.flowPanel1.Controls.Add(this.checkbox5);
this.flowPanel1.Controls.Add(this.checkbox4);
this.flowPanel1.Controls.Add(this.checkbox3);
this.flowPanel1.Controls.Add(this.checkbox2);
this.flowPanel1.Controls.Add(this.checkbox6);
this.flowPanel1.Controls.Add(this.checkbox1);
this.flowPanel1.Location = new System.Drawing.Point(3, 171);
this.flowPanel1.Name = "flowPanel1";
this.flowPanel1.Size = new System.Drawing.Size(694, 22);
this.flowPanel1.TabIndex = 29;
this.flowPanel1.Text = "flowPanel1";
//
// checkbox5
//
this.checkbox5.AutoCheck = true;
this.checkbox5.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
this.checkbox5.Location = new System.Drawing.Point(466, 0);
this.checkbox5.Margin = new System.Windows.Forms.Padding(0);
this.checkbox5.Name = "checkbox5";
this.checkbox5.Size = new System.Drawing.Size(66, 20);
this.checkbox5.TabIndex = 21;
this.checkbox5.Text = "排序";
//
// checkbox4
//
this.checkbox4.AutoCheck = true;
this.checkbox4.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
this.checkbox4.Location = new System.Drawing.Point(388, 0);
this.checkbox4.Margin = new System.Windows.Forms.Padding(0);
this.checkbox4.Name = "checkbox4";
this.checkbox4.Size = new System.Drawing.Size(78, 20);
this.checkbox4.TabIndex = 20;
this.checkbox4.Text = "奇偶列";
//
// checkbox3
//
this.checkbox3.AutoCheck = true;
this.checkbox3.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
this.checkbox3.Location = new System.Drawing.Point(285, 0);
this.checkbox3.Margin = new System.Windows.Forms.Padding(0);
this.checkbox3.Name = "checkbox3";
this.checkbox3.Size = new System.Drawing.Size(103, 20);
this.checkbox3.TabIndex = 19;
this.checkbox3.Text = "显示列边框";
//
// checkbox2
//
this.checkbox2.AutoCheck = true;
this.checkbox2.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
this.checkbox2.Location = new System.Drawing.Point(182, 0);
this.checkbox2.Margin = new System.Windows.Forms.Padding(0);
this.checkbox2.Name = "checkbox2";
this.checkbox2.Size = new System.Drawing.Size(103, 20);
this.checkbox2.TabIndex = 18;
this.checkbox2.Text = "列拖拽排序";
//
// checkbox6
//
this.checkbox6.AutoCheck = true;
this.checkbox6.Checked = true;
this.checkbox6.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
this.checkbox6.Location = new System.Drawing.Point(91, 0);
this.checkbox6.Margin = new System.Windows.Forms.Padding(0);
this.checkbox6.Name = "checkbox6";
this.checkbox6.Size = new System.Drawing.Size(91, 20);
this.checkbox6.TabIndex = 17;
this.checkbox6.Text = "显示表头";
//
// checkbox1
//
this.checkbox1.AutoCheck = true;
this.checkbox1.Checked = true;
this.checkbox1.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
this.checkbox1.Location = new System.Drawing.Point(0, 0);
this.checkbox1.Margin = new System.Windows.Forms.Padding(0);
this.checkbox1.Name = "checkbox1";
this.checkbox1.Size = new System.Drawing.Size(91, 20);
this.checkbox1.TabIndex = 12;
this.checkbox1.Text = "固定表头";
//
// flowPanel3
//
this.flowPanel3.Controls.Add(this.button5);
this.flowPanel3.Controls.Add(this.button2);
this.flowPanel3.Location = new System.Drawing.Point(3, 127);
this.flowPanel3.Name = "flowPanel3";
this.flowPanel3.Size = new System.Drawing.Size(694, 38);
this.flowPanel3.TabIndex = 27;
this.flowPanel3.Text = "flowPanel3";
//
// button5
//
this.button5.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button5.Location = new System.Drawing.Point(89, 3);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(80, 32);
this.button5.TabIndex = 5;
this.button5.Text = "删除";
this.button5.Type = AntdUI.TTypeMini.Error;
this.button5.WaveSize = 0;
//
// button2
//
this.button2.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button2.Location = new System.Drawing.Point(3, 3);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(80, 32);
this.button2.TabIndex = 2;
this.button2.Text = "新增";
this.button2.Type = AntdUI.TTypeMini.Primary;
this.button2.WaveSize = 0;
//
// 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 = 24;
this.label3.Text = "基本用法";
//
// 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 = 23;
//
// 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 = 22;
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 = 21;
this.label1.Text = "Table 表格";
//
// label4
//
this.label4.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label4.Location = new System.Drawing.Point(3, 509);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(694, 24);
this.label4.TabIndex = 31;
this.label4.Text = "分页";
//
// TableDemo
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.Controls.Add(this.stackPanel1);
this.Name = "TableDemo";
this.Size = new System.Drawing.Size(700, 770);
this.stackPanel1.ResumeLayout(false);
this.flowPanel1.ResumeLayout(false);
this.flowPanel3.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 flowPanel3;
private AntdUI.Button button2;
private AntdUI.Button button5;
private AntdUI.Table table_base;
private AntdUI.FlowPanel flowPanel1;
private AntdUI.Checkbox checkbox6;
private AntdUI.Checkbox checkbox1;
private AntdUI.Checkbox checkbox5;
private AntdUI.Checkbox checkbox4;
private AntdUI.Checkbox checkbox3;
private AntdUI.Checkbox checkbox2;
private AntdUI.Label label4;
}
}

97
Views/TableDemo.cs Normal file
View File

@ -0,0 +1,97 @@
using AntdUI;
using AntdUIDemo.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AntdUIDemo.Views
{
public partial class TableDemo : UserControl
{
private AntdUI.Window window;
AntList<User> antList;
public TableDemo(AntdUI.Window _window)
{
window = _window;
InitializeComponent();
//初始化表格列头
InitTableColumns();
InitData();
BindEventHandler();
}
private void InitTableColumns()
{
table_base.Columns = [
new ColumnCheck("Selected"){Fixed = true},
new Column("Name", "姓名",ColumnAlign.Center),
new Column("Age", "年龄",ColumnAlign.Center),
new Column("Address", "地址"){
Width = "120",
LineBreak = true,
},
new ColumnSwitch("Enabled", "是否启用", ColumnAlign.Center){
//支持点击回调
Call= (value,record, i_row, i_col) =>{
//执行耗时操作
Thread.Sleep(2000);
AntdUI.Message.info(window, value.ToString(),autoClose:1);
return value;
}
},
new Column("CellImages", "图片",ColumnAlign.Center),
new Column("CellTags", "标签",ColumnAlign.Center),
new Column("CellBadge", "徽标",ColumnAlign.Center),
new Column("CellText", "富文本",ColumnAlign.Center),
new Column("CellProgress", "进度条",ColumnAlign.Center),
new Column("CellDivider", "分割线",ColumnAlign.Center),
new Column("CellLinks", "链接",ColumnAlign.Center),
];
}
private void BindEventHandler()
{
}
private void InitData()
{
antList = new AntList<User>(3);
for (int i = 0; i < 3; i++)
{
antList.Add(new User
{
Id = i,
Selected = false,
Name = "张三",
Age = 30,
Address = "浙江省杭州市西湖区湖底公园1号",
Enabled = i % 2 == 0,
//CellImages = [new CellImage(Properties.Resources.bg1)],
CellTags = [new CellTag("测试", TTypeMini.Primary), new CellTag("测试", TTypeMini.Success), new CellTag("测试", TTypeMini.Warn)],
CellBadge = new CellBadge(TState.Processing, "测试中"),
CellText = new CellText("这是一个带图标的文本")
{
IconRatio = 0.5f,
PrefixSvg = "<svg viewBox=\"64 64 896 896\" focusable=\"false\" data-icon=\"search\" width=\"1em\" height=\"1em\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z\"></path></svg>"
},
CellLinks = [new CellLink("https://gitee.com/antdui/AntdUI", "AntdUI"),
new CellButton(i.ToString(),"修改",TTypeMini.Primary),
new CellButton(i.ToString(),"删除",TTypeMini.Error)],
//value:0-1
CellProgress = new CellProgress(0.5f),
CellDivider = new CellDivider(),
});
}
table_base.Binding<User>(antList);
}
}
}

120
Views/TableDemo.resx Normal file
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>