From d7936ea8138f097cb3e473327ddb8ec6b1843522 Mon Sep 17 00:00:00 2001 From: czz_y Date: Thu, 21 Nov 2024 00:01:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A71.7.5=EF=BC=8CSlider=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=83=8C=E6=99=AF=E6=9D=A1=E9=A2=9C=E8=89=B2=EF=BC=8C?= =?UTF-8?q?Spin=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9=EF=BC=8CUploadDragger?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9=EF=BC=8C?= =?UTF-8?q?Table=E6=94=AF=E6=8C=81=E6=A0=91=E8=8A=82=E7=82=B9=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AntdUIDemo.csproj | 4 +- README.md | 2 +- Views/SliderDemo.Designer.cs | 1 + Views/SpinDemo.cs | 71 ++++++++++++++++++++++++++++-------- Views/TableDemo.cs | 40 +++++++++++++++----- Views/UploadDraggerDemo.cs | 2 +- 6 files changed, 91 insertions(+), 29 deletions(-) diff --git a/AntdUIDemo.csproj b/AntdUIDemo.csproj index e6ad0e2..cd56c49 100644 --- a/AntdUIDemo.csproj +++ b/AntdUIDemo.csproj @@ -13,7 +13,7 @@ Copyright © 2024 czz_y $(Version) $(Version) - 1.7.4 + 1.7.5 czz_y 基于 Winform UI 框架 AntdUI 设计的 Demo https://gitee.com/mubaiyanghua/antd-uidemo @@ -30,7 +30,7 @@ - + diff --git a/README.md b/README.md index 2678f64..3c7bb58 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

AntdUI Demo

-本项目基于 `Winform .NET Framework 4.8` 开发,是 [AntdUI](https://gitee.com/antdui/AntdUI) 的 Demo 项目,当前版本 `1.7.4` +本项目基于 `Winform .NET Framework 4.8` 开发,是 [AntdUI](https://gitee.com/antdui/AntdUI) 的 Demo 项目,当前版本 `1.7.5` diff --git a/Views/SliderDemo.Designer.cs b/Views/SliderDemo.Designer.cs index 2584648..b052f63 100644 --- a/Views/SliderDemo.Designer.cs +++ b/Views/SliderDemo.Designer.cs @@ -266,6 +266,7 @@ this.slider2.Size = new System.Drawing.Size(200, 32); this.slider2.TabIndex = 1; this.slider2.Text = "slider2"; + this.slider2.TrackColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(244))))); this.slider2.Value = 50; // // slider1 diff --git a/Views/SpinDemo.cs b/Views/SpinDemo.cs index cbf37d0..ff096be 100644 --- a/Views/SpinDemo.cs +++ b/Views/SpinDemo.cs @@ -1,4 +1,5 @@ -using System; +using AntdUI; +using System; using System.Drawing; using System.Threading; using System.Windows.Forms; @@ -27,15 +28,20 @@ namespace AntdUIDemo.Views private void Button_control_Click(object sender, EventArgs e) { - AntdUI.Spin.open(label_spin, new AntdUI.Spin.Config() + AntdUI.Spin.open(label_spin, new Spin.Config() { Back = Color.FromArgb(220, 147, 181, 207), - Color = Color.White, + Color = Style.Db.Primary,//转圈颜色 Radius = 6, + Font = new Font("Microsoft YaHei UI", 7f),//字体可以控制进度圈的大小 + + }, (config) => + { + //耗时代码,处理数据 + Thread.Sleep(3000); }, () => { - //耗时代码,加载数据 - Thread.Sleep(1000); + //结束时执行的代码 }); } @@ -44,12 +50,28 @@ namespace AntdUIDemo.Views AntdUI.Spin.open(window, new AntdUI.Spin.Config() { Back = Color.FromArgb(220, 147, 181, 207), - Color = Color.White, + Color = Style.Db.Primary,//转圈颜色 Radius = 6, + Fore = Color.Black,//字体颜色 + Font = new Font("Microsoft YaHei UI", 14f),//字体可以控制进度圈的大小 + }, (config) => + { + //耗时代码,处理数据 + config.Text = "正在处理中,当前进度0%..."; + Thread.Sleep(1000); + //value范围:0-1 + config.Value = 0.2f; + config.Text = "正在处理中,当前进度20%..."; + Thread.Sleep(1000); + config.Value = 0.5f; + config.Text = "正在处理中,当前进度50%..."; + Thread.Sleep(1000); + config.Value = 1.0f; + config.Text = "处理完成!"; + Thread.Sleep(1000); }, () => { - //耗时代码,加载数据 - Thread.Sleep(1000); + //结束时执行的代码 }); } @@ -58,27 +80,46 @@ namespace AntdUIDemo.Views AntdUI.Spin.open(this, new AntdUI.Spin.Config() { Back = Color.FromArgb(220, 147, 181, 207), - Color = Color.White, + Color = Style.Db.Primary,//转圈颜色 Radius = 6, + Fore = Color.Black,//字体颜色 + Font = new Font("Microsoft YaHei UI", 14f),//字体可以控制进度圈的大小 + }, (config) => + { + //耗时代码,处理数据 + config.Text = "正在处理中,当前进度0%..."; + Thread.Sleep(1000); + //value范围:0-1 + config.Value = 0.2f; + config.Text = "正在处理中,当前进度20%..."; + Thread.Sleep(1000); + config.Value = 0.5f; + config.Text = "正在处理中,当前进度50%..."; + Thread.Sleep(1000); + config.Value = 1.0f; + config.Text = "处理完成!"; + Thread.Sleep(1000); }, () => { - //耗时代码,加载数据 - Thread.Sleep(1000); + //结束时执行的代码 }); } private void Button_base_Click(object sender, EventArgs e) { - //匿名委托 AntdUI.Spin.open(flowPanel1, new AntdUI.Spin.Config() { Back = Color.FromArgb(220, 147, 181, 207), - Color = Color.White, + Color = Style.Db.Primary,//转圈颜色 Radius = 6, + Font = new Font("Microsoft YaHei UI", 7f),//字体可以控制进度圈的大小 + }, (config) => + { + //耗时代码,处理数据 + Thread.Sleep(3000); }, () => { - //耗时代码,加载数据 - Thread.Sleep(1000); + //结束时执行的代码 }); } } diff --git a/Views/TableDemo.cs b/Views/TableDemo.cs index 1440ad7..4255b0a 100644 --- a/Views/TableDemo.cs +++ b/Views/TableDemo.cs @@ -152,6 +152,7 @@ namespace AntdUIDemo.Views //判断是否右键 if (e.Button == MouseButtons.Right) { + if (antList.Count == 0) return; AntdUI.ContextMenuStrip.open(new AntdUI.ContextMenuStrip.Config(table_base, (item) => { @@ -183,21 +184,42 @@ namespace AntdUIDemo.Views var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn); if (result == DialogResult.OK) { - if (antList.Any(antitem => antitem.Selected = true)) + //父元素没有勾选或者子元素也没有勾选,则删除当前行 + bool delCurrent = !antList.Any(x => x.Selected || (x.Users?.Any(u => u.Selected) ?? false)); + + if (delCurrent) { - //使用反转for循环删除 - for (int i = antList.Count - 1; i >= 0; i--) + //删除当前行,先判断是否父元素,再判断是否子元素,只支持一层子元素,需实现嵌套查询 + for (int i = 0; i < antList.Count; i++) { - if (antList[i].Selected) + if (antList[i] == user) { - antList.Remove(antList[i]); + antList.RemoveAt(i); + } + else + { + antList[i].Users = antList[i].Users?.Where(x => x != user).ToArray(); } } } else { - antList.Remove(user); + // 使用反转for循环删除主列表中选中的项 + for (int i = antList.Count - 1; i >= 0; i--) + { + // 1.删除选中的主列表项 + if (antList[i].Selected) + { + antList.RemoveAt(i); + } + else + { + // 删除子列表中选中的项 + antList[i].Users = antList[i].Users?.Where(childUser => !childUser.Selected).ToArray(); + } + } } + } } else @@ -273,7 +295,7 @@ namespace AntdUIDemo.Views // 判断子元素是否勾选 for (int i = 0; i < antList.Count; i++) { - if (antList[i].Users !=null && antList[i].Users.Any(x => x.Selected)) + if (antList[i].Users != null && antList[i].Users.Any(x => x.Selected)) { isSubSelected = true; break; @@ -303,8 +325,6 @@ namespace AntdUIDemo.Views antList[i].Users = antList[i].Users?.Where(user => !user.Selected).ToArray(); } } - //BUG:删除树节点数据需要重新绑定才刷新 - table_base.Binding(antList); // 提示删除完成 AntdUI.Message.success(window, "删除成功!", autoClose: 3); } @@ -358,7 +378,7 @@ namespace AntdUIDemo.Views IconRatio = 0.5f, PrefixSvg = "" }, - CellLinks = new CellLink[] {new CellLink("https://gitee.com/antdui/AntdUI", "AntdUI")}, + CellLinks = new CellLink[] { new CellLink("https://gitee.com/antdui/AntdUI", "AntdUI") }, //value:0-1 CellProgress = new CellProgress(1f), CellDivider = new CellDivider(), diff --git a/Views/UploadDraggerDemo.cs b/Views/UploadDraggerDemo.cs index 3dbfb6a..8cbeaf9 100644 --- a/Views/UploadDraggerDemo.cs +++ b/Views/UploadDraggerDemo.cs @@ -41,7 +41,7 @@ namespace AntdUIDemo.Views } } - private void UploadDragger_DragChanged(object sender, AntdUI.UploadDragger.StringsEventArgs e) + private void UploadDragger_DragChanged(object sender, AntdUI.StringsEventArgs e) { string[] filePaths = e.Value; foreach (string path in filePaths)