mirror of
https://gitee.com/AntdUI/AntdUI.git
synced 2026-03-24 06:30:44 +08:00
👾 修复 Table ToDataTable 插槽、修复 DataBindings 不支持AOT、修复 Window 大小变化、修复 Splitter DPI 异常、Menu 新增 IconActive、Loading 加入背景
This commit is contained in:
@@ -169,7 +169,7 @@ namespace AntdUI
|
||||
/// <summary>
|
||||
/// 点击时自动改变选中状态
|
||||
/// </summary>
|
||||
[Description("点击时自动改变选中状态"), Category("行为"), DefaultValue(false)]
|
||||
[Description("点击时自动改变选中状态"), Category("行为"), DefaultValue(true)]
|
||||
public bool AutoCheck { get; set; } = true;
|
||||
|
||||
RightToLeft rightToLeft = RightToLeft.No;
|
||||
|
||||
@@ -254,20 +254,26 @@ namespace AntdUI
|
||||
OnSizeChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
static bool disableDataBinding = false;
|
||||
#if NET40
|
||||
public void OnPropertyChanged(string propertyName)
|
||||
#else
|
||||
public void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string? propertyName = null)
|
||||
#endif
|
||||
{
|
||||
foreach (Binding it in DataBindings)
|
||||
if (disableDataBinding) return;
|
||||
try
|
||||
{
|
||||
if (it.PropertyName == propertyName)
|
||||
foreach (Binding it in DataBindings)
|
||||
{
|
||||
it.WriteValue();
|
||||
return;
|
||||
if (it.PropertyName == propertyName)
|
||||
{
|
||||
it.WriteValue();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NotSupportedException) { disableDataBinding = true; }
|
||||
}
|
||||
|
||||
#region 鼠标
|
||||
|
||||
@@ -793,8 +793,23 @@ namespace AntdUI
|
||||
}
|
||||
void PaintIcon(Canvas g, MenuItem it, Color fore)
|
||||
{
|
||||
if (it.Select)
|
||||
{
|
||||
int count = 0;
|
||||
if (it.IconActive != null)
|
||||
{
|
||||
g.Image(it.IconActive, it.ico_rect); count++;
|
||||
}
|
||||
if (it.IconActiveSvg != null)
|
||||
{
|
||||
if (g.GetImgExtend(it.IconActiveSvg, it.ico_rect, fore)) count++;
|
||||
}
|
||||
if (count > 0) return;
|
||||
}
|
||||
|
||||
|
||||
if (it.Icon != null) g.Image(it.Icon, it.ico_rect);
|
||||
else if (it.IconSvg != null) g.GetImgExtend(it.IconSvg, it.ico_rect, fore);
|
||||
if (it.IconSvg != null) g.GetImgExtend(it.IconSvg, it.ico_rect, fore);
|
||||
}
|
||||
|
||||
void PaintBack(Canvas g, Color color, Rectangle rect, float radius)
|
||||
@@ -1250,10 +1265,19 @@ namespace AntdUI
|
||||
/// <summary>
|
||||
/// 是否包含图片
|
||||
/// </summary>
|
||||
internal bool HasIcon
|
||||
{
|
||||
get => !string.IsNullOrWhiteSpace(iconSvg) || icon != null;
|
||||
}
|
||||
internal bool HasIcon => !string.IsNullOrWhiteSpace(iconSvg) || icon != null;
|
||||
|
||||
/// <summary>
|
||||
/// 图标激活
|
||||
/// </summary>
|
||||
[Description("图标激活"), Category("外观"), DefaultValue(null)]
|
||||
public Image? IconActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图标激活SVG
|
||||
/// </summary>
|
||||
[Description("图标激活SVG"), Category("外观"), DefaultValue(null)]
|
||||
public string? IconActiveSvg { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -695,8 +695,10 @@ namespace AntdUI
|
||||
{
|
||||
icon_size = sHeight;
|
||||
var rect_icon = new Rectangle(rect.X + u_x + _gap, rect.Y + (rect.Height - icon_size) / 2, icon_size, icon_size);
|
||||
using (var brush = new Pen(Color.FromArgb(170, fore), sHeight * .14F))
|
||||
using (var pen = new Pen(Style.Db.Fill, sHeight * .14F))
|
||||
using (var brush = new Pen(Color.FromArgb(170, fore), pen.Width))
|
||||
{
|
||||
g.DrawEllipse(pen, rect_icon);
|
||||
brush.StartCap = brush.EndCap = LineCap.Round;
|
||||
g.DrawArc(brush, rect_icon, AnimationLoadingValue, 100);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace AntdUI
|
||||
/// <summary>
|
||||
/// 点击时自动改变选中状态
|
||||
/// </summary>
|
||||
[Description("点击时自动改变选中状态"), Category("行为"), DefaultValue(false)]
|
||||
[Description("点击时自动改变选中状态"), Category("行为"), DefaultValue(true)]
|
||||
public bool AutoCheck { get; set; } = true;
|
||||
|
||||
RightToLeft rightToLeft = RightToLeft.No;
|
||||
|
||||
@@ -933,7 +933,7 @@ namespace AntdUI
|
||||
else
|
||||
{
|
||||
var size = g.MeasureString(it.Text, Font);
|
||||
it.SetRectTop(new Rectangle(rect.X + x, rect.Y, size.Width + gap2, rect.Height), imgsize_t, text_heigth, sp);
|
||||
it.SetRectTop(new Rectangle(rect.X + x, rect.Y, size.Width + gap2, rect.Height), imgsize_t, size.Height, sp);
|
||||
}
|
||||
x += it.Rect.Width + _igap;
|
||||
}
|
||||
@@ -947,7 +947,7 @@ namespace AntdUI
|
||||
else
|
||||
{
|
||||
var size = g.MeasureString(it.Text, Font);
|
||||
it.SetRectBottom(new Rectangle(rect.X + x, rect.Y, size.Width + gap2, rect.Height), imgsize_b, text_heigth, sp);
|
||||
it.SetRectBottom(new Rectangle(rect.X + x, rect.Y, size.Width + gap2, rect.Height), imgsize_b, size.Height, sp);
|
||||
}
|
||||
x += it.Rect.Width + _igap;
|
||||
}
|
||||
@@ -1259,10 +1259,7 @@ namespace AntdUI
|
||||
/// <summary>
|
||||
/// 是否包含图标
|
||||
/// </summary>
|
||||
public bool HasIcon
|
||||
{
|
||||
get => IconSvg != null || Icon != null;
|
||||
}
|
||||
public bool HasIcon => IconSvg != null || Icon != null;
|
||||
|
||||
/// <summary>
|
||||
/// 图标激活
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace AntdUI
|
||||
/// <summary>
|
||||
/// 点击时自动改变选中状态
|
||||
/// </summary>
|
||||
[Description("点击时自动改变选中状态"), Category("行为"), DefaultValue(false)]
|
||||
[Description("点击时自动改变选中状态"), Category("行为"), DefaultValue(true)]
|
||||
public bool AutoCheck { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -877,7 +877,7 @@ namespace AntdUI
|
||||
foreach (var cell in row.cells)
|
||||
{
|
||||
var obj = row[cell.Key];
|
||||
if (enableRender && dir_columns.TryGetValue(cell.Key, out var column)) obj = column.Render?.Invoke(obj, row.record, row.i);
|
||||
if (enableRender && dir_columns.TryGetValue(cell.Key, out var column) && column.Render != null) obj = column.Render(obj, row.record, row.i);
|
||||
|
||||
if (obj is IList<ICell> cells)
|
||||
{
|
||||
@@ -903,7 +903,7 @@ namespace AntdUI
|
||||
foreach (var cell in row.cells)
|
||||
{
|
||||
var obj = row[cell.Key];
|
||||
if (enableRender && dir_columns.TryGetValue(cell.Key, out var column)) obj = column.Render?.Invoke(obj, row.record, row.i);
|
||||
if (enableRender && dir_columns.TryGetValue(cell.Key, out var column) && column.Render != null) obj = column.Render(obj, row.record, row.i);
|
||||
data.Add(obj);
|
||||
}
|
||||
dt.Rows.Add(data.ToArray());
|
||||
@@ -1241,10 +1241,20 @@ namespace AntdUI
|
||||
/// </summary>
|
||||
public bool Ellipsis { get; set; }
|
||||
|
||||
bool lineBreak = false;
|
||||
/// <summary>
|
||||
/// 自动换行
|
||||
/// </summary>
|
||||
public bool LineBreak { get; set; }
|
||||
public bool LineBreak
|
||||
{
|
||||
get => lineBreak;
|
||||
set
|
||||
{
|
||||
if (lineBreak == value) return;
|
||||
lineBreak = value;
|
||||
Invalidates();
|
||||
}
|
||||
}
|
||||
|
||||
bool _fixed = false;
|
||||
/// <summary>
|
||||
|
||||
@@ -258,8 +258,10 @@ namespace AntdUI
|
||||
g.Fill(back, path);
|
||||
|
||||
float loading_size = it.rect_read.Height * 0.06F;
|
||||
using (var brush = new Pen(fore, loading_size))
|
||||
using (var pen = new Pen(Style.Db.Fill, loading_size))
|
||||
using (var brush = new Pen(fore, pen.Width))
|
||||
{
|
||||
g.DrawEllipse(pen, it.rect_icon);
|
||||
brush.StartCap = brush.EndCap = LineCap.Round;
|
||||
g.DrawArc(brush, it.rect_icon, it.AnimationLoadingValue, it.LoadingValue * 360F);
|
||||
}
|
||||
|
||||
@@ -86,17 +86,21 @@ namespace AntdUI
|
||||
DisableProcessWindowsGhosting();
|
||||
if (FormBorderStyle != FormBorderStyle.None && WindowState != FormWindowState.Maximized)
|
||||
{
|
||||
Size max = MaximumSize, min = MinimumSize;
|
||||
sizeInit = ClientSize;
|
||||
MaximumSize = MinimumSize = ClientSize = sizeInit.Value;
|
||||
ClientSize = sizeInit.Value;
|
||||
MinimumSize = min;
|
||||
MaximumSize = max;
|
||||
SetSize(sizeInit.Value);
|
||||
}
|
||||
HandMessage();
|
||||
DwmArea();
|
||||
}
|
||||
|
||||
void SetSize(Size size)
|
||||
{
|
||||
Size max = MaximumSize, min = MinimumSize;
|
||||
MaximumSize = MinimumSize = ClientSize = size;
|
||||
MinimumSize = min;
|
||||
MaximumSize = max;
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
SetWindowPos(Handle, HWND.NULL, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOZORDER | SetWindowPosFlags.SWP_NOOWNERZORDER | SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_FRAMECHANGED);
|
||||
@@ -427,7 +431,12 @@ namespace AntdUI
|
||||
void WmSize(ref System.Windows.Forms.Message m)
|
||||
{
|
||||
if (m.WParam == SIZE_MINIMIZED) WinState = WState.Minimize;
|
||||
else if (m.WParam == SIZE_MAXIMIZED) WinState = WState.Maximize;
|
||||
else if (m.WParam == SIZE_MAXIMIZED)
|
||||
{
|
||||
WinState = WState.Maximize;
|
||||
Invalidate();
|
||||
InvalidateNonclient();
|
||||
}
|
||||
else if (m.WParam == SIZE_RESTORED)
|
||||
{
|
||||
sizeNormal = ClientSize;
|
||||
@@ -452,6 +461,7 @@ namespace AntdUI
|
||||
nccsp.top -= borders.Top;
|
||||
nccsp.top += borders.Bottom;
|
||||
Marshal.StructureToPtr(nccsp, m.LParam, false);
|
||||
m.Result = new IntPtr(0x0400);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -499,12 +509,8 @@ namespace AntdUI
|
||||
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
|
||||
{
|
||||
if (DesignMode) base.SetBoundsCore(x, y, width, height, specified);
|
||||
#if NET40 || NET45 || NET46 || NET48 || NET6_0
|
||||
else if (WindowState == FormWindowState.Normal && sizeNormal.HasValue) base.SetBoundsCore(x, y, sizeNormal.Value.Width, sizeNormal.Value.Height, BoundsSpecified.None);
|
||||
else base.SetBoundsCore(x, y, width, height, specified);
|
||||
#else
|
||||
else base.SetBoundsCore(x, y, width, height, specified);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace AntdUI
|
||||
var dir = new Dictionary<Control, AnchorDock>(controls.Count);
|
||||
foreach (Control control in controls)
|
||||
{
|
||||
if (control is Splitter) continue;
|
||||
if (control.Dock != DockStyle.None || control.Anchor != (AnchorStyles.Left | AnchorStyles.Top)) dir.Add(control, new AnchorDock(control));
|
||||
if (controls.Count > 0) DpiSuspend(ref dir, control.Controls);
|
||||
}
|
||||
@@ -69,6 +70,7 @@ namespace AntdUI
|
||||
{
|
||||
foreach (Control control in controls)
|
||||
{
|
||||
if (control is Splitter) continue;
|
||||
if (control.Dock != DockStyle.None || control.Anchor != (AnchorStyles.Left | AnchorStyles.Top)) dir.Add(control, new AnchorDock(control));
|
||||
if (controls.Count > 0) DpiSuspend(ref dir, control.Controls);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user