👾 修复 下拉弹窗 低质量

This commit is contained in:
Tom
2025-07-10 17:46:59 +08:00
parent ec16b6f3bb
commit 95d2e29402
25 changed files with 281 additions and 470 deletions

View File

@@ -18,7 +18,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
@@ -36,7 +35,7 @@ namespace Demo.Controls
table1.Columns = new AntdUI.ColumnCollection {
new AntdUI.ColumnCheck("check").SetFixed(),
new AntdUI.Column("name", "<22><><EFBFBD><EFBFBD>").SetFixed().SetLocalizationTitleID("Table.Column.").SetDefaultFilter(),
new AntdUI.Column("name", "<22><><EFBFBD><EFBFBD>").SetFixed().SetLocalizationTitleID("Table.Column."),
new AntdUI.ColumnCheck("checkTitle", "<22><>ȫѡ<C8AB><D1A1><EFBFBD><EFBFBD>").SetColAlign().SetLocalizationTitleID("Table.Column."),
new AntdUI.ColumnRadio("radio", "<22><>ѡ").SetLocalizationTitleID("Table.Column."),
new AntdUI.Column("online", "״̬", AntdUI.ColumnAlign.Center).SetLocalizationTitleID("Table.Column."),
@@ -48,9 +47,9 @@ namespace Demo.Controls
return value;
}
},
new AntdUI.Column("age", "<22><><EFBFBD><EFBFBD>").SetAlign().SetLocalizationTitleID("Table.Column.").SetDefaultFilter(typeof(int)),
new AntdUI.Column("address", "סַ").SetLocalizationTitleID("Table.Column.").SetDefaultFilter(),
new AntdUI.Column("date", "<22><><EFBFBD><EFBFBD>").SetLocalizationTitleID("Table.Column.").SetDefaultFilter(typeof(DateTime)).SetDisplayFormat("D"),
new AntdUI.Column("age", "<22><><EFBFBD><EFBFBD>").SetAlign().SetLocalizationTitleID("Table.Column."),
new AntdUI.Column("address", "סַ").SetLocalizationTitleID("Table.Column."),
new AntdUI.Column("date", "<22><><EFBFBD><EFBFBD>").SetLocalizationTitleID("Table.Column."),
new AntdUI.Column("tag", "Tag"),
new AntdUI.Column("imgs", "ͼƬ").SetLocalizationTitleID("Table.Column."),
new AntdUI.Column("btns", "<22><><EFBFBD><EFBFBD>").SetFixed().SetWidth("auto").SetLocalizationTitleID("Table.Column."),
@@ -72,59 +71,12 @@ namespace Demo.Controls
foreach (var it in editStyle) editStyles.Add(new AntdUI.SelectItem(it));
editStyles.RemoveAt(0);
selectEditStyle.Items.AddRange(editStyles.ToArray());
table1.CellPaintBegin += Table1_CellPaintBegin;
table1.FilterPopupEnd += Table1_FilterPopupEnd;
table1.FilterDataChanged += Table1_FilterDataChanged;
}
#region ʾ<EFBFBD><EFBFBD>
private void Table1_CellPaintBegin(object sender, AntdUI.TablePaintBeginEventArgs e)
{
if (e.Column == table1.Columns["name"])
{
TestClass item = e.Record as TestClass;
if (item.name == "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
{
//<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
e.CellFont = new Font(table1.Font, FontStyle.Bold);
e.CellFore = Color.Green;
e.CellBack = new System.Drawing.Drawing2D.LinearGradientBrush(e.Rect, Color.Transparent, Color.FromArgb(100, AntdUI.Style.Db.PrimaryActive), 90f);
}
}
else if (e.Column == table1.Columns["tag"])
{
//<2F>Զ<EFBFBD><D4B6>嵥Ԫ<E5B5A5><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
TestClass item = e.Record as TestClass;
if (item.id == -1) return;
if (item.age < 1) return;
RectangleF rect = e.Rect;
rect.Offset(1, 1);
rect.Inflate(-1, -1);
rect.Width = ((float)item.age / 100) * e.Rect.Width; //test
using (System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(rect, Color.LightYellow, Color.YellowGreen, 0, true))
{
e.g.Fill(brush, rect);
}
}
}
private void Table1_FilterPopupEnd(object sender, AntdUI.TableFilterPopupEndEventArgs e)
{
AntdUI.Notification.info(form, ѡ<C9B8><D1A1><EFBFBD><EFBFBD>", $"<22><>ɸѡ<C9B8><D1A1> {(e.Records == null ? 0 : e.Records.Length)} <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", AntdUI.TAlignFrom.Top);
}
private void Table1_FilterDataChanged(object sender, AntdUI.TableFilterDataChangedEventArgs e)
{
if (e.Records == null || e.Records.Length == 0)
{
table1.Summary = null;
return;
}
table1.Summary=GetPageSummaryData(e.Records);
}
void checkFixedHeader_CheckedChanged(object sender, AntdUI.BoolEventArgs e)
{
table1.FixedHeader = e.Value;
@@ -342,29 +294,31 @@ namespace Demo.Controls
DateTime birthday_DanielWu = new DateTime(1974, 9, 30);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>https://baike.baidu.com/link?url=zk3KO7qvnfny-fZ2QfgQ2-lZleCeNUaCfketfcE6Ur5p_LowHOhlttu0c4tEXDKN673QcgpSRRRUmymic58Rf5NiUpsMJrctl1SXaR2RXuu
list.Add(new TestClass(start, 0, AntdUI.Localization.Get("Table.Data.Name1", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), (int)Math.Round((now - birthday_TigerHu).TotalDays / 365)));
list.Add(new TestClass(start + 1, 1, AntdUI.Localization.Get("Table.Data.Name2", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), 18)
list.Add(new TestClass(start + 1, 1, AntdUI.Localization.Get("Table.Data.Name2", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), (int)Math.Round((now - birthday_DanielWu).TotalDays / 365))
{
tag = new AntdUI.CellTag[] { new AntdUI.CellTag("NICE", AntdUI.TTypeMini.Success), new AntdUI.CellTag("DEVELOPER", AntdUI.TTypeMini.Info) }
});
for (int i = 2; i < pageSize; i++)
{
int index = start + i;
list.Add(new TestClass(index, i, AntdUI.Localization.Get("Table.Data.Name3", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), new Random().Next(88) + index));
list.Add(new TestClass(index, i, AntdUI.Localization.Get("Table.Data.Name3", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), 20 + index));
}
return list;
}
object GetPageSummaryData(object[]? source)
object GetPageSummaryData(object[] source)
{
// if (BatchCurrent == null) return null;
if (source == null) return null;
int totalAge = 0;
foreach (TestClass item in source)
foreach (TestClass item in source) totalAge += item.age;
return new
{
totalAge += item.age;
}
return new TestClass(-1, -1, "ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", totalAge/source.Length);
name = "ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
age = totalAge / source.Length
};
}
void pagination1_ValueChanged(object sender, AntdUI.PagePageEventArgs e)
{
table1.DataSource = GetPageData(e.Current, e.PageSize);
@@ -375,6 +329,21 @@ namespace Demo.Controls
}
#endregion
void Table1_FilterPopupEnd(object sender, AntdUI.TableFilterPopupEndEventArgs e)
{
AntdUI.Notification.info(form, ѡ<C9B8><D1A1><EFBFBD><EFBFBD>", $"<22><>ɸѡ<C9B8><D1A1> {(e.Records == null ? 0 : e.Records.Length)} <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", AntdUI.TAlignFrom.Top);
}
void Table1_FilterDataChanged(object sender, AntdUI.TableFilterDataChangedEventArgs e)
{
if (e.Records == null || e.Records.Length == 0)
{
table1.Summary = null;
return;
}
table1.Summary = GetPageSummaryData(e.Records);
}
public class TestColumn : AntdUI.TemplateColumn
{
@@ -386,14 +355,6 @@ namespace Demo.Controls
{
public TestClass(int index, int start, string name, int age)
{
if(index==-1)
{
id = -1;
_name = name;
_age = age;
return;
}
id = (index + 1);
if (start == 1) _online = new AntdUI.CellBadge(AntdUI.TState.Success, AntdUI.Localization.Get("Table.Data.Online", "<22><><EFBFBD><EFBFBD>"));
else if (start == 2) _online = new AntdUI.CellBadge(AntdUI.TState.Processing, AntdUI.Localization.Get("Table.Data.Online.Processing", "<22><><EFBFBD><EFBFBD>"));
@@ -402,7 +363,7 @@ namespace Demo.Controls
else _online = new AntdUI.CellBadge(AntdUI.TState.Default, AntdUI.Localization.Get("Table.Data.Online.Default", "<22><><EFBFBD><EFBFBD>"));
_name = name;
_age = age;
if (age != 18) _date = DateTime.Now.AddYears(-age);//<2F><><EFBFBD>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD><EFBFBD>
_date = DateTime.Now.Date.AddYears(-age);
_address = AntdUI.Localization.GetLangI("Table.Data.Address" + id, null);
if (_address == null) _address = AntdUI.Localization.GetLangI("Table.Data.AddressNum", null);
@@ -465,10 +426,10 @@ namespace Demo.Controls
else _btns = new AntdUI.CellLink[] { new AntdUI.CellLink("delete", "Delete") };
}
public int? id { get; set; }
public int id { get; set; }
bool? _check;
public bool? check
bool _check = false;
public bool check
{
get => _check;
set
@@ -479,8 +440,8 @@ namespace Demo.Controls
}
}
bool? _radio;
public bool? radio
bool _radio = false;
public bool radio
{
get => _radio;
set
@@ -491,8 +452,8 @@ namespace Demo.Controls
}
}
bool? _checkTitle;
public bool? checkTitle
bool _checkTitle = false;
public bool checkTitle
{
get => _checkTitle;
set
@@ -503,8 +464,8 @@ namespace Demo.Controls
}
}
string? _name;
public string? name
string _name;
public string name
{
get => _name;
set
@@ -515,8 +476,8 @@ namespace Demo.Controls
}
}
AntdUI.CellBadge? _online;
public AntdUI.CellBadge? online
AntdUI.CellBadge _online;
public AntdUI.CellBadge online
{
get => _online;
set
@@ -526,8 +487,8 @@ namespace Demo.Controls
}
}
bool? _enable;
public bool? enable
bool _enable = false;
public bool enable
{
get => _enable;
set
@@ -549,8 +510,8 @@ namespace Demo.Controls
OnPropertyChanged();
}
}
DateTime? _date;
public DateTime? date
DateTime _date;
public DateTime date
{
get => _date;
set
@@ -561,8 +522,8 @@ namespace Demo.Controls
}
}
string? _address;
public string? address
string _address;
public string address
{
get => _address;
set
@@ -573,8 +534,8 @@ namespace Demo.Controls
}
}
AntdUI.CellTag[]? _tag;
public AntdUI.CellTag[]? tag
AntdUI.CellTag[] _tag;
public AntdUI.CellTag[] tag
{
get => _tag;
set
@@ -584,8 +545,8 @@ namespace Demo.Controls
}
}
AntdUI.CellImage[]? _imgs;
public AntdUI.CellImage[]? imgs
AntdUI.CellImage[] _imgs;
public AntdUI.CellImage[] imgs
{
get => _imgs;
set
@@ -595,8 +556,8 @@ namespace Demo.Controls
}
}
AntdUI.CellLink[]? _btns;
public AntdUI.CellLink[]? btns
AntdUI.CellLink[] _btns;
public AntdUI.CellLink[] btns
{
get => _btns;
set

View File

@@ -49,7 +49,7 @@ namespace Demo.Controls
},
new AntdUI.Column("age", "<22><><EFBFBD><EFBFBD>").SetAlign().SetLocalizationTitleID("Table.Column."),
new AntdUI.Column("address", "סַ").SetLocalizationTitleID("Table.Column."),
new AntdUI.Column("date", "<22><><EFBFBD><EFBFBD>").SetLocalizationTitleID("Table.Column.").SetDisplayFormat("D"),
new AntdUI.Column("date", "<22><><EFBFBD><EFBFBD>").SetLocalizationTitleID("Table.Column."),
new AntdUI.Column("tag", "Tag"),
new AntdUI.Column("imgs", "ͼƬ").SetLocalizationTitleID("Table.Column."),
new AntdUI.Column("btns", "<22><><EFBFBD><EFBFBD>").SetFixed().SetWidth("auto").SetLocalizationTitleID("Table.Column."),
@@ -396,7 +396,7 @@ namespace Demo.Controls
new AntdUI.AntItem("radio", false),
new AntdUI.AntItem("online", online),
new AntdUI.AntItem("enable", start % 2 == 0),
new AntdUI.AntItem("age", age),
new AntdUI.AntItem("age", DateTime.Now.Date.AddYears(-age)),
new AntdUI.AntItem("address", address),
new AntdUI.AntItem("date",DateTime.Now.Date.AddYears(-new System.Random().Next(DateTime.Now.Second))),
new AntdUI.AntItem("tag",tag),

View File

@@ -210,6 +210,8 @@ namespace AntdUI
/// 获取焦点
/// </summary>
public bool Focus { get; set; } = true;
public float? Dpi { get; set; }
}
/// <summary>

View File

@@ -52,16 +52,16 @@ namespace AntdUI
SegmentedItem segmentedItem4 = new SegmentedItem();
TreeItem treeItem1 = new TreeItem();
segmentedSource = new Segmented();
gridPanel1 = new GridPanel();
treeList = new Tree();
inputSearch = new Input();
flowPanelConditionEdit = new System.Windows.Forms.Panel();
selectCondition = new Select();
gridPanel1.SuspendLayout();
tablePanel = new System.Windows.Forms.TableLayoutPanel();
tablePanel.SuspendLayout();
SuspendLayout();
//
// segmentedSource
//
segmentedSource.Dock = System.Windows.Forms.DockStyle.Top;
segmentedSource.Full = true;
segmentedSource.IconRatio = 1F;
segmentedItem1.Badge = null;
@@ -108,41 +108,28 @@ namespace AntdUI
segmentedSource.Items.Add(segmentedItem2);
segmentedSource.Items.Add(segmentedItem3);
segmentedSource.Items.Add(segmentedItem4);
segmentedSource.Location = new System.Drawing.Point(3, 3);
segmentedSource.Location = new System.Drawing.Point(0, 0);
segmentedSource.Margin = new System.Windows.Forms.Padding(2);
segmentedSource.Name = "segmentedSource";
segmentedSource.SelectIndex = 2;
segmentedSource.Size = new System.Drawing.Size(297, 56);
segmentedSource.Size = new System.Drawing.Size(180, 40);
segmentedSource.TabIndex = 4;
segmentedSource.Text = "segmented2";
//
// gridPanel1
//
gridPanel1.Controls.Add(treeList);
gridPanel1.Controls.Add(inputSearch);
gridPanel1.Controls.Add(flowPanelConditionEdit);
gridPanel1.Controls.Add(selectCondition);
gridPanel1.Controls.Add(segmentedSource);
gridPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
gridPanel1.Location = new System.Drawing.Point(0, 0);
gridPanel1.Name = "gridPanel1";
gridPanel1.Size = new System.Drawing.Size(303, 390);
gridPanel1.Span = "100%;18% 82%;100%;100%;- 16% 12% 12% 60%";
gridPanel1.TabIndex = 0;
gridPanel1.Text = "gridPanel1";
//
// treeList
//
treeList.Checkable = true;
treeList.Dock = System.Windows.Forms.DockStyle.Fill;
treeItem1.Checked = true;
treeItem1.CheckState = System.Windows.Forms.CheckState.Checked;
treeItem1.Select = true;
treeItem1.Text = "全选";
treeList.Items.Add(treeItem1);
treeList.Location = new System.Drawing.Point(3, 159);
treeList.Location = new System.Drawing.Point(0, 108);
treeList.Margin = new System.Windows.Forms.Padding(0);
treeList.Multiple = true;
treeList.Name = "treeList";
treeList.SelectItem = treeItem1;
treeList.Size = new System.Drawing.Size(297, 228);
treeList.Size = new System.Drawing.Size(180, 132);
treeList.TabIndex = 2;
treeList.Text = "tree1";
treeList.CheckedChanged += treeList_CheckedChanged;
@@ -150,53 +137,60 @@ namespace AntdUI
// inputSearch
//
inputSearch.AllowClear = true;
inputSearch.Dock = System.Windows.Forms.DockStyle.Fill;
inputSearch.Location = new System.Drawing.Point(3, 112);
inputSearch.Dock = System.Windows.Forms.DockStyle.Top;
inputSearch.Location = new System.Drawing.Point(0, 74);
inputSearch.Margin = new System.Windows.Forms.Padding(0);
inputSearch.Name = "inputSearch";
inputSearch.PlaceholderText = "搜索";
inputSearch.Size = new System.Drawing.Size(297, 41);
inputSearch.Size = new System.Drawing.Size(180, 34);
inputSearch.TabIndex = 1;
inputSearch.TextChanged += inputSearch_TextChanged;
//
// flowPanelConditionEdit
//
flowPanelConditionEdit.BackColor = System.Drawing.Color.Transparent;
flowPanelConditionEdit.Dock = System.Windows.Forms.DockStyle.Fill;
flowPanelConditionEdit.Location = new System.Drawing.Point(58, 65);
flowPanelConditionEdit.Name = "flowPanelConditionEdit";
flowPanelConditionEdit.Size = new System.Drawing.Size(242, 41);
flowPanelConditionEdit.TabIndex = 0;
flowPanelConditionEdit.Text = "flowPanel1";
//
// selectCondition
//
selectCondition.Dock = System.Windows.Forms.DockStyle.Fill;
selectCondition.IconRatio = 1F;
selectCondition.IconRatioRight = 0F;
selectCondition.List = true;
selectCondition.ListAutoWidth = true;
selectCondition.Location = new System.Drawing.Point(3, 65);
selectCondition.Location = new System.Drawing.Point(0, 0);
selectCondition.Margin = new System.Windows.Forms.Padding(0);
selectCondition.MaxCount = 8;
selectCondition.Name = "selectCondition";
selectCondition.Size = new System.Drawing.Size(49, 41);
selectCondition.Size = new System.Drawing.Size(34, 34);
selectCondition.TabIndex = 3;
//
// tablePanel
//
tablePanel.ColumnCount = 2;
tablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 34F));
tablePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
tablePanel.Controls.Add(selectCondition, 0, 0);
tablePanel.Dock = System.Windows.Forms.DockStyle.Top;
tablePanel.Location = new System.Drawing.Point(0, 40);
tablePanel.Name = "tablePanel";
tablePanel.RowCount = 1;
tablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
tablePanel.Size = new System.Drawing.Size(180, 34);
tablePanel.TabIndex = 5;
//
// FilterControl
//
Controls.Add(gridPanel1);
Controls.Add(treeList);
Controls.Add(inputSearch);
Controls.Add(tablePanel);
Controls.Add(segmentedSource);
Name = "FilterControl";
Size = new System.Drawing.Size(303, 390);
gridPanel1.ResumeLayout(false);
Size = new System.Drawing.Size(180, 240);
tablePanel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Segmented segmentedSource;
private GridPanel gridPanel1;
private System.Windows.Forms.Panel flowPanelConditionEdit;
private Select selectCondition;
private Input inputSearch;
private Tree treeList;
private System.Windows.Forms.TableLayoutPanel tablePanel;
}
}

View File

@@ -57,6 +57,7 @@ namespace AntdUI
InitFilterEditor();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
@@ -89,9 +90,10 @@ namespace AntdUI
if (type == null) type = typeof(string);
if (type == typeof(decimal) || type == typeof(double) || type == typeof(float) || type == typeof(int) || type == typeof(short) || type == typeof(long))
{
InputNumber edit = new InputNumber();
edit.TabIndex = 0;
edit.Dock = DockStyle.Fill;
var edit = new InputNumber {
Margin=new Padding(0),
Dock = DockStyle.Fill
};
edit.DecimalPlaces = type == typeof(int) || type == typeof(short) || type == typeof(long) ? 0 : 7;
try
{
@@ -100,7 +102,7 @@ namespace AntdUI
catch { }
edit.ValueChanged += Edit_ValueChanged;
edit.TextChanged += Edit_TextChanged;
flowPanelConditionEdit.Controls.Add(edit);
tablePanel.Controls.Add(edit, 1, 0);
foreach (SelectItem item in selectCondition.Items)
{
FilterConditions condition = (FilterConditions)item.Tag;
@@ -109,9 +111,11 @@ namespace AntdUI
}
else if (type == typeof(DateTime))
{
DatePicker edit = new DatePicker();
edit.TabIndex = 0;
edit.Dock = DockStyle.Fill;
var edit = new DatePicker
{
Margin = new Padding(0),
Dock = DockStyle.Fill
};
try
{
edit.Value = Option.FilterValues != null && Option.FilterValues.Count == 1 ? Convert.ToDateTime(Option.FilterValues[0]) : null;
@@ -119,7 +123,7 @@ namespace AntdUI
catch { }
edit.ValueChanged += EditDate_ValueChanged;
edit.TextChanged += Edit_TextChanged;
flowPanelConditionEdit.Controls.Add(edit);
tablePanel.Controls.Add(edit, 1, 0);
foreach (SelectItem item in selectCondition.Items)
{
FilterConditions condition = (FilterConditions)item.Tag;
@@ -128,9 +132,11 @@ namespace AntdUI
}
else if (type == typeof(bool))
{
Switch edit = new Switch();
edit.TabIndex = 0;
edit.Dock = DockStyle.Fill;
var edit = new Switch
{
Margin = new Padding(0),
Dock = DockStyle.Fill
};
edit.CheckedText = "是";
edit.UnCheckedText = "否";
try
@@ -139,7 +145,7 @@ namespace AntdUI
}
catch { }
edit.CheckedChanged += EditChecked_CheckedChanged;
flowPanelConditionEdit.Controls.Add(edit);
tablePanel.Controls.Add(edit, 1, 0);
foreach (SelectItem item in selectCondition.Items)
{
FilterConditions condition = (FilterConditions)item.Tag;
@@ -148,14 +154,16 @@ namespace AntdUI
}
else
{
Input edit = new Input();
edit.TabIndex = 0;
edit.Dock = DockStyle.Fill;
var edit = new Input
{
Margin = new Padding(0),
Dock = DockStyle.Fill
};
#pragma warning disable CS8601 // 引用类型赋值可能为 null。
edit.Text = Option.FilterValues != null && Option.FilterValues.Count == 1 && Option.FilterValues[0] != DBNull.Value ? Option.FilterValues[0].ToString() : string.Empty;
#pragma warning restore CS8601 // 引用类型赋值可能为 null。
edit.TextChanged += Edit_TextChanged;
flowPanelConditionEdit.Controls.Add(edit);
tablePanel.Controls.Add(edit, 1, 0);
}
}
@@ -255,10 +263,18 @@ namespace AntdUI
}
}
#endregion
#region Properties
public FilterOption Option { get { return FocusedColumn.Filter; } }
protected IControl? Edit { get { if (flowPanelConditionEdit.Controls.Count == 0) return null; return flowPanelConditionEdit.Controls[0] as IControl; } }
protected AntdUI.Table.IRow[]? RowsCache { get; set; }
protected IControl? Edit
{
get
{
if (tablePanel.Controls.Count == 0) return null;
return tablePanel.Controls[tablePanel.Controls.Count - 1] as IControl;
}
}
protected Table.IRow[]? RowsCache { get; set; }
protected Table _table;
protected IList<object>? CustomSource { get; set; }
protected bool EditLocked { get; set; } = true;
@@ -271,6 +287,7 @@ namespace AntdUI
public Column FocusedColumn { get => _column; }
#endregion
private void treeList_CheckedChanged(object sender, TreeCheckedEventArgs e)
{
if (EditLocked) return;
@@ -390,10 +407,11 @@ namespace AntdUI
Option.UpdateFilter();
ItemFilterEnabled.Enabled = Option.Enabled;
}
decimal beforeValue = 0;
void Edit_ValueChanged(object sender, DecimalEventArgs e)
{
if(beforeValue==e.Value) return;
if (beforeValue == e.Value) return;
beforeValue = e.Value;
Option.FilterValues = new List<object> { e.Value };
Option.UpdateFilter();
@@ -406,7 +424,6 @@ namespace AntdUI
if (e.Value != null) Option.FilterValues = new List<object> { e.Value };
Option.UpdateFilter();
ItemFilterEnabled.Enabled = Option.Enabled;
}
int beforeIndex = -1;
@@ -418,7 +435,7 @@ namespace AntdUI
{
Option.ClearFilter();
ItemFilterEnabled.Enabled = false;
Form? frm = this.FindForm();
Form? frm = FindForm();
if (frm != null) frm.Close();
}
else

View File

@@ -1,120 +0,0 @@
<?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>

View File

@@ -28,13 +28,10 @@ namespace AntdUI
{
internal TempTable? dataTmp = null;
bool dataOne = true;
void ExtractData(bool reset=true)
void ExtractData()
{
if (reset)
{
dataOne = true;
dataTmp = null;
}
dataOne = true;
dataTmp = null;
if (columns != null)
{
// 重置复选状态
@@ -45,36 +42,11 @@ namespace AntdUI
}
if (dataSource == null)
{
dataTmp = null;
rows_Expand.Clear();
// 空数据
ScrollBar.ValueX = ScrollBar.ValueY = 0;
return;
}
if (reset == false && dataTmp != null && dataTmp.rowsFilter != null)//只刷新汇总
{
if (summary != null)
{
if (dataSource is DataTable table)
{
if (table.Columns.Count > 0 && table.Rows.Count > 0)
{
var columns = new List<TempiColumn>(table.Columns.Count);
for (int i = 0; i < table.Columns.Count; i++) columns.Add(new TempiColumn(i, table.Columns[i]));
var _columns = columns.ToArray();
dataTmp.summary = ExtractSummary(_columns);
}
}
else if (dataSource is IList list)
{
var columns = new TempiColumn[0];
var rows = new List<IRow>(list.Count + 1);
for (int i = 0; i < list.Count; i++) GetRowAuto(ref rows, list[i], i, ref columns);
dataTmp.summary = ExtractSummary(columns);
}
}
return;
}
if (dataSource is BindingSource bindingSource)
{
bindingSource.ListChanged -= Binding_ListChanged;
@@ -84,6 +56,42 @@ namespace AntdUI
else ExtractData(dataSource);
}
bool ExtractDataSummary()
{
if (dataTmp == null || dataTmp.rowsFilter == null) return true;
if (columns != null)
{
// 重置复选状态
foreach (var item in columns)
{
if (item is ColumnCheck check) check.CheckState = CheckState.Unchecked;
}
}
if (summary == null)
{
dataTmp.summary = null;
return false;
}
if (dataSource is DataTable table)
{
if (table.Columns.Count > 0 && table.Rows.Count > 0)
{
var columns = new List<TempiColumn>(table.Columns.Count);
for (int i = 0; i < table.Columns.Count; i++) columns.Add(new TempiColumn(i, table.Columns[i]));
var _columns = columns.ToArray();
dataTmp.summary = ExtractSummary(_columns);
}
}
else if (dataSource is IList list)
{
var columns = new TempiColumn[0];
var rows = new List<IRow>(list.Count + 1);
for (int i = 0; i < list.Count; i++) GetRowAuto(ref rows, list[i], i, ref columns);
dataTmp.summary = ExtractSummary(columns);
}
return false;
}
void ExtractData(object? dataSource)
{
if (dataSource is DataTable table)
@@ -482,11 +490,7 @@ namespace AntdUI
/// <summary>
/// 数据 - 行已筛选
/// </summary>
public IRow[]? rowsFilter
{
get;
set;
}
public IRow[]? rowsFilter { get; set; }
public void ClearFilter() => rowsFilter = null;

View File

@@ -260,18 +260,21 @@ namespace AntdUI
/// <param name="sender">Table</param>
/// <param name="e">事件参数</param>
public delegate void TableFilterPopupEndEventHandler(object sender, TableFilterPopupEndEventArgs e);
/// <summary>
/// Table的列筛选弹出前的数据处理事件
/// </summary>
/// <param name="sender">Table</param>
/// <param name="e">事件参数</param>
public delegate void TableFilterPopupBeginEventHandler(object sender, TableFilterPopupBeginEventArgs e);
/// <summary>
/// Table的筛选数据变更事件
/// </summary>
/// <param name="sender">Table</param>
/// <param name="e">事件参数</param>
public delegate void TableFilterDataChangedEventHandler(object sender, TableFilterDataChangedEventArgs e);
/// <summary>
/// <summary>
/// 筛选窗口弹出前发生
@@ -289,6 +292,5 @@ namespace AntdUI
/// </summary>
[Description("筛选数据变更后发生"), Category("行为")]
public event TableFilterDataChangedEventHandler? FilterDataChanged;
}
}

View File

@@ -46,6 +46,7 @@ namespace AntdUI
return null;
}
}
/// <summary>
/// 获取筛选数据
/// </summary>
@@ -53,28 +54,22 @@ namespace AntdUI
public object[]? FilterList()
{
if (dataTmp == null || dataTmp.rowsFilter == null) return null;
List<object> data = new List<object>();
foreach (var row in dataTmp.rowsFilter)
{
data.Add(row.record);
}
List<object> data = new List<object>(dataTmp.rowsFilter.Length);
foreach (var row in dataTmp.rowsFilter) data.Add(row.record);
return data.ToArray();
}
/// <summary>
/// 更新筛选视图
/// </summary>
public void UpdateFilter()
{
if (dataTmp == null) return;
Column[]? filterColumns = FilterColumns;
if (filterColumns == null || filterColumns.Length == 0)
{
dataTmp.rowsFilter = null;
}
if (filterColumns == null || filterColumns.Length == 0) dataTmp.rowsFilter = null;
else
{
filterColumns = filterColumns.OrderBy(c => c.Filter.FilterIndex).ToArray();//按筛选优化级排序
filterColumns = filterColumns.OrderBy(c => c.Filter?.FilterIndex).ToArray();//按筛选优化级排序
List<IRow> rows = new List<IRow>();
foreach (var col in filterColumns)
{
@@ -91,8 +86,7 @@ namespace AntdUI
}
}
}
else
rows = found;
else rows = found;
}
if (rows.Count == 0)
{
@@ -112,18 +106,11 @@ namespace AntdUI
{
dataTmp.rowsFilter = new IRow[rows.Count];
rows.CopyTo(dataTmp.rowsFilter, 0);
}
}
if (FilterDataChanged != null)
{
var filterData = FilterList();
FilterDataChanged(this, new TableFilterDataChangedEventArgs(filterData));
}
FilterDataChanged?.Invoke(this, new TableFilterDataChangedEventArgs(FilterList()));
if (LoadLayout()) Invalidate();
}
/// <summary>
/// 更新筛选视图
@@ -199,8 +186,8 @@ namespace AntdUI
else if (val.GetType() == typeof(DateTime))
{
if (option.Condition == FilterConditions.Greater)
{
if ((DateTime)val > (DateTime)value) list.Add(row);
{
if ((DateTime)val > (DateTime)value) list.Add(row);
}
else
{
@@ -254,11 +241,13 @@ namespace AntdUI
/// 实例化筛选
/// </summary>
public FilterOption() : this(typeof(string)) { }
/// <summary>
/// 实例化筛选
/// </summary>
/// <param name="dataType">数据类型</param>
public FilterOption(Type dataType) : this(dataType, dataType == typeof(string) ? FilterConditions.Contain : FilterConditions.Equal) { }
/// <summary>
/// 实例化筛选
/// </summary>
@@ -300,6 +289,7 @@ namespace AntdUI
/// 筛选条件
/// </summary>
public FilterConditions Condition { get; set; } = FilterConditions.Contain;
List<object>? _filterValues;
/// <summary>
/// 已应用的筛选值列表

View File

@@ -319,9 +319,7 @@ namespace AntdUI
{
Popover.Config? config = sender as Popover.Config;
if (config == null) return;
var arg = new TableFilterPopupEndEventArgs(config.Tag is FilterOption ? (FilterOption)config.Tag : null, FilterList());
FilterPopupEnd(sender, arg);
e.Cancel = arg.Cancel;
}
@@ -465,11 +463,11 @@ namespace AntdUI
if (fixedColumnR != null && fixedColumnR.Contains(Columns.IndexOf(focusColumn))) location.X -= (showFixedColumnR ? _gap : _gap * 2);
location.X += col.rect_filter.Width / 2;
location.Y += col.rect_filter.Height;
Rectangle? rectScreen = Screen.PrimaryScreen?.Bounds;
Rectangle? rectScreen = Screen.FromPoint(location).WorkingArea;
TAlign align = TAlign.Bottom;
if (rectScreen.HasValue)
{
if (location.X -(editor.Width/2)< rectScreen.Value.Left)
if (location.X - (editor.Width / 2) < rectScreen.Value.Left)
{
align = TAlign.Right;
location.X = editor.Width / 2;
@@ -477,7 +475,7 @@ namespace AntdUI
else if (location.X + editor.Width > rectScreen.Value.Right)
{
align = TAlign.Left;
location.X = rectScreen.Value.Right- editor.Width / 2;
location.X = rectScreen.Value.Right - editor.Width / 2;
}
else if (location.Y + editor.Height > rectScreen.Value.Bottom)
{
@@ -485,8 +483,10 @@ namespace AntdUI
location.Y = locaionOrigin.Y;
}
}
Popover.open(new Popover.Config(this, editor)
{
Dpi = (fnt.Size / 9F) * Config.Dpi,
Tag = focusColumn.Filter,
ArrowAlign = align,
Font = fnt,

View File

@@ -665,17 +665,25 @@ namespace AntdUI
var state = g.Save();
try
{
if (CellPaintBegin == null) PaintItemCore(g, columnIndex, it, enable, fore);
if (CellPaintBegin == null) PaintItemCore(g, columnIndex, it, enable, Font, fore);
else
{
var arge = new TablePaintBeginEventArgs(g, it.RECT, it.RECT_REAL, it.ROW.RECORD, it.ROW.INDEX, columnIndex, it.COLUMN);
CellPaintBegin(this, arge);
if (!arge.Handled)
{
Color foreBefore = fore.Color;
if (arge.CellFore != null) fore.Color = arge.CellFore.Value;
PaintItemCore(g, columnIndex, it, enable, fore, arge.CellBack, arge.CellFont);
if (arge.CellFore != null) fore.Color = foreBefore;
if (arge.CellBack != null)
{
using (arge.CellBack)
{
g.Fill(arge.CellBack, it.RECT);
}
}
using (arge.CellFont)
using (arge.CellFore)
{
PaintItemCore(g, columnIndex, it, enable, arge.CellFont ?? Font, arge.CellFore ?? fore);
}
}
}
CellPaint?.Invoke(this, new TablePaintEventArgs(g, it.RECT, it.RECT_REAL, it.ROW.RECORD, it.ROW.INDEX, columnIndex, it.COLUMN));
@@ -683,11 +691,8 @@ namespace AntdUI
catch { }
g.Restore(state);
}
void PaintItemCore(Canvas g, int columnIndex, CELL it, bool enable, SolidBrush fore)
{
PaintItemCore(g, columnIndex, it, enable, fore, null, null);
}
void PaintItemCore(Canvas g, int columnIndex, CELL it, bool enable, SolidBrush fore, Brush? back, Font? font)
void PaintItemCore(Canvas g, int columnIndex, CELL it, bool enable, Font font, SolidBrush fore)
{
if (it is TCellCheck check) PaintCheck(g, check, enable);
else if (it is TCellRadio radio) PaintRadio(g, radio, enable);
@@ -716,21 +721,12 @@ namespace AntdUI
else if (it is Template template)
{
g.SetClip(it.RECT, CombineMode.Intersect);
foreach (var item in template.Value) item.Paint(g, font == null ? Font : font, enable, fore);
if (font != null) font.Dispose();
foreach (var item in template.Value) item.Paint(g, font, enable, fore);
}
else if (it is TCellText text)
{
g.SetClip(it.RECT, CombineMode.Intersect);
g.String(text.value, font == null ? Font : font, fore, text.RECT_REAL, StringFormat(text.COLUMN));
if (font != null) font.Dispose();
if (back != null)
{
using (back)
{ g.Fill(back, it.RECT); }
}
g.String(text.value, font, fore, text.RECT_REAL, StringFormat(text.COLUMN));
}
if (dragHeader != null && dragHeader.enable && dragHeader.i == it.COLUMN.INDEX_REAL) g.Fill(Colour.FillSecondary.Get("Table", ColorScheme), it.RECT);
if (it.ROW.CanExpand && it.ROW.KeyTreeINDEX == columnIndex)

View File

@@ -778,7 +778,7 @@ namespace AntdUI
{
value = column.GetDisplayText(txt);
}
/// <summary>
/// 值
/// </summary>

View File

@@ -21,7 +21,6 @@ using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
@@ -99,9 +98,7 @@ namespace AntdUI
set
{
summary = value;
ExtractData(false);//会设置dataTmp清除筛选
if (ExtractDataSummary()) ExtractData();
if (LoadLayout()) Invalidate();
OnPropertyChanged(nameof(Summary));
}
@@ -1999,10 +1996,8 @@ namespace AntdUI
/// 设置默认筛选选项 (string)
/// </summary>
/// <returns></returns>
public Column SetDefaultFilter()
{
return SetDefaultFilter(typeof(string));
}
public Column SetDefaultFilter() => SetDefaultFilter(typeof(string));
/// <summary>
/// 设置默认筛选选项
/// </summary>
@@ -2013,13 +2008,16 @@ namespace AntdUI
Filter = new FilterOption(type);
return this;
}
#endregion
#region
/// <summary>
/// 格式化显示如日期D, yyyy-MM-dd, dd MMM yyyy..., 数字格式化C, D5, P2, 0.###...
/// </summary>
public string? DisplayFormat { get; set; }
/// <summary>
/// 设置格式化显示
/// 建议非string类型需要时设置
@@ -2030,6 +2028,7 @@ namespace AntdUI
DisplayFormat = format;
return this;
}
/// <summary>
/// 返回格式化的字符串
/// </summary>
@@ -2037,11 +2036,10 @@ namespace AntdUI
/// <returns></returns>
public string? GetDisplayText(object? value)
{
if (value == null || value == DBNull.Value)
return string.Empty;
if (value == null || value == DBNull.Value) return null;
else
{
if (string.IsNullOrEmpty(this.DisplayFormat)) return value?.ToString();
if (DisplayFormat == null || string.IsNullOrEmpty(DisplayFormat)) return value?.ToString();
try
{
if (DisplayFormat.Contains("{0:")) return string.Format(DisplayFormat, value);
@@ -2050,7 +2048,9 @@ namespace AntdUI
catch { return value?.ToString(); }
}
}
#endregion
/// <summary>
/// 列可拖拽
/// </summary>

View File

@@ -19,7 +19,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
@@ -652,7 +651,7 @@ namespace AntdUI
if (item.Icon != null) g.Image(item.Icon, item.ico_rect);
if (item.IconSvg != null) g.GetImgExtend(item.IconSvg, item.ico_rect, color);
}
}
internal RectangleF PaintBlock(RectangleF rect)
@@ -1325,17 +1324,18 @@ namespace AntdUI
ThreadLoading?.Dispose();
if (loading)
{
ThreadLoading = new ITask(i =>
if (PARENT == null) Invalidate();
else
{
AnimationLoadingWaveValue += 1;
if (AnimationLoadingWaveValue > 100) AnimationLoadingWaveValue = 0;
AnimationLoadingValue = i;
Invalidate();
return loading;
}, 10, 360, 10, () =>
{
Invalidate();
});
ThreadLoading = new ITask(PARENT, i =>
{
AnimationLoadingWaveValue += 1;
if (AnimationLoadingWaveValue > 100) AnimationLoadingWaveValue = 0;
AnimationLoadingValue = i;
Invalidate();
return loading;
}, 10, 360, 10, () => Invalidate());
}
}
else Invalidate();
}

View File

@@ -28,24 +28,24 @@ namespace AntdUI.Design
/// </summary>
private void InitializeComponent()
{
this.input1 = new AntdUI.Input();
this.SuspendLayout();
input1 = new Input();
SuspendLayout();
//
// input1
//
this.input1.Anchor = System.Windows.Forms.AnchorStyles.None;
this.input1.Location = new System.Drawing.Point(43, 174);
this.input1.Name = "input1";
this.input1.Size = new System.Drawing.Size(144, 50);
this.input1.TabIndex = 1;
input1.Anchor = System.Windows.Forms.AnchorStyles.None;
input1.Location = new System.Drawing.Point(43, 174);
input1.Name = "input1";
input1.Size = new System.Drawing.Size(144, 50);
input1.TabIndex = 1;
//
// FrmColorEditor
//
this.Controls.Add(this.input1);
this.MinimumSize = new System.Drawing.Size(240, 280);
this.Name = "FrmColorEditor";
this.Size = new System.Drawing.Size(240, 280);
this.ResumeLayout(false);
Controls.Add(input1);
MinimumSize = new System.Drawing.Size(240, 280);
Name = "FrmColorEditor";
Size = new System.Drawing.Size(240, 280);
ResumeLayout(false);
}

View File

@@ -47,10 +47,7 @@ namespace AntdUI.Design
input1.Text = Value.ToHex();
input1.TextChanged += input1_TextChanged;
action = val =>
{
input1.Text = val.ToHex();
};
action = val => input1.Text = val.ToHex();
}
protected override void OnLoad(EventArgs e)
@@ -605,7 +602,7 @@ namespace AntdUI.Design
#endregion
private void input1_TextChanged(object sender, System.EventArgs e)
private void input1_TextChanged(object? sender, EventArgs e)
{
bmp_colors?.Dispose();
bmp_colors = null;

View File

@@ -673,21 +673,24 @@ namespace AntdUI
public TablePaintBeginEventArgs(Canvas canvas, Rectangle rect, Rectangle rectreal, object? record, int rowIndex, int index, Column column) : base(canvas, rect, rectreal, record, rowIndex, index, column) { }
/// <summary>
/// 是否处理
/// 是否处理
/// </summary>
public bool Handled { get; set; }
/// <summary>
/// 单元格前景色
/// </summary>
public Color? CellFore { get; set; } = null;
public SolidBrush? CellFore { get; set; }
/// <summary>
/// 单元格背景笔刷 (支持常用SolidBrush, HatchBrush, TextureBrush,LinearGradientBrush...)
/// </summary>
public Brush? CellBack { get; set; } = null;
public Brush? CellBack { get; set; }
/// <summary>
/// 单元格字体
/// </summary>
public Font? CellFont { get; set; } = null;
public Font? CellFont { get; set; }
}
public class TableSortModeEventArgs : EventArgs
@@ -840,6 +843,7 @@ namespace AntdUI
/// </summary>
public bool Cancel { get; set; }
}
#endregion
#region Tabs

View File

@@ -166,7 +166,7 @@ namespace AntdUI
[Description("圆角"), Category("外观"), DefaultValue(0)]
public int Radius { get; set; }
public abstract void PrintContent(Canvas g, Rectangle rect);
public abstract void PrintContent(Canvas g, Rectangle rect, GraphicsState state);
public abstract void PrintBg(Canvas g, Rectangle rect, GraphicsPath path);
public void PrintAndClear()
{
@@ -179,7 +179,7 @@ namespace AntdUI
{
var rect = TargetRectXY;
Bitmap original_bmp = new Bitmap(rect.Width, rect.Height);
using (var g = Graphics.FromImage(original_bmp).High())
using (var g = Graphics.FromImage(original_bmp).HighLay())
{
if (ShadowEnabled)
{
@@ -195,16 +195,12 @@ namespace AntdUI
g.Image(shadow_temp.Bitmap, rect, .2F);
PrintBg(g, rect_read, path);
}
using (var bmp = new Bitmap(rect_read.Width, rect_read.Height))
{
using (var g2 = Graphics.FromImage(bmp).High())
{
PrintContent(g2, new Rectangle(0, 0, rect_read.Width, rect_read.Height));
}
g.Image(bmp, rect_read);
}
g.SetClip(rect_read);
g.TranslateTransform(shadow, shadow);
var state = g.Save();
PrintContent(g, new Rectangle(0, 0, rect_read.Width, rect_read.Height), state);
}
else PrintContent(g, rect);
else PrintContent(g, rect, g.Save());
}
return original_bmp;
}

View File

@@ -175,7 +175,7 @@ namespace AntdUI
g.Fill(brush, path);
}
}
public override void PrintContent(Canvas g, Rectangle rect)
public override void PrintContent(Canvas g, Rectangle rect, GraphicsState state)
{
if (ScrollBar.ShowY) g.TranslateTransform(0, -ScrollBar.ValueY);
if (foreColor.HasValue)
@@ -192,8 +192,7 @@ namespace AntdUI
foreach (var it in Items) DrawItem(g, brush, it);
}
}
g.ResetClip();
g.ResetTransform();
g.Restore(state);
ScrollBar.Paint(g);
}

View File

@@ -53,9 +53,8 @@ namespace AntdUI
control.Parent = this;
control.BackColor = Colour.BgElevated.Get("Popover");
control.ForeColor = Colour.Text.Get("Popover");
int w = (int)Math.Round(control.Width * dpi) + 2;
control.Width = w;
Helper.DpiAuto(config.Dpi ?? Config.Dpi, control);
int w = control.Width;
int h;
if (_config.Title == null)
{
@@ -73,7 +72,6 @@ namespace AntdUI
}
}
tempContent = new Bitmap(control.Width, control.Height);
Helper.DpiAuto(Config.Dpi, control);
control.Size = new Size(tempContent.Width, tempContent.Height);
control.DrawToBitmap(tempContent, new Rectangle(0, 0, tempContent.Width, tempContent.Height));
SetSize(w + paddingx2, h + paddingy2);

View File

@@ -371,7 +371,7 @@ namespace AntdUI
if (ArrowAlign != TAlign.None) g.FillPolygon(brush, ArrowAlign.AlignLines(ArrowSize, rect, tmpItemHeight));
}
}
public override void PrintContent(Canvas g, Rectangle rect)
public override void PrintContent(Canvas g, Rectangle rect, GraphicsState state)
{
if (nodata) g.PaintEmpty(rect, Font, Color.FromArgb(180, Colour.Text.Get(keyid, ColorScheme)));
else
@@ -384,7 +384,7 @@ namespace AntdUI
using (var brush_split = new SolidBrush(Colour.Split.Get(keyid, ColorScheme)))
{
foreach (var it in GetItems()) DrawItem(g, brush, brush_sub, brush_back_hover, brush_fore, brush_split, it);
g.ResetTransform();
g.Restore(state);
ScrollBar.Paint(g);
}
}

View File

@@ -142,7 +142,7 @@ namespace AntdUI
if (ArrowAlign != TAlign.None) g.FillPolygon(brush, ArrowAlign.AlignLines(ArrowSize, rect, tmpItemHeight));
}
}
public override void PrintContent(Canvas g, Rectangle rect)
public override void PrintContent(Canvas g, Rectangle rect, GraphicsState state)
{
if (nodata) g.PaintEmpty(rect, Font, Color.FromArgb(180, Colour.Text.Get(name, ColorScheme)));
else
@@ -199,8 +199,7 @@ namespace AntdUI
foreach (var it in Items) DrawItemR(g, brush, brush_back_hover, brush_split, it);
}
}
g.ResetTransform();
g.ResetClip();
g.Restore(state);
ScrollBar.Paint(g);
}
}

View File

@@ -182,7 +182,7 @@ namespace AntdUI
if (ArrowAlign != TAlign.None) g.FillPolygon(brush, ArrowAlign.AlignLines(ArrowSize, rect, tmpItemHeight));
}
}
public override void PrintContent(Canvas g, Rectangle rect)
public override void PrintContent(Canvas g, Rectangle rect, GraphicsState state)
{
if (nodata) g.PaintEmpty(rect, Font, Color.FromArgb(180, Colour.Text.Get(name, ColorScheme)));
else
@@ -245,8 +245,7 @@ namespace AntdUI
}
}
}
g.ResetTransform();
g.ResetClip();
g.Restore(state);
ScrollBar.Paint(g);
}
}

View File

@@ -64,34 +64,7 @@ namespace AntdUI
Dispose();
});
}
public ITask(Func<int, bool> action, int interval, int max, int add, Action? end = null)
{
bool ok = true;
IsRun = true;
task = Run(() =>
{
int val = 0;
while (true)
{
if (token.Wait())
{
ok = false;
return;
}
else
{
val += add;
if (val > max) val = 0;
if (action(val)) Thread.Sleep(interval);
else return;
}
}
}).ContinueWith(action =>
{
if (ok && end != null) end();
Dispose();
});
}
/// <summary>
/// 循环任务
/// </summary>

View File

@@ -34,11 +34,11 @@ namespace AntdUI
private Bitmap bitmap;
private BitmapData bitmapData;
public UnsafeBitmap(Bitmap bitmap, bool lockBitmap = false, ImageLockMode imageLockMode = ImageLockMode.ReadWrite)
public UnsafeBitmap(Bitmap bmp, bool lockBitmap = false, ImageLockMode imageLockMode = ImageLockMode.ReadWrite)
{
this.bitmap = bitmap;
Width = bitmap.Width;
Height = bitmap.Height;
bitmap = bmp;
Width = bmp.Width;
Height = bmp.Height;
if (lockBitmap)
{