From 3d7611e546d0afbc92e85f790c8c918e98caf9ba Mon Sep 17 00:00:00 2001 From: czz_y Date: Sat, 31 Aug 2024 19:03:17 +0800 Subject: [PATCH] Table --- MainWindow.cs | 3 + Models/User.cs | 2 +- Views/Demo.Designer.cs | 89 ++++++++++++ Views/Demo.cs | 32 +++++ Views/Demo.resx | 120 ++++++++++++++++ Views/DrawerDemo.Designer.cs | 232 +++++++++++++++++++++++++++++++ Views/DrawerDemo.cs | 77 ++++++++++ Views/DrawerDemo.resx | 120 ++++++++++++++++ Views/FlowPanelDemo.Designer.cs | 3 +- Views/Table/UserEdit.Designer.cs | 203 +++++++++++++++++++++++++++ Views/Table/UserEdit.cs | 59 ++++++++ Views/Table/UserEdit.resx | 120 ++++++++++++++++ Views/TableDemo.Designer.cs | 46 +++--- Views/TableDemo.cs | 104 +++++++++++++- Views/Test/TestDemo.Designer.cs | 189 +++++++++++++++++++++++++ Views/Test/TestDemo.cs | 20 +++ Views/Test/TestDemo.resx | 120 ++++++++++++++++ 17 files changed, 1512 insertions(+), 27 deletions(-) create mode 100644 Views/Demo.Designer.cs create mode 100644 Views/Demo.cs create mode 100644 Views/Demo.resx create mode 100644 Views/DrawerDemo.Designer.cs create mode 100644 Views/DrawerDemo.cs create mode 100644 Views/DrawerDemo.resx create mode 100644 Views/Table/UserEdit.Designer.cs create mode 100644 Views/Table/UserEdit.cs create mode 100644 Views/Table/UserEdit.resx create mode 100644 Views/Test/TestDemo.Designer.cs create mode 100644 Views/Test/TestDemo.cs create mode 100644 Views/Test/TestDemo.resx diff --git a/MainWindow.cs b/MainWindow.cs index 73260c5..e7a8a01 100644 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -235,6 +235,9 @@ namespace AntdUIDemo case "Table": control = new TableDemo(this); break; + case "Drawer": + control = new DrawerDemo(this); + break; } if (control != null) { diff --git a/Models/User.cs b/Models/User.cs index b5fcce7..3fd3200 100644 --- a/Models/User.cs +++ b/Models/User.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace AntdUIDemo.Models { - internal class User : NotifyProperty + public class User : NotifyProperty { private int id { get; set; } private bool selected; diff --git a/Views/Demo.Designer.cs b/Views/Demo.Designer.cs new file mode 100644 index 0000000..13a377b --- /dev/null +++ b/Views/Demo.Designer.cs @@ -0,0 +1,89 @@ +namespace AntdUIDemo.Views +{ + partial class Demo + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.panel1 = new AntdUI.Panel(); + this.windowBar = new AntdUI.WindowBar(); + this.button_close = new AntdUI.Button(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.button_close); + this.panel1.Controls.Add(this.windowBar); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Shadow = 6; + this.panel1.Size = new System.Drawing.Size(500, 420); + this.panel1.TabIndex = 0; + this.panel1.Text = "panel1"; + // + // windowBar + // + this.windowBar.Dock = System.Windows.Forms.DockStyle.Top; + this.windowBar.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); + this.windowBar.Location = new System.Drawing.Point(6, 6); + this.windowBar.MaximizeBox = false; + this.windowBar.MinimizeBox = false; + this.windowBar.Name = "windowBar"; + this.windowBar.ShowIcon = false; + this.windowBar.Size = new System.Drawing.Size(488, 32); + this.windowBar.TabIndex = 1; + this.windowBar.Text = "DrawerDemo"; + // + // button_close + // + this.button_close.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); + this.button_close.Location = new System.Drawing.Point(9, 44); + this.button_close.Name = "button_close"; + this.button_close.Size = new System.Drawing.Size(75, 40); + this.button_close.TabIndex = 2; + this.button_close.Text = "关闭"; + this.button_close.Type = AntdUI.TTypeMini.Error; + // + // Demo + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; + this.Controls.Add(this.panel1); + this.Name = "Demo"; + this.Size = new System.Drawing.Size(500, 420); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private AntdUI.Panel panel1; + private AntdUI.WindowBar windowBar; + private AntdUI.Button button_close; + } +} diff --git a/Views/Demo.cs b/Views/Demo.cs new file mode 100644 index 0000000..da1bbb4 --- /dev/null +++ b/Views/Demo.cs @@ -0,0 +1,32 @@ +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 Demo : UserControl + { + public Demo() + { + InitializeComponent(); + BindEventHandler(); + } + + private void BindEventHandler() + { + button_close.Click += button_close_Click; + } + + private void button_close_Click(object sender, EventArgs e) + { + this.Dispose(); + } + } +} diff --git a/Views/Demo.resx b/Views/Demo.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Views/Demo.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Views/DrawerDemo.Designer.cs b/Views/DrawerDemo.Designer.cs new file mode 100644 index 0000000..6858749 --- /dev/null +++ b/Views/DrawerDemo.Designer.cs @@ -0,0 +1,232 @@ +namespace AntdUIDemo.Views +{ + partial class DrawerDemo + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.stackPanel1 = new AntdUI.StackPanel(); + this.label3 = new AntdUI.Label(); + this.divider1 = new AntdUI.Divider(); + this.label2 = new AntdUI.Label(); + this.label1 = new AntdUI.Label(); + this.flowPanel1 = new AntdUI.FlowPanel(); + this.button = new AntdUI.Button(); + this.label4 = new AntdUI.Label(); + this.stackPanel3 = new AntdUI.StackPanel(); + this.select_align = new AntdUI.Select(); + this.label10 = new AntdUI.Label(); + this.switch_mask = new AntdUI.Switch(); + this.label5 = new AntdUI.Label(); + this.switch_mc = new AntdUI.Switch(); + this.label6 = new AntdUI.Label(); + this.stackPanel1.SuspendLayout(); + this.flowPanel1.SuspendLayout(); + this.stackPanel3.SuspendLayout(); + this.SuspendLayout(); + // + // stackPanel1 + // + this.stackPanel1.Controls.Add(this.stackPanel3); + this.stackPanel1.Controls.Add(this.label4); + 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, 327); + this.stackPanel1.TabIndex = 0; + this.stackPanel1.Text = "stackPanel1"; + this.stackPanel1.Vertical = true; + // + // 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 = 28; + 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 = 27; + // + // 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 = 26; + 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 = 25; + this.label1.Text = "Drawer 抽屉"; + // + // flowPanel1 + // + this.flowPanel1.Controls.Add(this.button); + 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 = 29; + this.flowPanel1.Text = "flowPanel1"; + // + // button + // + this.button.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button.Location = new System.Drawing.Point(3, 3); + this.button.Name = "button"; + this.button.Size = new System.Drawing.Size(80, 32); + this.button.TabIndex = 1; + this.button.Text = "Open"; + this.button.Type = AntdUI.TTypeMini.Primary; + this.button.WaveSize = 0; + // + // label4 + // + this.label4.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F); + this.label4.Location = new System.Drawing.Point(3, 171); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(694, 24); + this.label4.TabIndex = 31; + this.label4.Text = "控件配置"; + // + // stackPanel3 + // + this.stackPanel3.Controls.Add(this.switch_mc); + this.stackPanel3.Controls.Add(this.label6); + this.stackPanel3.Controls.Add(this.switch_mask); + this.stackPanel3.Controls.Add(this.label5); + this.stackPanel3.Controls.Add(this.select_align); + this.stackPanel3.Controls.Add(this.label10); + this.stackPanel3.Gap = 6; + this.stackPanel3.Location = new System.Drawing.Point(3, 201); + this.stackPanel3.Name = "stackPanel3"; + this.stackPanel3.Size = new System.Drawing.Size(694, 38); + this.stackPanel3.TabIndex = 32; + this.stackPanel3.Text = "stackPanel3"; + // + // select_align + // + this.select_align.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); + this.select_align.List = true; + this.select_align.Location = new System.Drawing.Point(135, 3); + this.select_align.Name = "select_align"; + this.select_align.Size = new System.Drawing.Size(75, 32); + this.select_align.TabIndex = 5; + this.select_align.WaveSize = 0; + // + // label10 + // + this.label10.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label10.Location = new System.Drawing.Point(3, 3); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(120, 32); + this.label10.TabIndex = 4; + this.label10.Text = "Align"; + // + // switch_mask + // + this.switch_mask.AutoCheck = true; + this.switch_mask.Location = new System.Drawing.Point(354, 3); + this.switch_mask.Name = "switch_mask"; + this.switch_mask.Size = new System.Drawing.Size(60, 32); + this.switch_mask.TabIndex = 7; + this.switch_mask.Text = "switch1"; + // + // 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(222, 3); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(120, 32); + this.label5.TabIndex = 6; + this.label5.Text = "Mask"; + // + // switch_mc + // + this.switch_mc.AutoCheck = true; + this.switch_mc.Location = new System.Drawing.Point(558, 3); + this.switch_mc.Name = "switch_mc"; + this.switch_mc.Size = new System.Drawing.Size(60, 32); + this.switch_mc.TabIndex = 9; + this.switch_mc.Text = "switch1"; + // + // 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(426, 3); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(120, 32); + this.label6.TabIndex = 8; + this.label6.Text = "MaskClosable"; + // + // DrawerDemo + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; + this.Controls.Add(this.stackPanel1); + this.Name = "DrawerDemo"; + this.Size = new System.Drawing.Size(700, 327); + this.stackPanel1.ResumeLayout(false); + this.flowPanel1.ResumeLayout(false); + this.stackPanel3.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private AntdUI.StackPanel stackPanel1; + private AntdUI.Label label3; + private AntdUI.Divider divider1; + private AntdUI.Label label2; + private AntdUI.Label label1; + private AntdUI.FlowPanel flowPanel1; + private AntdUI.Button button; + private AntdUI.Label label4; + private AntdUI.StackPanel stackPanel3; + private AntdUI.Select select_align; + private AntdUI.Label label10; + private AntdUI.Switch switch_mask; + private AntdUI.Label label5; + private AntdUI.Switch switch_mc; + private AntdUI.Label label6; + } +} diff --git a/Views/DrawerDemo.cs b/Views/DrawerDemo.cs new file mode 100644 index 0000000..3576032 --- /dev/null +++ b/Views/DrawerDemo.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using AntdUI; +using AntdUIDemo.Views.Test; + +namespace AntdUIDemo.Views +{ + public partial class DrawerDemo : UserControl + { + private AntdUI.Window window; + public DrawerDemo(AntdUI.Window _window) + { + window = _window; + InitializeComponent(); + //初始化下拉框 + InitSelectItems(); + //设置默认值 + InitData(); + // 绑定事件 + BindEventHandler(); + } + + private void BindEventHandler() + { + button.Click += Button_click; + switch_mask.CheckedChanged += switch_mask_CheckedChanged; + } + + private void switch_mask_CheckedChanged(object sender, BoolEventArgs e) + { + if (e.Value) + { + switch_mc.Enabled = true; + return; + } + //当 mask 为 false 时,maskClosable 无效 + switch_mc.Checked = e.Value; + switch_mc.Enabled = e.Value; + + } + + private void Button_click(object sender, EventArgs e) + { + //TODO:Mask当前版本设置为false时,关闭窗口有bug,不建议关闭 + AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, new Demo() { Size = new Size(500, 300) }) + { + Align = (TAlignMini)select_align.SelectedValue, + Mask = switch_mask.Checked, + //当MaskClosable为false时,需要弹出窗口自己实现关闭,否则无法关闭 + MaskClosable = switch_mc.Checked + }); + } + + private void InitData() + { + select_align.SelectedIndex = 2; + switch_mask.Checked = true; + switch_mc.Checked = true; + } + + private void InitSelectItems() + { + select_align.Items.Clear(); + foreach (TAlignMini align in Enum.GetValues(typeof(TAlignMini))) + { + select_align.Items.Add(align); + } + } + } +} diff --git a/Views/DrawerDemo.resx b/Views/DrawerDemo.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Views/DrawerDemo.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Views/FlowPanelDemo.Designer.cs b/Views/FlowPanelDemo.Designer.cs index e193da0..ff401f2 100644 --- a/Views/FlowPanelDemo.Designer.cs +++ b/Views/FlowPanelDemo.Designer.cs @@ -150,10 +150,9 @@ this.switch_autoscroll.AutoCheck = true; this.switch_autoscroll.Location = new System.Drawing.Point(97, 3); this.switch_autoscroll.Name = "switch_autoscroll"; - this.switch_autoscroll.Size = new System.Drawing.Size(60, 26); + this.switch_autoscroll.Size = new System.Drawing.Size(50, 26); this.switch_autoscroll.TabIndex = 5; this.switch_autoscroll.Text = "switch1"; - this.switch_autoscroll.WaveSize = 0; // // label4 // diff --git a/Views/Table/UserEdit.Designer.cs b/Views/Table/UserEdit.Designer.cs new file mode 100644 index 0000000..49dcc17 --- /dev/null +++ b/Views/Table/UserEdit.Designer.cs @@ -0,0 +1,203 @@ +namespace AntdUIDemo.Views.Table +{ + partial class UserEdit + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.panel1 = new AntdUI.Panel(); + this.stackPanel1 = new AntdUI.StackPanel(); + this.button_ok = new AntdUI.Button(); + this.button_cancel = new AntdUI.Button(); + this.divider1 = new AntdUI.Divider(); + this.input_addr = new AntdUI.Input(); + this.label2 = new AntdUI.Label(); + this.input_age = new AntdUI.InputNumber(); + this.label1 = new AntdUI.Label(); + this.input_name = new AntdUI.Input(); + this.label3 = new AntdUI.Label(); + this.panel1.SuspendLayout(); + this.stackPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.input_addr); + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.input_age); + this.panel1.Controls.Add(this.label1); + this.panel1.Controls.Add(this.input_name); + this.panel1.Controls.Add(this.label3); + this.panel1.Controls.Add(this.divider1); + this.panel1.Controls.Add(this.stackPanel1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Padding = new System.Windows.Forms.Padding(12); + this.panel1.Shadow = 6; + this.panel1.Size = new System.Drawing.Size(500, 386); + this.panel1.TabIndex = 0; + this.panel1.Text = "panel1"; + // + // stackPanel1 + // + this.stackPanel1.Controls.Add(this.button_cancel); + this.stackPanel1.Controls.Add(this.button_ok); + this.stackPanel1.Dock = System.Windows.Forms.DockStyle.Top; + this.stackPanel1.Location = new System.Drawing.Point(18, 18); + this.stackPanel1.Name = "stackPanel1"; + this.stackPanel1.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.stackPanel1.Size = new System.Drawing.Size(464, 44); + this.stackPanel1.TabIndex = 3; + this.stackPanel1.Text = "stackPanel1"; + // + // button_ok + // + this.button_ok.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button_ok.Location = new System.Drawing.Point(3, 3); + this.button_ok.Name = "button_ok"; + this.button_ok.Size = new System.Drawing.Size(75, 38); + this.button_ok.TabIndex = 0; + this.button_ok.Text = "Submit"; + this.button_ok.Type = AntdUI.TTypeMini.Primary; + // + // button_cancel + // + this.button_cancel.BorderWidth = 1F; + this.button_cancel.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); + this.button_cancel.Ghost = true; + this.button_cancel.Location = new System.Drawing.Point(84, 3); + this.button_cancel.Name = "button_cancel"; + this.button_cancel.Size = new System.Drawing.Size(75, 38); + this.button_cancel.TabIndex = 1; + this.button_cancel.Text = "Cancel"; + // + // divider1 + // + this.divider1.Dock = System.Windows.Forms.DockStyle.Top; + this.divider1.Location = new System.Drawing.Point(18, 62); + this.divider1.Name = "divider1"; + this.divider1.Size = new System.Drawing.Size(464, 12); + this.divider1.TabIndex = 14; + // + // input_addr + // + this.input_addr.Dock = System.Windows.Forms.DockStyle.Top; + this.input_addr.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.input_addr.Location = new System.Drawing.Point(18, 222); + this.input_addr.Name = "input_addr"; + this.input_addr.Radius = 3; + this.input_addr.Size = new System.Drawing.Size(464, 38); + this.input_addr.TabIndex = 20; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + 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(18, 198); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(464, 24); + this.label2.TabIndex = 19; + this.label2.Text = "地址"; + // + // input_age + // + this.input_age.Dock = System.Windows.Forms.DockStyle.Top; + this.input_age.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); + this.input_age.Location = new System.Drawing.Point(18, 160); + this.input_age.Maximum = new decimal(new int[] { + 200, + 0, + 0, + 0}); + this.input_age.Minimum = new decimal(new int[] { + 0, + 0, + 0, + 0}); + this.input_age.Name = "input_age"; + this.input_age.Radius = 3; + this.input_age.Size = new System.Drawing.Size(464, 38); + this.input_age.TabIndex = 18; + this.input_age.Text = "0"; + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Location = new System.Drawing.Point(18, 136); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(464, 24); + this.label1.TabIndex = 17; + this.label1.Text = "年龄"; + // + // input_name + // + this.input_name.Dock = System.Windows.Forms.DockStyle.Top; + this.input_name.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.input_name.Location = new System.Drawing.Point(18, 98); + this.input_name.Name = "input_name"; + this.input_name.Radius = 3; + this.input_name.Size = new System.Drawing.Size(464, 38); + this.input_name.TabIndex = 16; + // + // label3 + // + this.label3.Dock = System.Windows.Forms.DockStyle.Top; + 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(18, 74); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(464, 24); + this.label3.TabIndex = 15; + this.label3.Text = "姓名"; + // + // UserEdit + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; + this.Controls.Add(this.panel1); + this.Name = "UserEdit"; + this.Size = new System.Drawing.Size(500, 386); + this.panel1.ResumeLayout(false); + this.stackPanel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private AntdUI.Panel panel1; + private AntdUI.StackPanel stackPanel1; + private AntdUI.Button button_cancel; + private AntdUI.Button button_ok; + private AntdUI.Divider divider1; + private AntdUI.Input input_addr; + private AntdUI.Label label2; + private AntdUI.InputNumber input_age; + private AntdUI.Label label1; + private AntdUI.Input input_name; + private AntdUI.Label label3; + } +} diff --git a/Views/Table/UserEdit.cs b/Views/Table/UserEdit.cs new file mode 100644 index 0000000..1d87c81 --- /dev/null +++ b/Views/Table/UserEdit.cs @@ -0,0 +1,59 @@ +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.Tasks; +using System.Windows.Forms; + +namespace AntdUIDemo.Views.Table +{ + public partial class UserEdit : UserControl + { + private User user; + public UserEdit(User _user) + { + user = _user; + InitializeComponent(); + //设置默认值 + InitData(); + // 绑定事件 + BindEventHandler(); + } + + private void BindEventHandler() + { + button_ok.Click += Button_ok_Click; + button_cancel.Click += Button_cancel_Click; + } + + private void Button_cancel_Click(object sender, EventArgs e) + { + this.Dispose(); + } + + private void Button_ok_Click(object sender, EventArgs e) + { + input_name.Status = AntdUI.TType.None; + //检查输入内容 + if (String.IsNullOrEmpty(input_name.Text)) + { + input_name.Status = AntdUI.TType.Error; + } + user.Name = input_name.Text; + user.Address = input_addr.Text; + user.Age = (int)input_age.Value; + this.Dispose(); + } + + private void InitData() + { + input_name.Text = user.Name; + input_addr.Text = user.Address; + input_age.Value = user.Age; + } + } +} diff --git a/Views/Table/UserEdit.resx b/Views/Table/UserEdit.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Views/Table/UserEdit.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Views/TableDemo.Designer.cs b/Views/TableDemo.Designer.cs index e41d7d7..2f32224 100644 --- a/Views/TableDemo.Designer.cs +++ b/Views/TableDemo.Designer.cs @@ -29,6 +29,7 @@ private void InitializeComponent() { this.stackPanel1 = new AntdUI.StackPanel(); + this.label4 = new AntdUI.Label(); this.table_base = new AntdUI.Table(); this.flowPanel1 = new AntdUI.FlowPanel(); this.checkbox5 = new AntdUI.Checkbox(); @@ -38,14 +39,13 @@ this.checkbox6 = new AntdUI.Checkbox(); this.checkbox1 = new AntdUI.Checkbox(); this.flowPanel3 = new AntdUI.FlowPanel(); + this.buttonCZ = new AntdUI.Button(); this.buttonDEL = new AntdUI.Button(); this.buttonADD = 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.buttonCZ = new AntdUI.Button(); this.stackPanel1.SuspendLayout(); this.flowPanel1.SuspendLayout(); this.flowPanel3.SuspendLayout(); @@ -69,11 +69,22 @@ this.stackPanel1.Text = "stackPanel1"; this.stackPanel1.Vertical = true; // + // 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 = "分页"; + // // table_base // + this.table_base.EmptyHeader = true; 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.ShowTip = false; this.table_base.Size = new System.Drawing.Size(694, 304); this.table_base.TabIndex = 30; this.table_base.Text = "table1"; @@ -171,6 +182,17 @@ this.flowPanel3.TabIndex = 27; this.flowPanel3.Text = "flowPanel3"; // + // buttonCZ + // + this.buttonCZ.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.buttonCZ.Location = new System.Drawing.Point(175, 3); + this.buttonCZ.Name = "buttonCZ"; + this.buttonCZ.Size = new System.Drawing.Size(80, 32); + this.buttonCZ.TabIndex = 6; + this.buttonCZ.Text = "重置"; + this.buttonCZ.Type = AntdUI.TTypeMini.Warn; + this.buttonCZ.WaveSize = 0; + // // buttonDEL // this.buttonDEL.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -227,26 +249,6 @@ 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 = "分页"; - // - // buttonCZ - // - this.buttonCZ.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.buttonCZ.Location = new System.Drawing.Point(175, 3); - this.buttonCZ.Name = "buttonCZ"; - this.buttonCZ.Size = new System.Drawing.Size(80, 32); - this.buttonCZ.TabIndex = 6; - this.buttonCZ.Text = "重置"; - this.buttonCZ.Type = AntdUI.TTypeMini.Warn; - this.buttonCZ.WaveSize = 0; - // // TableDemo // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; diff --git a/Views/TableDemo.cs b/Views/TableDemo.cs index 1d1ed1d..0137a9f 100644 --- a/Views/TableDemo.cs +++ b/Views/TableDemo.cs @@ -1,5 +1,6 @@ using AntdUI; using AntdUIDemo.Models; +using AntdUIDemo.Views.Table; using System; using System.Collections.Generic; using System.ComponentModel; @@ -57,6 +58,105 @@ namespace AntdUIDemo.Views } private void BindEventHandler() + { + buttonDEL.Click += ButtonDEL_Click; + + table_base.CellClick += Table_base_CellClick; + table_base.CellButtonClick += Table_base_CellButtonClick; + } + + private void Table_base_CellClick(object sender, TableClickEventArgs e) + { + var record = e.Record; + if (record is User user) + { + //判断是否右键 + if (e.Button == MouseButtons.Right) + { + AntdUI.ContextMenuStrip.open(new AntdUI.ContextMenuStrip.Config(table_base, + (item) => + { + if (item.Text == "编辑") + { + var form = new UserEdit(user) { Size = new Size(500, 300) }; + AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form) + { + MaskClosable = true, + OnLoad = () => + { + AntdUI.Message.info(window, "进入编辑", autoClose: 1); + }, + OnClose = () => + { + AntdUI.Message.info(window, "结束编辑", autoClose: 1); + } + }); + } + else if (item.Text == "删除") + { + var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn); + if (result == DialogResult.OK) + antList.Remove(user); + } + else + AntdUI.Message.info(window, item.Text, autoClose: 1); + }, + [ + new AntdUI.ContextMenuStripItem("编辑"){ + IconSvg = "", + }, + new AntdUI.ContextMenuStripItem("删除"){ + IconSvg = "" + }, + new ContextMenuStripItemDivider(), + new AntdUI.ContextMenuStripItem("详情"){ + Sub = [ new AntdUI.ContextMenuStripItem("打印", "Ctrl + P") { }, + new AntdUI.ContextMenuStripItem("另存为", "Ctrl + S") { } ], + IconSvg = "", + } + ])); + } + } + } + + //表格内部按钮事件 + private void Table_base_CellButtonClick(object sender, TableButtonEventArgs e) + { + var buttontext = e.Btn.Text; + + if (e.Record is User user) + { + switch (buttontext) + { + //暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据 + case "编辑": + var form = new UserEdit(user) { Size = new Size(500, 300) }; + AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form) + { + MaskClosable = true, + OnLoad = () => + { + AntdUI.Message.info(window, "进入编辑", autoClose: 1); + }, + OnClose = () => + { + AntdUI.Message.info(window, "结束编辑", autoClose: 1); + } + }); + break; + case "删除": + var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn); + if (result == DialogResult.OK) + antList.Remove(user); + break; + case "AntdUI": + AntdUI.Message.info(window, user.CellLinks.FirstOrDefault().Id, autoClose: 1); + break; + } + } + } + + private void ButtonDEL_Click(object sender, EventArgs e) { } @@ -73,7 +173,7 @@ namespace AntdUIDemo.Views Selected = false, Name = "张三", Age = 30, - Address = "浙江省杭州市西湖区湖底公园1号", + Address = $"浙江省杭州市西湖区湖底公园{i + 1}号", Enabled = i % 2 == 0, //CellImages = [new CellImage(Properties.Resources.bg1)], CellTags = [new CellTag("测试", TTypeMini.Primary), new CellTag("测试", TTypeMini.Success), new CellTag("测试", TTypeMini.Warn)], @@ -84,7 +184,7 @@ namespace AntdUIDemo.Views PrefixSvg = "" }, CellLinks = [new CellLink("https://gitee.com/antdui/AntdUI", "AntdUI"), - new CellButton(i.ToString(),"修改",TTypeMini.Primary), + new CellButton(i.ToString(),"编辑",TTypeMini.Primary), new CellButton(i.ToString(),"删除",TTypeMini.Error)], //value:0-1 CellProgress = new CellProgress(0.5f), diff --git a/Views/Test/TestDemo.Designer.cs b/Views/Test/TestDemo.Designer.cs new file mode 100644 index 0000000..6cb3971 --- /dev/null +++ b/Views/Test/TestDemo.Designer.cs @@ -0,0 +1,189 @@ +namespace AntdUIDemo.Views.Test +{ + partial class TestDemo + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.flowPanel1 = new AntdUI.FlowPanel(); + this.button1 = new AntdUI.Button(); + this.button2 = new AntdUI.Button(); + this.button3 = new AntdUI.Button(); + this.button4 = new AntdUI.Button(); + this.button5 = new AntdUI.Button(); + this.button6 = new AntdUI.Button(); + this.button7 = new AntdUI.Button(); + this.button8 = new AntdUI.Button(); + this.button9 = new AntdUI.Button(); + this.button10 = new AntdUI.Button(); + this.flowPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // flowPanel1 + // + this.flowPanel1.Controls.Add(this.button10); + this.flowPanel1.Controls.Add(this.button9); + this.flowPanel1.Controls.Add(this.button8); + this.flowPanel1.Controls.Add(this.button7); + this.flowPanel1.Controls.Add(this.button6); + this.flowPanel1.Controls.Add(this.button5); + this.flowPanel1.Controls.Add(this.button4); + this.flowPanel1.Controls.Add(this.button3); + this.flowPanel1.Controls.Add(this.button2); + this.flowPanel1.Controls.Add(this.button1); + this.flowPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowPanel1.Location = new System.Drawing.Point(0, 0); + this.flowPanel1.Name = "flowPanel1"; + this.flowPanel1.Size = new System.Drawing.Size(500, 257); + this.flowPanel1.TabIndex = 0; + this.flowPanel1.Text = "flowPanel1"; + // + // button1 + // + this.button1.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button1.Location = new System.Drawing.Point(13, 3); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(114, 40); + this.button1.TabIndex = 0; + this.button1.Text = "Button"; + this.button1.Type = AntdUI.TTypeMini.Primary; + // + // 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(133, 3); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(114, 40); + this.button2.TabIndex = 1; + this.button2.Text = "Button"; + this.button2.Type = AntdUI.TTypeMini.Primary; + // + // button3 + // + this.button3.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button3.Location = new System.Drawing.Point(253, 3); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(114, 40); + this.button3.TabIndex = 2; + this.button3.Text = "Button"; + this.button3.Type = AntdUI.TTypeMini.Primary; + // + // button4 + // + this.button4.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button4.Location = new System.Drawing.Point(373, 3); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(114, 40); + this.button4.TabIndex = 3; + this.button4.Text = "Button"; + this.button4.Type = AntdUI.TTypeMini.Primary; + // + // 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(13, 49); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(114, 40); + this.button5.TabIndex = 4; + this.button5.Text = "Button"; + this.button5.Type = AntdUI.TTypeMini.Primary; + // + // button6 + // + this.button6.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button6.Location = new System.Drawing.Point(133, 49); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(114, 40); + this.button6.TabIndex = 5; + this.button6.Text = "Button"; + this.button6.Type = AntdUI.TTypeMini.Primary; + // + // button7 + // + this.button7.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button7.Location = new System.Drawing.Point(253, 49); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(114, 40); + this.button7.TabIndex = 6; + this.button7.Text = "Button"; + this.button7.Type = AntdUI.TTypeMini.Primary; + // + // button8 + // + this.button8.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button8.Location = new System.Drawing.Point(373, 49); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(114, 40); + this.button8.TabIndex = 7; + this.button8.Text = "Button"; + this.button8.Type = AntdUI.TTypeMini.Primary; + // + // button9 + // + this.button9.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button9.Location = new System.Drawing.Point(13, 95); + this.button9.Name = "button9"; + this.button9.Size = new System.Drawing.Size(114, 40); + this.button9.TabIndex = 8; + this.button9.Text = "Button"; + this.button9.Type = AntdUI.TTypeMini.Primary; + // + // button10 + // + this.button10.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.button10.Location = new System.Drawing.Point(133, 95); + this.button10.Name = "button10"; + this.button10.Size = new System.Drawing.Size(114, 40); + this.button10.TabIndex = 9; + this.button10.Text = "Button"; + this.button10.Type = AntdUI.TTypeMini.Primary; + // + // TestDemo + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; + this.Controls.Add(this.flowPanel1); + this.Name = "TestDemo"; + this.Size = new System.Drawing.Size(500, 257); + this.flowPanel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private AntdUI.FlowPanel flowPanel1; + private AntdUI.Button button4; + private AntdUI.Button button3; + private AntdUI.Button button2; + private AntdUI.Button button1; + private AntdUI.Button button10; + private AntdUI.Button button9; + private AntdUI.Button button8; + private AntdUI.Button button7; + private AntdUI.Button button6; + private AntdUI.Button button5; + } +} diff --git a/Views/Test/TestDemo.cs b/Views/Test/TestDemo.cs new file mode 100644 index 0000000..3f9797c --- /dev/null +++ b/Views/Test/TestDemo.cs @@ -0,0 +1,20 @@ +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.Test +{ + public partial class TestDemo : UserControl + { + public TestDemo() + { + InitializeComponent(); + } + } +} diff --git a/Views/Test/TestDemo.resx b/Views/Test/TestDemo.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Views/Test/TestDemo.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file