From 3cf5ed85bc70cc7264c6538e732f3d0cbeccc0e9 Mon Sep 17 00:00:00 2001 From: Tom <17379620@qq.com> Date: Thu, 8 Jan 2026 22:26:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BE=20=E4=BC=98=E5=8C=96=20Popover=20?= =?UTF-8?q?=E8=A7=86=E8=A7=89=E6=B5=81=E7=95=85=E3=80=81Table=20=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E9=80=82=E9=85=8D=E7=A9=BA=E7=99=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AntdUI/Controls/Table/FilterControl.cs | 23 +++++-- src/AntdUI/Controls/Table/Table.Filter.cs | 62 +++++-------------- src/AntdUI/Controls/Table/Table.Mouse.cs | 2 +- .../Forms/LayeredWindow/LayeredFormPopover.cs | 11 ++-- 4 files changed, 40 insertions(+), 58 deletions(-) diff --git a/src/AntdUI/Controls/Table/FilterControl.cs b/src/AntdUI/Controls/Table/FilterControl.cs index f5bae7dd..c3132281 100644 --- a/src/AntdUI/Controls/Table/FilterControl.cs +++ b/src/AntdUI/Controls/Table/FilterControl.cs @@ -20,8 +20,6 @@ namespace AntdUI public const string SVG_LESS = ""; public const string SVG_CONTAIN = ""; - string BLANK_FIELD = Localization.Get("Filter.Blank", "(空白)"); - #region Ctor IList? CustomSource; @@ -36,8 +34,8 @@ namespace AntdUI realTime = table.FilterRealTime; dv.VirtualMode = table.VirtualMode; dv.Columns = new ColumnCollection { new ColumnCheck("check"), new Column("text", "(全选)").SetLocalizationTitle("Filter.SelectAll") }; - if (Option.Table == null) Option.Table = table; - if (Option.Column == null) Option.Column = currentColumn; + Option.Table = table; + Option.Column = currentColumn; inputSearch.PlaceholderText = Localization.Get("Filter.Search", "搜索") + " " + currentColumn.Title; InitConditions(); InitFilterEdit(); @@ -68,6 +66,7 @@ namespace AntdUI var edit = new Select { Margin = new Padding(0), + PlaceholderText = Localization.Get("Filter", "筛选"), Dock = DockStyle.Fill, List = true, AutoPrefixSvg = true @@ -90,6 +89,7 @@ namespace AntdUI var edit = new InputNumber { Margin = new Padding(0), + PlaceholderText = Localization.Get("Filter", "筛选"), Dock = DockStyle.Fill, DecimalPlaces = type == typeof(int) || type == typeof(short) || type == typeof(long) ? 0 : 7 }; @@ -107,6 +107,7 @@ namespace AntdUI var edit = new DatePicker { Margin = new Padding(0), + PlaceholderText = Localization.Get("Filter", "筛选"), Dock = DockStyle.Fill }; tablePanel.Controls.Add(edit, 1, 0); @@ -140,6 +141,7 @@ namespace AntdUI var edit = new Input { Margin = new Padding(0), + PlaceholderText = Localization.Get("Filter", "筛选"), Dock = DockStyle.Fill }; tablePanel.Controls.Add(edit, 1, 0); @@ -164,6 +166,7 @@ namespace AntdUI var items = new List(count); var selects = GetColumnSelect(); var dir = new Dictionary>(count); + AntItem[]? item_null = null; foreach (var val in values) { bool check = list.Contains(val); @@ -172,7 +175,11 @@ namespace AntdUI if (value == null) { if (Option.AllowNull == false) continue; - items.Add(new AntItem[] { new AntItem("tag", value), new AntItem("check", false), new AntItem("text", BLANK_FIELD) }); + if (item_null == null) + { + item_null = new AntItem[] { new AntItem("tag"), new AntItem("check", check), new AntItem("text", new CellText().SetText("(空白)", "Filter.Blank").SetFore(Style.Db.TextTertiary)) }; + items.Add(item_null); + } } else { @@ -569,7 +576,11 @@ namespace AntdUI var tmp = new List(list.Count); foreach (var it in list) { - if (it[1].value is bool check && check && it[0].value is List data) tmp.AddRange(data); + if (it[1].value is bool check && check) + { + if (it[0].value is List data) tmp.AddRange(data); + else tmp.Add(null); + } } if (tmp.Count == _table.dataTmp.RowsCache.Length) Option.FilterValues = null; else Option.FilterValues = tmp; diff --git a/src/AntdUI/Controls/Table/Table.Filter.cs b/src/AntdUI/Controls/Table/Table.Filter.cs index b34c517d..2a7e05dc 100644 --- a/src/AntdUI/Controls/Table/Table.Filter.cs +++ b/src/AntdUI/Controls/Table/Table.Filter.cs @@ -131,11 +131,6 @@ namespace AntdUI dataTmp.ClearFilter(); return; } - var dir = new Dictionary>(columns.Count); - foreach (var col in columns) - { - if (col.Visible && col.Filter != null && col.Filter.Enabled) dir.Add(col.Key, col.Filter.FilterValues!); - } dataTmp.rowsFilter = IFilterList(); FilterDataChanged?.Invoke(this, new TableFilterDataChangedEventArgs(FilterList())); OnUpdateSummaries(); @@ -170,6 +165,7 @@ namespace AntdUI // 检查单元格值是否存在于筛选值列表中 foreach (var filterValue in filterValues) { + if (filterValue == null && cellValue == null) return true; if (filterValue?.Equals(cellValue) ?? false) return true; } return false; @@ -257,56 +253,28 @@ namespace AntdUI internal void UpdateFilter() => Table?.UpdateFilter(); /// - /// 外部应用筛选 (当前列) + /// 外部应用筛选 /// - /// 条件 - /// 单个筛选值 - public bool Apply(FilterConditions condition, object filterValue) + /// 单个筛选值(列数据) + public bool Apply(object filterValue) => Apply(new object[] { filterValue }); + + /// + /// 外部应用筛选 + /// + /// 筛选值(列数据) + public bool Apply(params object[] filterValues) { - if (Column == null) return false; - object[] filterValues = new object[] { filterValue }; - return Apply(Column, condition, filterValues); + FilterValues = new List(filterValues); + UpdateFilter(); + return Enabled; } /// /// 外部应用筛选 /// - /// 筛选列 - /// 条件 - /// 单个筛选值 - public bool Apply(Column column, FilterConditions condition, object filterValue) + /// 筛选值(列数据) + public bool Apply(IList filterValues) { - object[] filterValues = new object[] { filterValue }; - return Apply(column, condition, filterValues); - } - - /// - /// 外部应用筛选 (当前列) - /// - /// 条件 - /// 筛选值 - /// - public bool Apply(FilterConditions condition, object[] filterValues) - { - if (Column == null) return false; - return Apply(Column, condition, filterValues); - } - - /// - /// 外部应用筛选 - /// - /// 筛选列 - /// 条件 - /// 筛选值 - /// - public bool Apply(Column column, FilterConditions condition, object[] filterValues) - { - if (column == null || condition == FilterConditions.None) return false; - - Column = column; - Table = column.PARENT; - - Condition = condition; FilterValues = new List(filterValues); UpdateFilter(); return Enabled; diff --git a/src/AntdUI/Controls/Table/Table.Mouse.cs b/src/AntdUI/Controls/Table/Table.Mouse.cs index 6c98d27c..5c823e15 100644 --- a/src/AntdUI/Controls/Table/Table.Mouse.cs +++ b/src/AntdUI/Controls/Table/Table.Mouse.cs @@ -460,7 +460,7 @@ namespace AntdUI } else if (it.row.IsColumn && it.cell is TCellColumn col) { - if (it.cell.COLUMN.Filter != null&& col.rect_filter.Contains(db.x - col.offsetx, db.y - col.offsety)) + if (it.cell.COLUMN.Filter != null && col.rect_filter.Contains(db.x - col.offsetx, db.y - col.offsety)) { //点击筛选 var focusColumn = it.cell.COLUMN; diff --git a/src/AntdUI/Forms/LayeredWindow/LayeredFormPopover.cs b/src/AntdUI/Forms/LayeredWindow/LayeredFormPopover.cs index c19dd4a5..cd7439c7 100644 --- a/src/AntdUI/Forms/LayeredWindow/LayeredFormPopover.cs +++ b/src/AntdUI/Forms/LayeredWindow/LayeredFormPopover.cs @@ -60,10 +60,13 @@ namespace AntdUI } } rectContent.Offset(shadow, shadow); - tempContent = new Bitmap(control.Width, control.Height); - control.Size = new Size(tempContent.Width, tempContent.Height); - control.DrawToBitmap(tempContent, new Rectangle(0, 0, tempContent.Width, tempContent.Height)); + control.Size = new Size(control.Width, control.Height); SetSize(w + paddingx2, h + paddingy2); + BeginInvoke(() => + { + tempContent = new Bitmap(control.Width, control.Height); + control.DrawToBitmap(tempContent, new Rectangle(0, 0, tempContent.Width, tempContent.Height)); + }); } else if (config.Content is IList list) { @@ -205,6 +208,7 @@ namespace AntdUI var fsize = new Size(rectContent.Width, rectContent.Height); form = new DoubleBufferForm(this, control, config.Focus) { + StartPosition = FormStartPosition.Manual, FormBorderStyle = FormBorderStyle.None, Location = flocation, MaximumSize = fsize, @@ -213,7 +217,6 @@ namespace AntdUI }; control.Disposed += Control_Disposed; form.Show(this); - form.Location = flocation; PARENT = form; parent = control.FindPARENT(); config.OnControlLoad?.Invoke();