🦄 Beautiful AntdUI

This commit is contained in:
Tom
2024-11-07 10:45:20 +08:00
parent e861890f3a
commit 6d6abc5e3c
88 changed files with 1240 additions and 1763 deletions

View File

@@ -155,7 +155,7 @@ namespace Demo.Controls
StringFormat s_f = AntdUI.Helper.SF_NoWrap(lr: StringAlignment.Near);
StringFormat s_c = AntdUI.Helper.SF_NoWrap();
public override void Paint(AntdUI.ICanvas g, AntdUI.VirtualPanelArgs e)
public override void Paint(AntdUI.Canvas g, AntdUI.VirtualPanelArgs e)
{
var dpi = AntdUI.Config.Dpi;
@@ -178,7 +178,7 @@ namespace Demo.Controls
}
}
public override Size Size(AntdUI.ICanvas g, AntdUI.VirtualPanelArgs e)
public override Size Size(AntdUI.Canvas g, AntdUI.VirtualPanelArgs e)
{
var dpi = AntdUI.Config.Dpi;
return new Size(e.Rect.Width, (int)(44 * dpi));
@@ -191,7 +191,7 @@ namespace Demo.Controls
StringFormat s_f = AntdUI.Helper.SF_NoWrap();
Bitmap bmp = null, bmp_ac = null;
public override void Paint(AntdUI.ICanvas g, AntdUI.VirtualPanelArgs e)
public override void Paint(AntdUI.Canvas g, AntdUI.VirtualPanelArgs e)
{
var dpi = AntdUI.Config.Dpi;
int icon_size = (int)(36 * dpi), text_size = (int)(24 * dpi), y = e.Rect.Y + (e.Rect.Height - (icon_size + text_size)) / 2;
@@ -206,23 +206,18 @@ namespace Demo.Controls
if (bmp_ac == null) bmp_ac = AntdUI.SvgExtend.SvgToBmp(Value, icon_size, icon_size, AntdUI.Style.Db.PrimaryColor);
g.Image(bmp_ac, rect_icon);
using (var fore = new SolidBrush(AntdUI.Style.Db.PrimaryColor))
{
g.String(Key, e.Panel.Font, fore, rect_text, s_f);
}
g.String(Key, e.Panel.Font, AntdUI.Style.Db.PrimaryColor, rect_text, s_f);
}
else
{
if (bmp == null) bmp = AntdUI.SvgExtend.SvgToBmp(Value, icon_size, icon_size, AntdUI.Style.Db.Text);
g.Image(bmp, rect_icon);
using (var fore = new SolidBrush(AntdUI.Style.Db.Text))
{
g.String(Key, e.Panel.Font, fore, rect_text, s_f);
}
g.String(Key, e.Panel.Font, AntdUI.Style.Db.Text, rect_text, s_f);
}
}
public override Size Size(AntdUI.ICanvas g, AntdUI.VirtualPanelArgs e)
public override Size Size(AntdUI.Canvas g, AntdUI.VirtualPanelArgs e)
{
var dpi = AntdUI.Config.Dpi;
return new Size((int)(200 * dpi), (int)(100 * dpi));

View File

@@ -128,7 +128,7 @@ namespace Demo.Controls
public VItem(Color d, int size = 100) { data = d; width = height = size; }
public VItem(Color d, int w, int h) { data = d; width = w; height = h; }
public override void Paint(AntdUI.ICanvas g, AntdUI.VirtualPanelArgs e)
public override void Paint(AntdUI.Canvas g, AntdUI.VirtualPanelArgs e)
{
var dpi = AntdUI.Config.Dpi;
using (var brush = new SolidBrush(data))
@@ -137,7 +137,7 @@ namespace Demo.Controls
}
}
public override Size Size(AntdUI.ICanvas g, AntdUI.VirtualPanelArgs e)
public override Size Size(AntdUI.Canvas g, AntdUI.VirtualPanelArgs e)
{
var dpi = AntdUI.Config.Dpi;
return new Size((int)(width * dpi), (int)(height * dpi));
@@ -239,7 +239,7 @@ namespace Demo.Controls
StringFormat s_f = new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center, Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap };
Bitmap bmp = null;
public override void Paint(AntdUI.ICanvas g, AntdUI.VirtualPanelArgs e)
public override void Paint(AntdUI.Canvas g, AntdUI.VirtualPanelArgs e)
{
var dpi = AntdUI.Config.Dpi;
if (bmp == null || bmp.Width != e.Rect.Width || bmp.Height != e.Rect.Height)
@@ -254,10 +254,7 @@ namespace Demo.Controls
g.Image(bmp, e.Rect);
using (var path = AntdUI.Helper.RoundPath(e.Rect, e.Radius))
{
using (var brush_bor = new Pen(AntdUI.Style.Db.BorderColor, 1.5F * dpi))
{
g.Draw(brush_bor, path);
}
g.Draw(AntdUI.Style.Db.BorderColor, 1.5F * dpi, path);
}
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
@@ -286,7 +283,7 @@ namespace Demo.Controls
}
}
public override Size Size(AntdUI.ICanvas g, AntdUI.VirtualPanelArgs e)
public override Size Size(AntdUI.Canvas g, AntdUI.VirtualPanelArgs e)
{
var dpi = AntdUI.Config.Dpi;
int count = 5, w = (e.Rect.Width - ((int)(20 * dpi) * count)) / count;

Binary file not shown.

View File

@@ -355,7 +355,7 @@ namespace AntdUI
/// <param name="rect">区域</param>
/// <param name="size">文字大小</param>
/// <param name="fore">文字颜色</param>
void PaintText(ICanvas g, RectangleF rect, SizeF size, Color fore)
void PaintText(Canvas g, RectangleF rect, SizeF size, Color fore)
{
using (var brush = new SolidBrush(fore))
{
@@ -409,7 +409,7 @@ namespace AntdUI
/// <param name="size">文字大小</param>
/// <param name="fore">文字颜色</param>
/// <param name="back">背景颜色</param>
void PaintText(ICanvas g, RectangleF rect, RectangleF rect_icon, SizeF size, Color fore, Color back, float radius)
void PaintText(Canvas g, RectangleF rect, RectangleF rect_icon, SizeF size, Color fore, Color back, float radius)
{
using (var brush_fore = new SolidBrush(fore))
{

View File

@@ -395,17 +395,13 @@ namespace AntdUI
if (borderWidth > 0) DrawRect(g, rect, borColor, borderWidth * Config.Dpi, _radius, round);
if (loading)
{
using (var pen = new Pen(Color.FromArgb(220, Style.Db.PrimaryColor), 6 * Config.Dpi))
using (var penpro = new Pen(Style.Db.Primary, pen.Width))
var bor6 = 6F * Config.Dpi;
int loading_size = (int)(40 * Config.Dpi);
var rect_loading = new Rectangle(rect.X + (rect.Width - loading_size) / 2, rect.Y + (rect.Height - loading_size) / 2, loading_size, loading_size);
g.DrawEllipse(Color.FromArgb(220, Style.Db.PrimaryColor), bor6, rect_loading);
using (var penpro = new Pen(Style.Db.Primary, bor6))
{
int loading_size = (int)(40 * Config.Dpi);
var rect_loading = new Rectangle(rect.X + (rect.Width - loading_size) / 2, rect.Y + (rect.Height - loading_size) / 2, loading_size, loading_size);
g.DrawEllipse(pen, rect_loading);
try
{
g.DrawArc(penpro, rect_loading, -90, 360F * _value);
}
catch { }
g.DrawArc(penpro, rect_loading, -90, 360F * _value);
}
}
this.PaintBadge(g);
@@ -416,7 +412,7 @@ namespace AntdUI
readonly StringFormat stringCenter = Helper.SF_ALL();
void FillRect(ICanvas g, Rectangle rect, Color color, float radius, bool round)
void FillRect(Canvas g, Rectangle rect, Color color, float radius, bool round)
{
using (var brush = new SolidBrush(color))
{
@@ -438,23 +434,17 @@ namespace AntdUI
}
}
void DrawRect(ICanvas g, Rectangle rect, Color color, float width, float radius, bool round)
void DrawRect(Canvas g, Rectangle rect, Color color, float width, float radius, bool round)
{
using (var pen = new Pen(color, width))
if (round) g.DrawEllipse(color, width, rect);
else if (radius > 0)
{
if (round)
using (var path = rect.RoundPath(radius))
{
g.DrawEllipse(pen, rect);
g.Draw(color, width, path);
}
else if (radius > 0)
{
using (var path = rect.RoundPath(radius))
{
g.Draw(pen, path);
}
}
else g.Draw(pen, rect);
}
else g.Draw(color, width, rect);
}
#endregion

View File

@@ -169,10 +169,7 @@ namespace AntdUI
if (state == TState.Processing)
{
float max = (size.Height - 6F) * AnimationStateValue, alpha = 255 * (1F - AnimationStateValue);
using (var pen = new Pen(Helper.ToColor(alpha, brush.Color), 4F))
{
g.DrawEllipse(pen, new RectangleF((rect.Width - max) / 2F, (rect.Height - max) / 2F, max, max));
}
g.DrawEllipse(Helper.ToColor(alpha, brush.Color), 4F * Config.Dpi, new RectangleF((rect.Width - max) / 2F, (rect.Height - max) / 2F, max, max));
}
}
}
@@ -187,10 +184,7 @@ namespace AntdUI
if (state == TState.Processing)
{
float max = (size.Height - 6F) * AnimationStateValue, alpha = 255 * (1F - AnimationStateValue);
using (var pen = new Pen(Helper.ToColor(alpha, brush.Color), 4F))
{
g.DrawEllipse(pen, new RectangleF(rect_dot.X + (rect_dot.Width - max) / 2F, rect_dot.Y + (rect_dot.Height - max) / 2F, max, max));
}
g.DrawEllipse(Helper.ToColor(alpha, brush.Color), 4F * Config.Dpi, new RectangleF(rect_dot.X + (rect_dot.Width - max) / 2F, rect_dot.Y + (rect_dot.Height - max) / 2F, max, max));
}
}
using (var brush = fore.Brush(Style.Db.Text, Style.Db.TextQuaternary, Enabled))

View File

@@ -141,6 +141,9 @@ namespace AntdUI
#endregion
Color fillfully = Color.FromArgb(0, 210, 121);
/// <summary>
/// 满电颜色
/// </summary>
[Description("满电颜色"), Category("外观"), DefaultValue(typeof(Color), "0, 210, 121")]
public Color FillFully
{
@@ -153,12 +156,30 @@ namespace AntdUI
}
}
/// <summary>
/// 警告电量颜色
/// </summary>
[Description("警告电量颜色"), Category("外观"), DefaultValue(typeof(Color), "250, 173, 20")]
public Color FillWarn { get; set; } = Color.FromArgb(250, 173, 20);
/// <summary>
/// 危险电量颜色
/// </summary>
[Description("危险电量颜色"), Category("外观"), DefaultValue(typeof(Color), "255, 77, 79")]
public Color FillDanger { get; set; } = Color.FromArgb(255, 77, 79);
/// <summary>
/// 警告电量阈值
/// </summary>
[Description("警告电量阈值"), Category("外观"), DefaultValue(30)]
public int ValueWarn { get; set; } = 30;
/// <summary>
/// 危险电量阈值
/// </summary>
[Description("危险电量阈值"), Category("外观"), DefaultValue(20)]
public int ValueDanger { get; set; } = 20;
#endregion
#region
@@ -215,8 +236,8 @@ namespace AntdUI
using (var g2 = Graphics.FromImage(bmp).High())
{
Color _color;
if (_value > 30) _color = fillfully;
else if (_value > 20) _color = FillWarn;
if (_value > ValueWarn) _color = fillfully;
else if (_value > ValueDanger) _color = FillWarn;
else _color = FillDanger;
g2.Fill(_color, path_pain);
var _w = rect.Width * (_value / 100F);

View File

@@ -261,7 +261,7 @@ namespace AntdUI
base.OnPaint(e);
}
bool PaintImg(ICanvas g, BreadcrumbItem it, Color color, string? svg, Image? bmp)
bool PaintImg(Canvas g, BreadcrumbItem it, Color color, string? svg, Image? bmp)
{
if (svg != null)
{

View File

@@ -1944,7 +1944,7 @@ namespace AntdUI
#region
public void Paint(ICanvas g, Rectangle rect, Rectangle rect_read)
public void Paint(Canvas g, Rectangle rect, Rectangle rect_read)
{
float _radius = (shape == TShape.Round || shape == TShape.Circle) ? rect_read.Height : radius * Config.Dpi;
@@ -2002,49 +2002,25 @@ namespace AntdUI
float border = borderWidth * Config.Dpi;
if (MouseDown)
{
using (var brush = new Pen(_back_active, border))
{
g.Draw(brush, path);
}
g.Draw(_back_active, border, path);
PaintTextLoading(g, text, _back_active, rect_read, control.Enabled);
}
else if (AnimationHover)
{
var colorHover = Helper.ToColor(AnimationHoverValue, _back_hover);
using (var brush = new Pen(Style.Db.DefaultBorder, border))
{
g.Draw(brush, path);
}
using (var brush = new Pen(colorHover, border))
{
g.Draw(brush, path);
}
g.Draw(Style.Db.DefaultBorder, border, path);
g.Draw(colorHover, border, path);
PaintTextLoading(g, text, _fore, colorHover, rect_read);
}
else if (MouseHover)
{
using (var brush = new Pen(_back_hover, border))
{
g.Draw(brush, path);
}
g.Draw(_back_hover, border, path);
PaintTextLoading(g, text, _back_hover, rect_read, control.Enabled);
}
else
{
if (AnimationBlinkState && colorBlink.HasValue)
{
using (var brush = new Pen(colorBlink.Value, border))
{
g.Draw(brush, path);
}
}
else
{
using (var brush = new Pen(defaultbordercolor ?? Style.Db.DefaultBorder, border))
{
g.Draw(brush, path);
}
}
if (AnimationBlinkState && colorBlink.HasValue) g.Draw(colorBlink.Value, border, path);
else g.Draw(defaultbordercolor ?? Style.Db.DefaultBorder, border, path);
PaintTextLoading(g, text, _fore, rect_read, control.Enabled);
}
}
@@ -2101,31 +2077,19 @@ namespace AntdUI
float border = borderWidth * Config.Dpi;
if (MouseDown)
{
using (var brush = new Pen(_back_active, border))
{
g.Draw(brush, path);
}
g.Draw(_back_active, border, path);
PaintTextLoading(g, text, _back_active, rect_read, control.Enabled);
}
else if (AnimationHover)
{
var colorHover = Helper.ToColor(AnimationHoverValue, _back_hover);
using (var brush = new Pen(control.Enabled ? _back : Style.Db.FillTertiary, border))
{
g.Draw(brush, path);
}
using (var brush = new Pen(colorHover, border))
{
g.Draw(brush, path);
}
g.Draw(control.Enabled ? _back : Style.Db.FillTertiary, border, path);
g.Draw(colorHover, border, path);
PaintTextLoading(g, text, _back, colorHover, rect_read);
}
else if (MouseHover)
{
using (var brush = new Pen(_back_hover, border))
{
g.Draw(brush, path);
}
g.Draw(_back_hover, border, path);
PaintTextLoading(g, text, _back_hover, rect_read, control.Enabled);
}
else
@@ -2136,30 +2100,18 @@ namespace AntdUI
{
using (var brushback = backExtendToggle.BrushEx(rect_read, _back))
{
using (var brush = new Pen(brushback, border))
{
g.Draw(brush, path);
}
g.Draw(brushback, border, path);
}
}
else
{
using (var brushback = backExtend.BrushEx(rect_read, _back))
{
using (var brush = new Pen(brushback, border))
{
g.Draw(brush, path);
}
g.Draw(brushback, border, path);
}
}
}
else
{
using (var brush = new Pen(Style.Db.FillTertiary, border))
{
g.Draw(brush, path);
}
}
else g.Draw(Style.Db.FillTertiary, border, path);
PaintTextLoading(g, text, control.Enabled ? _back : Style.Db.TextQuaternary, rect_read, control.Enabled);
}
}
@@ -2218,7 +2170,7 @@ namespace AntdUI
#region
void PaintLoadingWave(ICanvas g, GraphicsPath path, Rectangle rect)
void PaintLoadingWave(Canvas g, GraphicsPath path, Rectangle rect)
{
if (loading && LoadingWaveValue > 0)
{
@@ -2313,7 +2265,7 @@ namespace AntdUI
}
}
}
void PaintTextLoading(ICanvas g, string? text, Color color, Rectangle rect_read, bool enabled)
void PaintTextLoading(Canvas g, string? text, Color color, Rectangle rect_read, bool enabled)
{
var font_size = g.MeasureString(text ?? Config.NullText, Font());
if (text == null)
@@ -2439,7 +2391,7 @@ namespace AntdUI
}
}
}
void PaintTextLoading(ICanvas g, string? text, Color color, Color colorHover, Rectangle rect_read)
void PaintTextLoading(Canvas g, string? text, Color color, Color colorHover, Rectangle rect_read)
{
var font_size = g.MeasureString(text ?? Config.NullText, Font());
if (text == null)
@@ -2603,7 +2555,7 @@ namespace AntdUI
}
}
internal static Rectangle RectAlignL(ICanvas g, bool textLine, Font font, TAlignMini iconPosition, float iconratio, float icongap, Size font_size, Rectangle rect_read, out Rectangle rect_l)
internal static Rectangle RectAlignL(Canvas g, bool textLine, Font font, TAlignMini iconPosition, float iconratio, float icongap, Size font_size, Rectangle rect_read, out Rectangle rect_l)
{
int font_Height = font_size.Height;
if (textLine && (iconPosition == TAlignMini.Top || iconPosition == TAlignMini.Bottom)) font_Height = g.MeasureString(Config.NullText, font).Height;
@@ -2635,7 +2587,7 @@ namespace AntdUI
}
return rect_text;
}
internal static Rectangle RectAlignLR(ICanvas g, bool textLine, Font font, TAlignMini iconPosition, float iconratio, float icongap, Size font_size, Rectangle rect_read, out Rectangle rect_l, out Rectangle rect_r)
internal static Rectangle RectAlignLR(Canvas g, bool textLine, Font font, TAlignMini iconPosition, float iconratio, float icongap, Size font_size, Rectangle rect_read, out Rectangle rect_l, out Rectangle rect_r)
{
int font_Height = font_size.Height;
if (textLine && (iconPosition == TAlignMini.Top || iconPosition == TAlignMini.Bottom)) font_Height = g.MeasureString(Config.NullText, font).Height;
@@ -2671,7 +2623,7 @@ namespace AntdUI
}
return rect_text;
}
internal static Rectangle RectAlignR(ICanvas g, bool textLine, Font font, TAlignMini iconPosition, float iconratio, float icongap, Size font_size, Rectangle rect_read, out Rectangle rect_r)
internal static Rectangle RectAlignR(Canvas g, bool textLine, Font font, TAlignMini iconPosition, float iconratio, float icongap, Size font_size, Rectangle rect_read, out Rectangle rect_r)
{
int font_Height = font_size.Height;
if (textLine && (iconPosition == TAlignMini.Top || iconPosition == TAlignMini.Bottom)) font_Height = g.MeasureString(Config.NullText, font).Height;
@@ -2742,7 +2694,7 @@ namespace AntdUI
/// <param name="rect_o">区域</param>
/// <param name="hastxt">包含文本</param>
/// <param name="enabled">使能</param>
bool PaintIcon(ICanvas g, Color? color, Rectangle rect_o, bool hastxt, bool enabled)
bool PaintIcon(Canvas g, Color? color, Rectangle rect_o, bool hastxt, bool enabled)
{
var rect = hastxt ? GetIconRect(rect_o) : rect_o;
if (AnimationIconHover)
@@ -2802,10 +2754,10 @@ namespace AntdUI
else return rectl;
}
bool PaintCoreIcon(ICanvas g, Rectangle rect, Color? color, float opacity = 1F) => toggle ? PaintCoreIcon(g, iconToggle, iconSvgToggle, rect, color, opacity) : PaintCoreIcon(g, icon, iconSvg, rect, color, opacity);
bool PaintCoreIconHover(ICanvas g, Rectangle rect, Color? color, float opacity = 1F) => toggle ? PaintCoreIcon(g, ToggleIconHover, ToggleIconHoverSvg, rect, color, opacity) : PaintCoreIcon(g, IconHover, IconHoverSvg, rect, color, opacity);
bool PaintCoreIcon(Canvas g, Rectangle rect, Color? color, float opacity = 1F) => toggle ? PaintCoreIcon(g, iconToggle, iconSvgToggle, rect, color, opacity) : PaintCoreIcon(g, icon, iconSvg, rect, color, opacity);
bool PaintCoreIconHover(Canvas g, Rectangle rect, Color? color, float opacity = 1F) => toggle ? PaintCoreIcon(g, ToggleIconHover, ToggleIconHoverSvg, rect, color, opacity) : PaintCoreIcon(g, IconHover, IconHoverSvg, rect, color, opacity);
bool PaintCoreIcon(ICanvas g, Image? icon, string? iconSvg, Rectangle rect, Color? color, float opacity = 1F)
bool PaintCoreIcon(Canvas g, Image? icon, string? iconSvg, Rectangle rect, Color? color, float opacity = 1F)
{
if (iconSvg != null)
{

View File

@@ -499,7 +499,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintYear(ICanvas g, Rectangle rect_read, float radius, List<Calendari> datas)
void PrintYear(Canvas g, Rectangle rect_read, float radius, List<Calendari> datas)
{
using (var brush_fore_disable = new SolidBrush(Style.Db.TextQuaternary))
using (var brush_bg_disable = new SolidBrush(Style.Db.FillTertiary))
@@ -536,25 +536,13 @@ namespace AntdUI
else if (it.enable)
{
if (it.hover) g.Fill(Style.Db.FillTertiary, path);
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, it.t == 1 ? brush_fore : brush_fore_disable, it.rect, s_f);
}
else
{
g.Fill(brush_bg_disable, new Rectangle(it.rect.X, it.rect_read.Y, it.rect.Width, it.rect_read.Height));
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore_disable, it.rect, s_f);
}
}
@@ -573,7 +561,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintMonth(ICanvas g, Rectangle rect_read, float radius, List<Calendari> datas)
void PrintMonth(Canvas g, Rectangle rect_read, float radius, List<Calendari> datas)
{
using (var brush_fore_disable = new SolidBrush(Style.Db.TextQuaternary))
using (var brush_bg_disable = new SolidBrush(Style.Db.FillTertiary))
@@ -589,13 +577,7 @@ namespace AntdUI
g.String(_Date.ToString("yyyy") + YearButton, font, brush_hove, rect_month_l, s_f);
}
}
else if (hover_year.Switch)
{
using (var brush_hove = new SolidBrush(Style.Db.Primary))
{
g.String(_Date.ToString("yyyy") + YearButton, font, brush_hove, rect_month_l, s_f);
}
}
else if (hover_year.Switch) g.String(_Date.ToString("yyyy") + YearButton, font, Style.Db.Primary, rect_month_l, s_f);
else g.String(_Date.ToString("yyyy") + YearButton, font, brush_fore, rect_month_l, s_f);
}
@@ -611,25 +593,13 @@ namespace AntdUI
else if (it.enable)
{
if (it.hover) g.Fill(Style.Db.FillTertiary, path);
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore, it.rect, s_f);
}
else
{
g.Fill(brush_bg_disable, new Rectangle(it.rect.X, it.rect_read.Y, it.rect.Width, it.rect_read.Height));
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore_disable, it.rect, s_f);
}
}
@@ -651,7 +621,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintDay(ICanvas g, Rectangle rect_read, float radius, List<Calendari> datas)
void PrintDay(Canvas g, Rectangle rect_read, float radius, List<Calendari> datas)
{
if (rect_day_s == null) return;
using (var brush_fore = new SolidBrush(Style.Db.TextBase))
@@ -661,35 +631,17 @@ namespace AntdUI
if (hover_year.Animation)
{
g.String(_Date.ToString("yyyy") + YearButton, font, brush_fore, rect_day_l, s_f_L);
using (var brush_hove = new SolidBrush(Helper.ToColor(hover_year.Value, Style.Db.Primary)))
{
g.String(_Date.ToString("yyyy") + YearButton, font, brush_hove, rect_day_l, s_f_L);
}
}
else if (hover_year.Switch)
{
using (var brush_hove = new SolidBrush(Style.Db.Primary))
{
g.String(_Date.ToString("yyyy") + YearButton, font, brush_hove, rect_day_l, s_f_L);
}
g.String(_Date.ToString("yyyy") + YearButton, font, Helper.ToColor(hover_year.Value, Style.Db.Primary), rect_day_l, s_f_L);
}
else if (hover_year.Switch) g.String(_Date.ToString("yyyy") + YearButton, font, Style.Db.Primary, rect_day_l, s_f_L);
else g.String(_Date.ToString("yyyy") + YearButton, font, brush_fore, rect_day_l, s_f_L);
if (hover_month.Animation)
{
g.String(_Date.ToString("MM") + MonthButton, font, brush_fore, rect_day_r, s_f_R);
using (var brush_hove = new SolidBrush(Helper.ToColor(hover_month.Value, Style.Db.Primary)))
{
g.String(_Date.ToString("MM") + MonthButton, font, brush_hove, rect_day_r, s_f_R);
}
}
else if (hover_month.Switch)
{
using (var brush_hove = new SolidBrush(Style.Db.Primary))
{
g.String(_Date.ToString("MM") + MonthButton, font, brush_hove, rect_day_r, s_f_R);
}
g.String(_Date.ToString("MM") + MonthButton, font, Helper.ToColor(hover_month.Value, Style.Db.Primary), rect_day_r, s_f_R);
}
else if (hover_month.Switch) g.String(_Date.ToString("MM") + MonthButton, font, Style.Db.Primary, rect_day_r, s_f_R);
else g.String(_Date.ToString("MM") + MonthButton, font, brush_fore, rect_day_r, s_f_R);
}
@@ -810,7 +762,7 @@ namespace AntdUI
/// <summary>
/// 绘制今天边框
/// </summary>
internal static void PaintToDayFrame(ICanvas g, IList<Calendari> datas, string dateNow, float radius)
internal static void PaintToDayFrame(Canvas g, IList<Calendari> datas, string dateNow, float radius)
{
foreach (var it in datas)
{
@@ -818,10 +770,7 @@ namespace AntdUI
{
using (var path = it.rect_read.RoundPath(radius))
{
using (var pen_active = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(pen_active, path);
}
g.Draw(Style.Db.Primary, Config.Dpi, path);
}
return;
}
@@ -1194,8 +1143,8 @@ namespace AntdUI
rect_day_l = new Rectangle(rect.X, rect.Y, xm, t_top);
rect_day_r = new Rectangle(rect.X + xm, rect.Y, xm, t_top);
rect_day_split1 = new RectangleF(rect.X, rect.Y + t_top, rect.Width, 1F);
if (showButtonToDay) rect_day_split2 = new RectangleF(rect.X, rect_button.Y - .5F, rect.Width, 1);
rect_day_split1 = new RectangleF(rect.X, rect.Y + t_top, rect.Width, Config.Dpi);
if (showButtonToDay) rect_day_split2 = new RectangleF(rect.X, rect_button.Y - .5F, rect.Width, Config.Dpi);
rect_day_s = new Rectangle[]{
new Rectangle(rect.X + gap_day, y, size_w, size_h),
@@ -1224,8 +1173,8 @@ namespace AntdUI
rect_day_l = new Rectangle(rect.X, rect.Y, xm, t_top);
rect_day_r = new Rectangle(rect.X + xm, rect.Y, xm, t_top);
rect_day_split1 = new RectangleF(rect.X, rect.Y + t_top, rect.Width, 1F);
if (showButtonToDay) rect_day_split2 = new RectangleF(rect.X, rect_button.Y - .5F, rect.Width, 1);
rect_day_split1 = new RectangleF(rect.X, rect.Y + t_top, rect.Width, Config.Dpi);
if (showButtonToDay) rect_day_split2 = new RectangleF(rect.X, rect_button.Y - .5F, rect.Width, Config.Dpi);
rect_day_s = new Rectangle[]{
new Rectangle(rect.X + gap_day, y, size_w, size_h),
@@ -1255,8 +1204,8 @@ namespace AntdUI
rect_day_l = new Rectangle(rect.X, rect.Y, xm, t_top);
rect_day_r = new Rectangle(rect.X + xm, rect.Y, xm, t_top);
rect_day_split1 = new RectangleF(rect.X, rect.Y + t_top, rect.Width, 1F);
if (showButtonToDay) rect_day_split2 = new RectangleF(rect.X, rect_button.Y - .5F, rect.Width, 1);
rect_day_split1 = new RectangleF(rect.X, rect.Y + t_top, rect.Width, Config.Dpi);
if (showButtonToDay) rect_day_split2 = new RectangleF(rect.X, rect_button.Y - .5F, rect.Width, Config.Dpi);
rect_day_s = new Rectangle[]{
new Rectangle(rect.X + gap_day, y, size, size),

View File

@@ -629,7 +629,7 @@ namespace AntdUI
}
return bmp;
}
void PaintBmp(CarouselItemCollection items, CarouselRectPanel select_range, ICanvas g2, float radius)
void PaintBmp(CarouselItemCollection items, CarouselRectPanel select_range, Canvas g2, float radius)
{
foreach (var it in select_range.list)
{

View File

@@ -120,7 +120,7 @@ namespace AntdUI.Chat
StringFormat SFL = Helper.SF(tb: StringAlignment.Near);
void PaintItem(ICanvas g, IChatItem it, Rectangle rect, float sy, float radius)
void PaintItem(Canvas g, IChatItem it, Rectangle rect, float sy, float radius)
{
it.show = it.Show && it.rect.Y > sy - rect.Height - it.rect.Height && it.rect.Bottom < ScrollBar.Value + ScrollBar.ReadSize + it.rect.Height;
if (it.show)
@@ -158,7 +158,7 @@ namespace AntdUI.Chat
}
}
void PaintItemText(ICanvas g, TextChatItem text, SolidBrush fore)
void PaintItemText(Canvas g, TextChatItem text, SolidBrush fore)
{
if (text.selectionLength > 0)
{
@@ -582,7 +582,7 @@ namespace AntdUI.Chat
#region
internal Size FixFontWidth(ICanvas g, Font Font, TextChatItem item, int max_width, int spilt)
internal Size FixFontWidth(Canvas g, Font Font, TextChatItem item, int max_width, int spilt)
{
item.HasEmoji = false;
int font_height = 0;
@@ -832,7 +832,7 @@ namespace AntdUI.Chat
}
internal int SetRect(Rectangle _rect, int y, ICanvas g, Font font, Size msglen, int gap, int spilt, int spilt2, int image_size)
internal int SetRect(Rectangle _rect, int y, Canvas g, Font font, Size msglen, int gap, int spilt, int spilt2, int image_size)
{
if (string.IsNullOrEmpty(_name))
{

View File

@@ -82,7 +82,7 @@ namespace AntdUI.Chat
StringFormat SFBage = Helper.SF();
StringFormat SFL = Helper.SF_ALL(lr: StringAlignment.Near);
StringFormat SFR = Helper.SF_ALL(lr: StringAlignment.Far);
void PaintItem(ICanvas g, MsgItem it, Rectangle rect, float sy, Font font_text, Font font_time)
void PaintItem(Canvas g, MsgItem it, Rectangle rect, float sy, Font font_text, Font font_time)
{
it.show = it.Show && it.Visible && it.rect.Y > sy - rect.Height && it.rect.Bottom < ScrollBar.Value + ScrollBar.ReadSize + it.rect.Height;
if (it.show)

View File

@@ -211,7 +211,7 @@ namespace AntdUI
#region
internal void PaintChecked(ICanvas g, Rectangle rect, bool enabled, Rectangle icon_rect, bool right)
internal void PaintChecked(Canvas g, Rectangle rect, bool enabled, Rectangle icon_rect, bool right)
{
float dot_size = icon_rect.Height;
float radius = dot_size * .2F;
@@ -220,6 +220,7 @@ namespace AntdUI
{
if (enabled)
{
var bor2 = 2F * Config.Dpi;
var color = fill ?? Style.Db.Primary;
if (AnimationCheck)
{
@@ -237,62 +238,29 @@ namespace AntdUI
g.FillEllipse(brush, new RectangleF(icon_rect.X + (icon_rect.Width - max) / 2F, icon_rect.Y + (icon_rect.Height - max) / 2F, max, max));
}
}
using (var brush = new Pen(color, 2F * Config.Dpi))
{
g.Draw(brush, path);
}
g.Draw(color, bor2, path);
}
else if (_checked)
{
g.Fill(color, path);
using (var brush = new Pen(Style.Db.BgBase, 3F * Config.Dpi))
{
g.DrawLines(brush, icon_rect.CheckArrow());
}
g.DrawLines(Style.Db.BgBase, 3F * Config.Dpi, icon_rect.CheckArrow());
}
else
{
if (AnimationHover)
{
using (var brush = new Pen(Style.Db.BorderColor, 2F * Config.Dpi))
{
g.Draw(brush, path);
}
using (var brush = new Pen(Helper.ToColor(AnimationHoverValue, color), 2F * Config.Dpi))
{
g.Draw(brush, path);
}
}
else if (ExtraMouseHover)
{
using (var brush = new Pen(color, 2F * Config.Dpi))
{
g.Draw(brush, path);
}
}
else
{
using (var brush = new Pen(Style.Db.BorderColor, 2F * Config.Dpi))
{
g.Draw(brush, path);
}
g.Draw(Style.Db.BorderColor, bor2, path);
g.Draw(Helper.ToColor(AnimationHoverValue, color), bor2, path);
}
else if (ExtraMouseHover) g.Draw(color, bor2, path);
else g.Draw(Style.Db.BorderColor, bor2, path);
}
}
else
{
g.Fill(Style.Db.FillQuaternary, path);
if (_checked)
{
using (var brush = new Pen(Style.Db.TextQuaternary, 3F * Config.Dpi))
{
g.DrawLines(brush, icon_rect.CheckArrow());
}
}
using (var brush = new Pen(Style.Db.BorderColorDisable, 2F * Config.Dpi))
{
g.Draw(brush, path);
}
if (_checked) g.DrawLines(Style.Db.TextQuaternary, 3F * Config.Dpi, icon_rect.CheckArrow());
g.Draw(Style.Db.BorderColorDisable, 2F * Config.Dpi, path);
}
}
}

View File

@@ -485,7 +485,7 @@ namespace AntdUI
base.OnPaint(e);
}
void PaintItem(ICanvas g, CollapseItem item, SolidBrush fore, Pen pen_arr)
void PaintItem(Canvas g, CollapseItem item, SolidBrush fore, Pen pen_arr)
{
if (item.ExpandThread) PaintArrow(g, item, pen_arr, -90 + (90F * item.ExpandProg));
else if (item.Expand) g.DrawLines(pen_arr, item.RectArrow.TriangleLines(-1, .56F));
@@ -494,7 +494,7 @@ namespace AntdUI
g.String(item.Text, Font, fore, item.RectText, s_l);
}
void PaintItem(ICanvas g, CollapseItem item, SolidBrush fore)
void PaintItem(Canvas g, CollapseItem item, SolidBrush fore)
{
if (item.ExpandThread) PaintArrow(g, item, fore, -90 + (90F * item.ExpandProg));
else if (item.Expand) g.FillPolygon(fore, item.RectArrow.TriangleLines(-1, .56F));
@@ -503,7 +503,7 @@ namespace AntdUI
g.String(item.Text, Font, fore, item.RectText, s_l);
}
void PaintArrow(ICanvas g, CollapseItem item, Pen pen, float rotate)
void PaintArrow(Canvas g, CollapseItem item, Pen pen, float rotate)
{
var rect_arr = item.RectArrow;
int size_arrow = rect_arr.Width / 2;
@@ -512,7 +512,7 @@ namespace AntdUI
g.DrawLines(pen, new Rectangle(-size_arrow, -size_arrow, rect_arr.Width, rect_arr.Height).TriangleLines(-1, .56F));
g.ResetTransform();
}
void PaintArrow(ICanvas g, CollapseItem item, SolidBrush brush, float rotate)
void PaintArrow(Canvas g, CollapseItem item, SolidBrush brush, float rotate)
{
var rect_arr = item.RectArrow;
int size_arrow = rect_arr.Width / 2;

View File

@@ -195,7 +195,7 @@ namespace AntdUI
return _rect;
}
void ChangeList(ICanvas g, Rectangle rect, CollapseGroupItem Parent, CollapseGroupSubCollection items, ref int y, int font_height, int csize, int icon_size, int gap)
void ChangeList(Canvas g, Rectangle rect, CollapseGroupItem Parent, CollapseGroupSubCollection items, ref int y, int font_height, int csize, int icon_size, int gap)
{
int hasI = 0, tmp = 0;
foreach (var it in items)
@@ -248,7 +248,7 @@ namespace AntdUI
base.OnPaint(e);
}
void PaintItem(ICanvas g, Rectangle rect, int sx, int sy, CollapseGroupItemCollection items, SolidBrush fore, SolidBrush fore_active, SolidBrush hover, SolidBrush active, SolidBrush brush_TextQuaternary, float radius)
void PaintItem(Canvas g, Rectangle rect, int sx, int sy, CollapseGroupItemCollection items, SolidBrush fore, SolidBrush fore_active, SolidBrush hover, SolidBrush active, SolidBrush brush_TextQuaternary, float radius)
{
foreach (var it in items)
{
@@ -311,7 +311,7 @@ namespace AntdUI
}
}
void PaintBack(ICanvas g, CollapseGroupSub sub, SolidBrush brush)
void PaintBack(Canvas g, CollapseGroupSub sub, SolidBrush brush)
{
if (radius > 0)
{
@@ -335,7 +335,7 @@ namespace AntdUI
};
}
void PaintArrow(ICanvas g, CollapseGroupItem item, SolidBrush color, int sx, int sy)
void PaintArrow(Canvas g, CollapseGroupItem item, SolidBrush color, int sx, int sy)
{
using (var pen = new Pen(color, 2F))
{
@@ -346,7 +346,7 @@ namespace AntdUI
}
}
void PaintArrow(ICanvas g, CollapseGroupItem item, Pen pen, int sx, int sy, float rotate)
void PaintArrow(Canvas g, CollapseGroupItem item, Pen pen, int sx, int sy, float rotate)
{
int size = item.arr_rect.Width, size_arrow = size / 2;
g.TranslateTransform(item.arr_rect.X + size_arrow, item.arr_rect.Y + size_arrow);
@@ -724,7 +724,7 @@ namespace AntdUI
internal CollapseGroup? PARENT { get; set; }
internal void SetRect(ICanvas g, Rectangle _rect, int icon_size, int gap)
internal void SetRect(Canvas g, Rectangle _rect, int icon_size, int gap)
{
rect = _rect;
int x = _rect.X + gap, y = _rect.Y + (_rect.Height - icon_size) / 2;
@@ -989,7 +989,7 @@ namespace AntdUI
internal CollapseGroup? PARENT { get; set; }
public CollapseGroupItem? PARENTITEM { get; set; }
internal void SetRect(ICanvas g, Rectangle rect_read, int font_height, int xc, int icon_size)
internal void SetRect(Canvas g, Rectangle rect_read, int font_height, int xc, int icon_size)
{
rect = rect_read;
int sp = (int)(font_height * .25F), t_x = rect_read.Y + ((rect_read.Height - (font_height + icon_size + sp)) / 2);

View File

@@ -322,23 +322,21 @@ namespace AntdUI
g.Fill(_back, path);
if (borderWidth > 0)
{
var borWidth = borderWidth * Config.Dpi;
if (AnimationHover)
{
g.Draw(_border, borderWidth, path);
using (var brush = new Pen(Helper.ToColor(AnimationHoverValue, _borderHover), borderWidth))
{
g.Draw(brush, path);
}
g.Draw(_border, borWidth, path);
g.Draw(Helper.ToColor(AnimationHoverValue, _borderHover), borWidth, path);
}
else if (ExtraMouseDown) g.Draw(_borderActive, borderWidth, path);
else if (ExtraMouseHover) g.Draw(_borderHover, borderWidth, path);
else g.Draw(_border, borderWidth, path);
else if (ExtraMouseDown) g.Draw(_borderActive, borWidth, path);
else if (ExtraMouseHover) g.Draw(_borderHover, borWidth, path);
else g.Draw(_border, borWidth, path);
}
}
else
{
g.Fill(Style.Db.FillTertiary, path);
if (borderWidth > 0) g.Draw(_border, borderWidth, path);
if (borderWidth > 0) g.Draw(_border, borderWidth * Config.Dpi, path);
}
var r = _radius * 0.75F;
if (showText)
@@ -385,7 +383,7 @@ namespace AntdUI
}
Bitmap? bmp_alpha = null;
void PaintAlpha(ICanvas g, float radius, Rectangle rect)
void PaintAlpha(Canvas g, float radius, Rectangle rect)
{
if (bmp_alpha == null || bmp_alpha.Width != rect.Width || bmp_alpha.Height != rect.Height)
{
@@ -406,7 +404,7 @@ namespace AntdUI
g.Image(bmp_alpha, rect);
}
void PaintAlpha(ICanvas g, Rectangle rect)
void PaintAlpha(Canvas g, Rectangle rect)
{
int u_y = 0, size = rect.Height / 4;
bool ad = false;
@@ -440,7 +438,7 @@ namespace AntdUI
#region
internal void PaintClick(ICanvas g, GraphicsPath path, Rectangle rect, Color color, float radius)
internal void PaintClick(Canvas g, GraphicsPath path, Rectangle rect, Color color, float radius)
{
if (AnimationFocus)
{

View File

@@ -16,417 +16,127 @@
// CSDN: https://blog.csdn.net/v_132
// QQ: 17379620
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Windows.Forms;
namespace AntdUI.Core
namespace AntdUI
{
public class Canvas : ICanvas
public interface Canvas : IDisposable
{
Graphics g;
public Canvas(Graphics gdi)
{
g = gdi;
}
#region MeasureString
public Size MeasureString(string? text, Font font) => g.MeasureString(text, font).Size();
public Size MeasureString(string? text, Font font, int width) => g.MeasureString(text, font, width).Size();
public Size MeasureString(string? text, Font font, int width, StringFormat? format) => g.MeasureString(text, font, width, format).Size();
Size MeasureString(string? text, Font font);
Size MeasureString(string? text, Font font, int width);
Size MeasureString(string? text, Font font, int width, StringFormat? format);
#endregion
#region String
public void String(string? text, Font font, Color color, Rectangle rect) => TextRenderer.DrawText(g, text, font, rect, color);
public void String(string? text, Font font, Color color, Rectangle rect, TextFormatFlags flags) => TextRenderer.DrawText(g, text, font, rect, color, flags);
void String(string? text, Font font, Color color, Rectangle rect);
void String(string? text, Font font, Color color, Rectangle rect, TextFormatFlags flags);
public void String(string? text, Font font, Color color, Rectangle rect, StringFormat? format = null)
{
using (var brush = new SolidBrush(color))
{
String(text, font, brush, rect, format);
}
}
public void String(string? text, Font font, Brush brush, Rectangle rect, StringFormat? format = null)
{
CorrectionTextRendering.CORE(font, text, ref rect);
g.DrawString(text, font, brush, rect, format);
}
public void String(string? text, Font font, Brush brush, RectangleF rect, StringFormat? format = null)
{
CorrectionTextRendering.CORE(font, text, ref rect);
g.DrawString(text, font, brush, rect, format);
}
void String(string? text, Font font, Color color, Rectangle rect, StringFormat? format = null);
void String(string? text, Font font, Color color, RectangleF rect, StringFormat? format = null);
void String(string? text, Font font, Brush brush, Rectangle rect, StringFormat? format = null);
void String(string? text, Font font, Brush brush, RectangleF rect, StringFormat? format = null);
#endregion
#region Image
public void Image(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes? imageAttr)
{
try
{
g.DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttr, null);
}
catch { }
}
void Image(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes? imageAttr);
public void Image(Image image, float x, float y, float w, float h)
{
try
{
g.DrawImage(image, x, y, w, h);
}
catch { }
}
void Image(Image image, float x, float y, float w, float h);
public void Image(Image image, int srcX, int srcY, int srcWidth, int srcHeight)
{
try
{
g.DrawImage(image, srcX, srcY, srcWidth, srcHeight);
}
catch { }
}
public void Image(Bitmap image, Rectangle rect)
{
try
{
g.DrawImage(image, rect);
}
catch { }
}
public void Icon(System.Drawing.Icon icon, Rectangle rect)
{
try
{
g.DrawIcon(icon, rect);
}
catch { }
}
void Image(Image image, int srcX, int srcY, int srcWidth, int srcHeight);
void Image(Bitmap image, Rectangle rect);
void Icon(System.Drawing.Icon icon, Rectangle rect);
public void Image(Image image, Rectangle rect)
{
try
{
g.DrawImage(image, rect);
}
catch { }
}
public void Image(Image image, RectangleF rect)
{
try
{
g.DrawImage(image, rect);
}
catch { }
}
public void Image(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
{
try
{
g.DrawImage(image, destRect, srcRect, srcUnit);
}
catch { }
}
void Image(Image image, Rectangle rect);
void Image(Image image, RectangleF rect);
void Image(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit);
#region
public void Image(Bitmap bmp, Rectangle rect, float opacity)
{
try
{
if (opacity >= 1F)
{
g.DrawImage(bmp, rect);
return;
}
using (var attributes = new ImageAttributes())
{
var matrix = new ColorMatrix { Matrix33 = opacity };
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(bmp, rect, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, attributes);
}
}
catch { }
}
void Image(Bitmap bmp, Rectangle rect, float opacity);
public void Image(Image bmp, Rectangle rect, float opacity)
{
try
{
if (opacity >= 1F)
{
g.DrawImage(bmp, rect);
return;
}
using (var attributes = new ImageAttributes())
{
var matrix = new ColorMatrix { Matrix33 = opacity };
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(bmp, rect, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, attributes);
}
}
catch { }
}
void Image(Image bmp, Rectangle rect, float opacity);
#endregion
public void Image(RectangleF rect, Image image, TFit fit)
{
switch (fit)
{
case TFit.Fill:
g.DrawImage(image, rect);
break;
case TFit.None:
g.DrawImage(image, new RectangleF(rect.X + (rect.Width - image.Width) / 2, rect.Y + (rect.Height - image.Height) / 2, image.Width, image.Height));
break;
case TFit.Contain:
PaintImgContain(this, image, rect);
break;
case TFit.Cover:
PaintImgCover(this, image, rect);
break;
}
}
public void Image(RectangleF rect, Image image, TFit fit, float radius, bool round)
{
try
{
if (round || radius > 0)
{
using (var bmp = new Bitmap((int)rect.Width, (int)rect.Height))
{
using (var g2 = Graphics.FromImage(bmp).High())
{
PaintImg(g2, new RectangleF(0, 0, rect.Width, rect.Height), image, fit);
}
using (var brush = new TextureBrush(bmp, WrapMode.Clamp))
{
brush.TranslateTransform(rect.X, rect.Y);
if (round) g.FillEllipse(brush, rect);
else
{
using (var path = rect.RoundPath(radius))
{
g.FillPath(brush, path);
}
}
}
}
}
else PaintImg(this, rect, image, fit);
}
catch { }
}
public void Image(RectangleF rect, Image image, TFit fit, float radius, TShape shape)
{
try
{
if (shape == TShape.Circle || shape == TShape.Round || radius > 0)
{
using (var bmp = new Bitmap((int)rect.Width, (int)rect.Height))
{
using (var g2 = Graphics.FromImage(bmp).High())
{
PaintImg(g2, new RectangleF(0, 0, rect.Width, rect.Height), image, fit);
}
using (var brush = new TextureBrush(bmp, WrapMode.Clamp))
{
brush.TranslateTransform(rect.X, rect.Y);
if (shape == TShape.Circle) g.FillEllipse(brush, rect);
else
{
using (var path = rect.RoundPath(radius))
{
g.FillPath(brush, path);
}
}
}
}
}
else PaintImg(this, rect, image, fit);
}
catch { }
}
static void PaintImg(ICanvas g, RectangleF rect, Image image, TFit fit)
{
switch (fit)
{
case TFit.Fill:
g.Image(image, rect);
break;
case TFit.None:
g.Image(image, new RectangleF(rect.X + (rect.Width - image.Width) / 2, rect.Y + (rect.Height - image.Height) / 2, image.Width, image.Height));
break;
case TFit.Contain:
PaintImgContain(g, image, rect);
break;
case TFit.Cover:
PaintImgCover(g, image, rect);
break;
}
}
static void PaintImgCover(ICanvas g, Image image, RectangleF rect)
{
float originWidth = image.Width, originHeight = image.Height;
if (originWidth == originHeight)
{
if (rect.Width == rect.Height) g.Image(image, rect);
else if (rect.Width > rect.Height) g.Image(image, new RectangleF(0, (rect.Height - rect.Width) / 2, rect.Width, rect.Width));
else g.Image(image, new RectangleF((rect.Width - rect.Height) / 2, 0, rect.Height, rect.Height));
return;
}
float destWidth = rect.Width, destHeight = rect.Height;
float currentWidth, currentHeight;
if ((originWidth * destHeight) > (originHeight * destWidth))
{
currentHeight = destHeight;
currentWidth = (originWidth * destHeight) / originHeight;
}
else
{
currentWidth = destWidth;
currentHeight = (destWidth * originHeight) / originWidth;
}
g.Image(image, new RectangleF(rect.X + (destWidth - currentWidth) / 2, rect.Y + (destHeight - currentHeight) / 2, currentWidth, currentHeight), new RectangleF(0, 0, originWidth, originHeight), GraphicsUnit.Pixel);
}
static void PaintImgContain(ICanvas g, Image image, RectangleF rect)
{
float originWidth = image.Width, originHeight = image.Height;
if (originWidth == originHeight)
{
if (rect.Width == rect.Height) g.Image(image, rect);
else if (rect.Width > rect.Height) g.Image(image, new RectangleF((rect.Width - rect.Height) / 2, 0, rect.Height, rect.Height));
else g.Image(image, new RectangleF(0, (rect.Height - rect.Width) / 2, rect.Width, rect.Width));
return;
}
float destWidth = rect.Width, destHeight = rect.Height;
float currentWidth, currentHeight;
if ((originWidth * destHeight) > (originHeight * destWidth))
{
currentWidth = destWidth;
currentHeight = (destWidth * originHeight) / originWidth;
}
else
{
currentHeight = destHeight;
currentWidth = (originWidth * destHeight) / originHeight;
}
g.Image(image, new RectangleF(rect.X + (destWidth - currentWidth) / 2, rect.Y + (destHeight - currentHeight) / 2, currentWidth, currentHeight), new RectangleF(0, 0, originWidth, originHeight), GraphicsUnit.Pixel);
}
void Image(RectangleF rect, Image image, TFit fit, float radius, bool round);
void Image(RectangleF rect, Image image, TFit fit, float radius, TShape shape);
void Image(RectangleF rect, Image image, TFit fit);
#endregion
#region Fill
public void Fill(Color color, GraphicsPath path)
{
using (var brush = new SolidBrush(color))
{
Fill(brush, path);
}
}
public void Fill(Color color, Rectangle rect)
{
using (var brush = new SolidBrush(color))
{
g.FillRectangle(brush, rect);
}
}
public void Fill(Color color, RectangleF rect)
{
using (var brush = new SolidBrush(color))
{
g.FillRectangle(brush, rect);
}
}
public void Fill(Brush brush, GraphicsPath path) => g.FillPath(brush, path);
public void Fill(Brush brush, Rectangle rect) => g.FillRectangle(brush, rect);
public void Fill(Brush brush, int x, int y, int w, int h) => g.FillRectangle(brush, x, y, w, h);
public void Fill(Brush brush, RectangleF rect) => g.FillRectangle(brush, rect);
public void FillEllipse(Brush brush, Rectangle rect) => g.FillEllipse(brush, rect);
public void FillEllipse(Brush brush, RectangleF rect) => g.FillEllipse(brush, rect);
void Fill(Brush brush, GraphicsPath path);
void Fill(Brush brush, Rectangle rect);
void Fill(Brush brush, int x, int y, int w, int h);
void Fill(Brush brush, RectangleF rect);
public void FillPolygon(Brush brush, Point[] points) => g.FillPolygon(brush, points);
public void FillPolygon(Brush brush, PointF[] points) => g.FillPolygon(brush, points);
public void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle) => g.FillPie(brush, rect, startAngle, sweepAngle);
public void FillPie(Brush brush, float x, float y, float w, float h, float startAngle, float sweepAngle) => g.FillPie(brush, x, y, w, h, startAngle, sweepAngle);
void Fill(Color color, GraphicsPath path);
void Fill(Color color, Rectangle rect);
void Fill(Color color, RectangleF rect);
void FillEllipse(Brush brush, Rectangle rect);
void FillEllipse(Brush brush, RectangleF rect);
void FillEllipse(Color color, Rectangle rect);
void FillEllipse(Color color, RectangleF rect);
void FillPolygon(Brush brush, Point[] points);
void FillPolygon(Brush brush, PointF[] points);
void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle);
void FillPie(Brush brush, float x, float y, float w, float h, float startAngle, float sweepAngle);
#endregion
#region Draw
public void Draw(Brush brush, float width, GraphicsPath path)
{
using (var pen = new Pen(brush, width))
{
Draw(pen, path);
}
}
public void Draw(Color color, float width, GraphicsPath path)
{
using (var pen = new Pen(color, width))
{
Draw(pen, path);
}
}
public void Draw(Pen pen, GraphicsPath path) => g.DrawPath(pen, path);
public void Draw(Pen pen, Rectangle rect) => g.DrawRectangle(pen, rect);
public void DrawEllipse(Pen pen, Rectangle rect) => g.DrawEllipse(pen, rect);
public void DrawEllipse(Pen pen, RectangleF rect) => g.DrawEllipse(pen, rect);
public void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle)
{
try
{
g.DrawArc(pen, rect, startAngle, sweepAngle);
}
catch { }
}
public void DrawArc(Pen pen, RectangleF rect, float startAngle, float sweepAngle)
{
try
{
g.DrawArc(pen, rect, startAngle, sweepAngle);
}
catch { }
}
void Draw(Pen pen, GraphicsPath path);
void Draw(Pen pen, Rectangle rect);
void Draw(Color color, float width, GraphicsPath path);
void Draw(Brush brush, float width, GraphicsPath path);
void Draw(Color color, float width, Rectangle rect);
void Draw(Color color, float width, DashStyle dashStyle, GraphicsPath path);
public void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle) => g.DrawPie(pen, rect, startAngle, sweepAngle);
public void DrawPie(Pen pen, float x, float y, float w, float h, float startAngle, float sweepAngle) => g.DrawPie(pen, x, y, w, h, startAngle, sweepAngle);
void DrawEllipse(Pen pen, Rectangle rect);
void DrawEllipse(Pen pen, RectangleF rect);
void DrawEllipse(Color color, float width, RectangleF rect);
public void DrawLines(Pen pen, Point[] points) => g.DrawLines(pen, points);
public void DrawLines(Pen pen, PointF[] points) => g.DrawLines(pen, points);
public void DrawLine(Pen pen, float x, float y, float x2, float y2) => g.DrawLine(pen, x, y, x2, y2);
void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle);
void DrawArc(Pen pen, RectangleF rect, float startAngle, float sweepAngle);
void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle);
void DrawLines(Pen pen, Point[] points);
void DrawLines(Pen pen, PointF[] points);
void DrawLine(Pen pen, float x, float y, float x2, float y2);
void DrawLines(Color color, float width, PointF[] points);
#endregion
#region Base
public GraphicsState Save() => g.Save();
public void Restore(GraphicsState state) => g.Restore(state);
public void SetClip(Rectangle rect) => g.SetClip(rect);
public void SetClip(RectangleF rect) => g.SetClip(rect);
public void SetClip(GraphicsPath path) => g.SetClip(path);
public void ResetClip() => g.ResetClip();
public void ResetTransform() => g.ResetTransform();
public void TranslateTransform(float dx, float dy) => g.TranslateTransform(dx, dy);
public void RotateTransform(float angle) => g.RotateTransform(angle);
public float DpiX => g.DpiX;
public float DpiY => g.DpiY;
public CompositingMode CompositingMode
{
get => g.CompositingMode;
set => g.CompositingMode = value;
}
public void Dispose() => g.Dispose();
GraphicsState Save();
void Restore(GraphicsState state);
void SetClip(Rectangle rect);
void SetClip(RectangleF rect);
void SetClip(GraphicsPath path);
void ResetClip();
void ResetTransform();
void TranslateTransform(float dx, float dy);
void RotateTransform(float angle);
float DpiX { get; }
float DpiY { get; }
CompositingMode CompositingMode { get; set; }
#endregion
}

View File

@@ -0,0 +1,487 @@
// COPYRIGHT (C) Tom. ALL RIGHTS RESERVED.
// THE AntdUI PROJECT IS AN WINFORM LIBRARY LICENSED UNDER THE Apache-2.0 License.
// LICENSED UNDER THE Apache License, VERSION 2.0 (THE "License")
// YOU MAY NOT USE THIS FILE EXCEPT IN COMPLIANCE WITH THE License.
// YOU MAY OBTAIN A COPY OF THE LICENSE AT
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE
// DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND
// LIMITATIONS UNDER THE License.
// GITEE: https://gitee.com/antdui/AntdUI
// GITHUB: https://github.com/AntdUI/AntdUI
// CSDN: https://blog.csdn.net/v_132
// QQ: 17379620
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Windows.Forms;
namespace AntdUI.Core
{
public class CanvasGDI : Canvas
{
Graphics g;
public CanvasGDI(Graphics gdi)
{
g = gdi;
}
#region MeasureString
public Size MeasureString(string? text, Font font) => g.MeasureString(text, font).Size();
public Size MeasureString(string? text, Font font, int width) => g.MeasureString(text, font, width).Size();
public Size MeasureString(string? text, Font font, int width, StringFormat? format) => g.MeasureString(text, font, width, format).Size();
#endregion
#region String
public void String(string? text, Font font, Color color, Rectangle rect) => TextRenderer.DrawText(g, text, font, rect, color);
public void String(string? text, Font font, Color color, Rectangle rect, TextFormatFlags flags) => TextRenderer.DrawText(g, text, font, rect, color, flags);
public void String(string? text, Font font, Color color, Rectangle rect, StringFormat? format = null)
{
using (var brush = new SolidBrush(color))
{
String(text, font, brush, rect, format);
}
}
public void String(string? text, Font font, Color color, RectangleF rect, StringFormat? format = null)
{
using (var brush = new SolidBrush(color))
{
String(text, font, brush, rect, format);
}
}
public void String(string? text, Font font, Brush brush, Rectangle rect, StringFormat? format = null)
{
CorrectionTextRendering.CORE(font, text, ref rect);
g.DrawString(text, font, brush, rect, format);
}
public void String(string? text, Font font, Brush brush, RectangleF rect, StringFormat? format = null)
{
CorrectionTextRendering.CORE(font, text, ref rect);
g.DrawString(text, font, brush, rect, format);
}
#endregion
#region Image
public void Image(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes? imageAttr)
{
try
{
g.DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttr, null);
}
catch { }
}
public void Image(Image image, float x, float y, float w, float h)
{
try
{
g.DrawImage(image, x, y, w, h);
}
catch { }
}
public void Image(Image image, int srcX, int srcY, int srcWidth, int srcHeight)
{
try
{
g.DrawImage(image, srcX, srcY, srcWidth, srcHeight);
}
catch { }
}
public void Image(Bitmap image, Rectangle rect)
{
try
{
g.DrawImage(image, rect);
}
catch { }
}
public void Icon(System.Drawing.Icon icon, Rectangle rect)
{
try
{
g.DrawIcon(icon, rect);
}
catch { }
}
public void Image(Image image, Rectangle rect)
{
try
{
g.DrawImage(image, rect);
}
catch { }
}
public void Image(Image image, RectangleF rect)
{
try
{
g.DrawImage(image, rect);
}
catch { }
}
public void Image(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
{
try
{
g.DrawImage(image, destRect, srcRect, srcUnit);
}
catch { }
}
#region
public void Image(Bitmap bmp, Rectangle rect, float opacity)
{
try
{
if (opacity >= 1F)
{
g.DrawImage(bmp, rect);
return;
}
using (var attributes = new ImageAttributes())
{
var matrix = new ColorMatrix { Matrix33 = opacity };
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(bmp, rect, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, attributes);
}
}
catch { }
}
public void Image(Image bmp, Rectangle rect, float opacity)
{
try
{
if (opacity >= 1F)
{
g.DrawImage(bmp, rect);
return;
}
using (var attributes = new ImageAttributes())
{
var matrix = new ColorMatrix { Matrix33 = opacity };
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(bmp, rect, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, attributes);
}
}
catch { }
}
#endregion
public void Image(RectangleF rect, Image image, TFit fit)
{
switch (fit)
{
case TFit.Fill:
g.DrawImage(image, rect);
break;
case TFit.None:
g.DrawImage(image, new RectangleF(rect.X + (rect.Width - image.Width) / 2, rect.Y + (rect.Height - image.Height) / 2, image.Width, image.Height));
break;
case TFit.Contain:
PaintImgContain(this, image, rect);
break;
case TFit.Cover:
PaintImgCover(this, image, rect);
break;
}
}
public void Image(RectangleF rect, Image image, TFit fit, float radius, bool round)
{
try
{
if (round || radius > 0)
{
using (var bmp = new Bitmap((int)rect.Width, (int)rect.Height))
{
using (var g2 = Graphics.FromImage(bmp).High())
{
PaintImg(g2, new RectangleF(0, 0, rect.Width, rect.Height), image, fit);
}
using (var brush = new TextureBrush(bmp, WrapMode.Clamp))
{
brush.TranslateTransform(rect.X, rect.Y);
if (round) g.FillEllipse(brush, rect);
else
{
using (var path = rect.RoundPath(radius))
{
g.FillPath(brush, path);
}
}
}
}
}
else PaintImg(this, rect, image, fit);
}
catch { }
}
public void Image(RectangleF rect, Image image, TFit fit, float radius, TShape shape)
{
try
{
if (shape == TShape.Circle || shape == TShape.Round || radius > 0)
{
using (var bmp = new Bitmap((int)rect.Width, (int)rect.Height))
{
using (var g2 = Graphics.FromImage(bmp).High())
{
PaintImg(g2, new RectangleF(0, 0, rect.Width, rect.Height), image, fit);
}
using (var brush = new TextureBrush(bmp, WrapMode.Clamp))
{
brush.TranslateTransform(rect.X, rect.Y);
if (shape == TShape.Circle) g.FillEllipse(brush, rect);
else
{
using (var path = rect.RoundPath(radius))
{
g.FillPath(brush, path);
}
}
}
}
}
else PaintImg(this, rect, image, fit);
}
catch { }
}
static void PaintImg(Canvas g, RectangleF rect, Image image, TFit fit)
{
switch (fit)
{
case TFit.Fill:
g.Image(image, rect);
break;
case TFit.None:
g.Image(image, new RectangleF(rect.X + (rect.Width - image.Width) / 2, rect.Y + (rect.Height - image.Height) / 2, image.Width, image.Height));
break;
case TFit.Contain:
PaintImgContain(g, image, rect);
break;
case TFit.Cover:
PaintImgCover(g, image, rect);
break;
}
}
static void PaintImgCover(Canvas g, Image image, RectangleF rect)
{
float originWidth = image.Width, originHeight = image.Height;
if (originWidth == originHeight)
{
if (rect.Width == rect.Height) g.Image(image, rect);
else if (rect.Width > rect.Height) g.Image(image, new RectangleF(0, (rect.Height - rect.Width) / 2, rect.Width, rect.Width));
else g.Image(image, new RectangleF((rect.Width - rect.Height) / 2, 0, rect.Height, rect.Height));
return;
}
float destWidth = rect.Width, destHeight = rect.Height;
float currentWidth, currentHeight;
if ((originWidth * destHeight) > (originHeight * destWidth))
{
currentHeight = destHeight;
currentWidth = (originWidth * destHeight) / originHeight;
}
else
{
currentWidth = destWidth;
currentHeight = (destWidth * originHeight) / originWidth;
}
g.Image(image, new RectangleF(rect.X + (destWidth - currentWidth) / 2, rect.Y + (destHeight - currentHeight) / 2, currentWidth, currentHeight), new RectangleF(0, 0, originWidth, originHeight), GraphicsUnit.Pixel);
}
static void PaintImgContain(Canvas g, Image image, RectangleF rect)
{
float originWidth = image.Width, originHeight = image.Height;
if (originWidth == originHeight)
{
if (rect.Width == rect.Height) g.Image(image, rect);
else if (rect.Width > rect.Height) g.Image(image, new RectangleF((rect.Width - rect.Height) / 2, 0, rect.Height, rect.Height));
else g.Image(image, new RectangleF(0, (rect.Height - rect.Width) / 2, rect.Width, rect.Width));
return;
}
float destWidth = rect.Width, destHeight = rect.Height;
float currentWidth, currentHeight;
if ((originWidth * destHeight) > (originHeight * destWidth))
{
currentWidth = destWidth;
currentHeight = (destWidth * originHeight) / originWidth;
}
else
{
currentHeight = destHeight;
currentWidth = (originWidth * destHeight) / originHeight;
}
g.Image(image, new RectangleF(rect.X + (destWidth - currentWidth) / 2, rect.Y + (destHeight - currentHeight) / 2, currentWidth, currentHeight), new RectangleF(0, 0, originWidth, originHeight), GraphicsUnit.Pixel);
}
#endregion
#region Fill
public void Fill(Brush brush, GraphicsPath path) => g.FillPath(brush, path);
public void Fill(Brush brush, Rectangle rect) => g.FillRectangle(brush, rect);
public void Fill(Brush brush, int x, int y, int w, int h) => g.FillRectangle(brush, x, y, w, h);
public void Fill(Brush brush, RectangleF rect) => g.FillRectangle(brush, rect);
public void Fill(Color color, GraphicsPath path)
{
using (var brush = new SolidBrush(color))
{
Fill(brush, path);
}
}
public void Fill(Color color, Rectangle rect)
{
using (var brush = new SolidBrush(color))
{
Fill(brush, rect);
}
}
public void Fill(Color color, RectangleF rect)
{
using (var brush = new SolidBrush(color))
{
Fill(brush, rect);
}
}
public void FillEllipse(Brush brush, Rectangle rect) => g.FillEllipse(brush, rect);
public void FillEllipse(Brush brush, RectangleF rect) => g.FillEllipse(brush, rect);
public void FillEllipse(Color color, Rectangle rect)
{
using (var brush = new SolidBrush(color))
{
FillEllipse(brush, rect);
}
}
public void FillEllipse(Color color, RectangleF rect)
{
using (var brush = new SolidBrush(color))
{
FillEllipse(brush, rect);
}
}
public void FillPolygon(Brush brush, Point[] points) => g.FillPolygon(brush, points);
public void FillPolygon(Brush brush, PointF[] points) => g.FillPolygon(brush, points);
public void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle) => g.FillPie(brush, rect, startAngle, sweepAngle);
public void FillPie(Brush brush, float x, float y, float w, float h, float startAngle, float sweepAngle) => g.FillPie(brush, x, y, w, h, startAngle, sweepAngle);
#endregion
#region Draw
public void Draw(Pen pen, GraphicsPath path) => g.DrawPath(pen, path);
public void Draw(Pen pen, Rectangle rect) => g.DrawRectangle(pen, rect);
public void Draw(Brush brush, float width, GraphicsPath path)
{
using (var pen = new Pen(brush, width))
{
Draw(pen, path);
}
}
public void Draw(Color color, float width, GraphicsPath path)
{
using (var pen = new Pen(color, width))
{
Draw(pen, path);
}
}
public void Draw(Color color, float width, Rectangle rect)
{
using (var pen = new Pen(color, width))
{
Draw(pen, rect);
}
}
public void Draw(Color color, float width, DashStyle dashStyle, GraphicsPath path)
{
using (var pen = new Pen(color, width))
{
pen.DashStyle = dashStyle;
Draw(pen, path);
}
}
public void DrawEllipse(Pen pen, Rectangle rect) => g.DrawEllipse(pen, rect);
public void DrawEllipse(Pen pen, RectangleF rect) => g.DrawEllipse(pen, rect);
public void DrawEllipse(Color color, float width, RectangleF rect)
{
using (var pen = new Pen(color, width))
{
g.DrawEllipse(pen, rect);
}
}
public void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle)
{
try
{
g.DrawArc(pen, rect, startAngle, sweepAngle);
}
catch { }
}
public void DrawArc(Pen pen, RectangleF rect, float startAngle, float sweepAngle)
{
try
{
g.DrawArc(pen, rect, startAngle, sweepAngle);
}
catch { }
}
public void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle) => g.DrawPie(pen, rect, startAngle, sweepAngle);
public void DrawLines(Pen pen, Point[] points) => g.DrawLines(pen, points);
public void DrawLines(Pen pen, PointF[] points) => g.DrawLines(pen, points);
public void DrawLine(Pen pen, float x, float y, float x2, float y2) => g.DrawLine(pen, x, y, x2, y2);
public void DrawLines(Color color, float width, PointF[] points)
{
using (var pen = new Pen(color, width))
{
DrawLines(pen, points);
}
}
#endregion
#region Base
public GraphicsState Save() => g.Save();
public void Restore(GraphicsState state) => g.Restore(state);
public void SetClip(Rectangle rect) => g.SetClip(rect);
public void SetClip(RectangleF rect) => g.SetClip(rect);
public void SetClip(GraphicsPath path) => g.SetClip(path);
public void ResetClip() => g.ResetClip();
public void ResetTransform() => g.ResetTransform();
public void TranslateTransform(float dx, float dy) => g.TranslateTransform(dx, dy);
public void RotateTransform(float angle) => g.RotateTransform(angle);
public float DpiX => g.DpiX;
public float DpiY => g.DpiY;
public CompositingMode CompositingMode
{
get => g.CompositingMode;
set => g.CompositingMode = value;
}
public void Dispose() => g.Dispose();
#endregion
}
}

View File

@@ -1,133 +0,0 @@
// COPYRIGHT (C) Tom. ALL RIGHTS RESERVED.
// THE AntdUI PROJECT IS AN WINFORM LIBRARY LICENSED UNDER THE Apache-2.0 License.
// LICENSED UNDER THE Apache License, VERSION 2.0 (THE "License")
// YOU MAY NOT USE THIS FILE EXCEPT IN COMPLIANCE WITH THE License.
// YOU MAY OBTAIN A COPY OF THE LICENSE AT
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE
// DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND
// LIMITATIONS UNDER THE License.
// GITEE: https://gitee.com/antdui/AntdUI
// GITHUB: https://github.com/AntdUI/AntdUI
// CSDN: https://blog.csdn.net/v_132
// QQ: 17379620
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Windows.Forms;
namespace AntdUI
{
public interface ICanvas : IDisposable
{
#region MeasureString
Size MeasureString(string? text, Font font);
Size MeasureString(string? text, Font font, int width);
Size MeasureString(string? text, Font font, int width, StringFormat? format);
#endregion
#region String
void String(string? text, Font font, Color color, Rectangle rect);
void String(string? text, Font font, Color color, Rectangle rect, TextFormatFlags flags);
void String(string? text, Font font, Color color, Rectangle rect, StringFormat? format = null);
void String(string? text, Font font, Brush brush, Rectangle rect, StringFormat? format = null);
void String(string? text, Font font, Brush brush, RectangleF rect, StringFormat? format = null);
#endregion
#region Image
void Image(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes? imageAttr);
void Image(Image image, float x, float y, float w, float h);
void Image(Image image, int srcX, int srcY, int srcWidth, int srcHeight);
void Image(Bitmap image, Rectangle rect);
void Icon(System.Drawing.Icon icon, Rectangle rect);
void Image(Image image, Rectangle rect);
void Image(Image image, RectangleF rect);
void Image(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit);
#region
void Image(Bitmap bmp, Rectangle rect, float opacity);
void Image(Image bmp, Rectangle rect, float opacity);
#endregion
void Image(RectangleF rect, Image image, TFit fit, float radius, bool round);
void Image(RectangleF rect, Image image, TFit fit, float radius, TShape shape);
void Image(RectangleF rect, Image image, TFit fit);
#endregion
#region Fill
void Fill(Color color, GraphicsPath path);
void Fill(Color color, Rectangle rect);
void Fill(Color color, RectangleF rect);
void Fill(Brush brush, GraphicsPath path);
void Fill(Brush brush, Rectangle rect);
void Fill(Brush brush, int x, int y, int w, int h);
void Fill(Brush brush, RectangleF rect);
void FillEllipse(Brush brush, Rectangle rect);
void FillEllipse(Brush brush, RectangleF rect);
void FillPolygon(Brush brush, Point[] points);
void FillPolygon(Brush brush, PointF[] points);
void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle);
void FillPie(Brush brush, float x, float y, float w, float h, float startAngle, float sweepAngle);
#endregion
#region Draw
void Draw(Brush brush, float width, GraphicsPath path);
void Draw(Color color, float width, GraphicsPath path);
void Draw(Pen pen, GraphicsPath path);
void Draw(Pen pen, Rectangle rect);
void DrawEllipse(Pen pen, Rectangle rect);
void DrawEllipse(Pen pen, RectangleF rect);
void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle);
void DrawArc(Pen pen, RectangleF rect, float startAngle, float sweepAngle);
void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle);
void DrawPie(Pen pen, float x, float y, float w, float h, float startAngle, float sweepAngle);
void DrawLines(Pen pen, Point[] points);
void DrawLines(Pen pen, PointF[] points);
void DrawLine(Pen pen, float x, float y, float x2, float y2);
#endregion
#region Base
GraphicsState Save();
void Restore(GraphicsState state);
void SetClip(Rectangle rect);
void SetClip(RectangleF rect);
void SetClip(GraphicsPath path);
void ResetClip();
void ResetTransform();
void TranslateTransform(float dx, float dy);
void RotateTransform(float angle);
float DpiX { get; }
float DpiY { get; }
CompositingMode CompositingMode { get; set; }
#endregion
}
}

View File

@@ -148,7 +148,7 @@ namespace AntdUI
get => showicon;
}
protected override void PaintRIcon(ICanvas g, Rectangle rect_r)
protected override void PaintRIcon(Canvas g, Rectangle rect_r)
{
if (showicon)
{

View File

@@ -240,7 +240,7 @@ namespace AntdUI
get => showicon;
}
protected override void PaintRIcon(ICanvas g, Rectangle rect_r)
protected override void PaintRIcon(Canvas g, Rectangle rect_r)
{
if (showicon)
{
@@ -511,7 +511,7 @@ namespace AntdUI
}
}
}
protected override void PaintOtherBor(ICanvas g, RectangleF rect_read, float radius, Color back, Color borderColor, Color borderActive)
protected override void PaintOtherBor(Canvas g, RectangleF rect_read, float radius, Color back, Color borderColor, Color borderActive)
{
if ((showS && placeholderS != null) || (showE && placeholderE != null))
{

View File

@@ -323,14 +323,14 @@ namespace AntdUI
#region
internal void PaintText(ICanvas g, string? text, Rectangle path, StringFormat stringFormat, bool enabled)
internal void PaintText(Canvas g, string? text, Rectangle path, StringFormat stringFormat, bool enabled)
{
using (var brush = new SolidBrush(enabled ? ForeColor : Style.Db.TextQuaternary))
{
g.String(text, Font, brush, path, stringFormat);
}
}
internal void PaintText(ICanvas g, string? text, RectangleF path, StringFormat stringFormat, bool enabled)
internal void PaintText(Canvas g, string? text, RectangleF path, StringFormat stringFormat, bool enabled)
{
using (var brush = new SolidBrush(enabled ? ForeColor : Style.Db.TextQuaternary))
{

View File

@@ -319,7 +319,7 @@ namespace AntdUI
#region
void FillRect(ICanvas g, RectangleF rect, Color color, float radius, bool round)
void FillRect(Canvas g, RectangleF rect, Color color, float radius, bool round)
{
using (var brush = new SolidBrush(color))
{

View File

@@ -51,7 +51,7 @@ namespace AntdUI
base.OnPaint(e);
}
internal void IPaint(ICanvas g, Rectangle rect, Rectangle rect_read)
internal void IPaint(Canvas g, Rectangle rect, Rectangle rect_read)
{
float _radius = round ? rect_read.Height : radius * Config.Dpi;
if (backImage != null) g.Image(rect_read, backImage, backFit, _radius, false);
@@ -96,38 +96,15 @@ namespace AntdUI
PaintScroll(g, rect_read, _radius);
if (borderWidth > 0)
{
var borWidth = borderWidth * Config.Dpi;
if (AnimationHover)
{
using (var brush = new Pen(_border, borderWidth))
{
g.Draw(brush, path);
}
using (var brush = new Pen(Helper.ToColor(AnimationHoverValue, _borderHover), borderWidth))
{
g.Draw(brush, path);
}
}
else if (ExtraMouseDown)
{
using (var brush = new Pen(_borderActive, borderWidth))
{
g.Draw(brush, path);
}
}
else if (ExtraMouseHover)
{
using (var brush = new Pen(_borderHover, borderWidth))
{
g.Draw(brush, path);
}
}
else
{
using (var brush = new Pen(_border, borderWidth))
{
g.Draw(brush, path);
}
g.Draw(_border, borWidth, path);
g.Draw(Helper.ToColor(AnimationHoverValue, _borderHover), borWidth, path);
}
else if (ExtraMouseDown) g.Draw(_borderActive, borWidth, path);
else if (ExtraMouseHover) g.Draw(_borderHover, borWidth, path);
else g.Draw(_border, borWidth, path);
}
}
else
@@ -137,27 +114,25 @@ namespace AntdUI
PaintText(g, Style.Db.TextQuaternary, rect_read.Right, rect_read.Bottom);
PaintOtherBor(g, rect_read, _radius, _back, _border, _borderActive);
PaintScroll(g, rect_read, _radius);
if (borderWidth > 0) g.Draw(_border, borderWidth, path);
if (borderWidth > 0) g.Draw(_border, borderWidth * Config.Dpi, path);
}
}
}
void PaintScroll(ICanvas g, Rectangle rect_read, float _radius)
void PaintScroll(Canvas g, Rectangle rect_read, float _radius)
{
if (ScrollYShow && autoscroll)
{
int SIZE = 20;
ScrollRect = new Rectangle(rect_read.Right - SIZE, rect_read.Y, SIZE, rect_read.Height);
using (var brush = new SolidBrush(Color.FromArgb(10, Style.Db.TextBase)))
var color = Color.FromArgb(10, Style.Db.TextBase);
if (JoinRight) g.Fill(color, ScrollRect);
else
{
if (JoinRight) g.Fill(brush, ScrollRect);
else
using (var pathScroll = Helper.RoundPath(ScrollRect, _radius, false, true, true, false))
{
using (var pathScroll = Helper.RoundPath(ScrollRect, _radius, false, true, true, false))
{
g.Fill(brush, pathScroll);
}
g.Fill(color, pathScroll);
}
}
@@ -178,7 +153,7 @@ namespace AntdUI
#region
void PaintIcon(ICanvas g, Color _fore)
void PaintIcon(Canvas g, Color _fore)
{
if (prefixText != null)
{
@@ -203,7 +178,7 @@ namespace AntdUI
else PaintRIcon(g, rect_r);
}
void PaintText(ICanvas g, Color _fore, int w, int h)
void PaintText(Canvas g, Color _fore, int w, int h)
{
if (multiline) g.SetClip(rect_text);
else if (RECTDIV.HasValue) g.SetClip(RECTDIV.Value);
@@ -263,7 +238,7 @@ namespace AntdUI
g.ResetTransform();
}
}
void PaintTextSelected(ICanvas g, CacheFont[] cache_font)
void PaintTextSelected(Canvas g, CacheFont[] cache_font)
{
if (selectionLength > 0 && cache_font.Length > selectionStartTemp && !BanInput)
{
@@ -292,13 +267,13 @@ namespace AntdUI
}
}
protected virtual void PaintRIcon(ICanvas g, Rectangle rect) { }
protected virtual void PaintRIcon(Canvas g, Rectangle rect) { }
protected virtual void PaintOtherBor(ICanvas g, RectangleF rect_read, float radius, Color back, Color borderColor, Color borderActive) { }
protected virtual void PaintOtherBor(Canvas g, RectangleF rect_read, float radius, Color back, Color borderColor, Color borderActive) { }
#region
internal void PaintClick(ICanvas g, GraphicsPath path, Rectangle rect, Color color, float radius)
internal void PaintClick(Canvas g, GraphicsPath path, Rectangle rect, Color color, float radius)
{
if (AnimationFocus)
{

View File

@@ -1389,7 +1389,7 @@ namespace AntdUI
Input control;
public ICaret(Input input) { control = input; }
public Rectangle Rect = new Rectangle(-1, -1000, (int)(1 * Config.Dpi), 0);
public Rectangle Rect = new Rectangle(-1, -1000, (int)Config.Dpi, 0);
public bool Place = false;

View File

@@ -241,7 +241,7 @@ namespace AntdUI
return false;
}
protected override void PaintOtherBor(ICanvas g, RectangleF rect_read, float _radius, Color back, Color borColor, Color borderActive)
protected override void PaintOtherBor(Canvas g, RectangleF rect_read, float _radius, Color back, Color borColor, Color borderActive)
{
if (hover_button.Animation || hover_button.Switch)
{
@@ -258,7 +258,7 @@ namespace AntdUI
if (hover_button.Animation)
{
using (var pen = new Pen(Helper.ToColor(hover_button.Value, borColor), 1 * Config.Dpi))
using (var pen = new Pen(Helper.ToColor(hover_button.Value, borColor), Config.Dpi))
{
using (var path = rect_button_up.RoundPath(radius, false, true, false, false))
{
@@ -272,7 +272,7 @@ namespace AntdUI
}
else if (hover_button.Switch)
{
using (var pen = new Pen(borColor, 1 * Config.Dpi))
using (var pen = new Pen(borColor, Config.Dpi))
{
using (var path = rect_button_up.RoundPath(radius, false, true, false, false))
{
@@ -287,7 +287,7 @@ namespace AntdUI
if (hover_button_up.Animation)
{
using (var pen_def = new Pen(borColor, 1 * Config.Dpi))
using (var pen_def = new Pen(borColor, Config.Dpi))
{
g.DrawLines(pen_def, TAlignMini.Top.TriangleLines(rect_button_up));
using (var brush_hove = new Pen(Helper.ToColor(hover_button_up.Value, borderActive), pen_def.Width))
@@ -298,14 +298,14 @@ namespace AntdUI
}
else if (hover_button_up.Switch)
{
using (var pen = new Pen(borderActive, 1 * Config.Dpi))
using (var pen = new Pen(borderActive, Config.Dpi))
{
g.DrawLines(pen, TAlignMini.Top.TriangleLines(rect_button_up));
}
}
else
{
using (var pen_def = new Pen(borColor, 1 * Config.Dpi))
using (var pen_def = new Pen(borColor, Config.Dpi))
{
g.DrawLines(pen_def, TAlignMini.Top.TriangleLines(rect_button_up));
}
@@ -313,7 +313,7 @@ namespace AntdUI
if (hover_button_bottom.Animation)
{
using (var pen_def = new Pen(borColor, 1 * Config.Dpi))
using (var pen_def = new Pen(borColor, Config.Dpi))
{
g.DrawLines(pen_def, TAlignMini.Bottom.TriangleLines(rect_button_bottom));
using (var brush_hove = new Pen(Helper.ToColor(hover_button_bottom.Value, borderActive), pen_def.Width))
@@ -324,14 +324,14 @@ namespace AntdUI
}
else if (hover_button_bottom.Switch)
{
using (var pen = new Pen(borderActive, 1 * Config.Dpi))
using (var pen = new Pen(borderActive, Config.Dpi))
{
g.DrawLines(pen, TAlignMini.Bottom.TriangleLines(rect_button_bottom));
}
}
else
{
using (var pen_def = new Pen(borColor, 1 * Config.Dpi))
using (var pen_def = new Pen(borColor, Config.Dpi))
{
g.DrawLines(pen_def, TAlignMini.Bottom.TriangleLines(rect_button_bottom));
}

View File

@@ -369,7 +369,7 @@ namespace AntdUI
#region
bool ellipsis = false;
void PaintText(ICanvas g, string? text, Color color, Rectangle rect_read)
void PaintText(Canvas g, string? text, Color color, Rectangle rect_read)
{
if (!string.IsNullOrEmpty(text))
{
@@ -405,7 +405,7 @@ namespace AntdUI
}
}
Rectangle PaintTextLeft(ICanvas g, Color color, Rectangle rect_read, Size font_size, bool has_prefixText, bool has_suffixText, bool has_prefix, bool has_suffix)
Rectangle PaintTextLeft(Canvas g, Color color, Rectangle rect_read, Size font_size, bool has_prefixText, bool has_suffixText, bool has_prefix, bool has_suffix)
{
int hx = 0;
if (has_prefixText)
@@ -457,7 +457,7 @@ namespace AntdUI
if (hx > 0) return new Rectangle(rect_read.X + hx, rect_read.Y, rect_read.Width - hx, rect_read.Height);
return rect_read;
}
Rectangle PaintTextRight(ICanvas g, Color color, Rectangle rect_read, Size font_size, bool has_prefixText, bool has_suffixText, bool has_prefix, bool has_suffix)
Rectangle PaintTextRight(Canvas g, Color color, Rectangle rect_read, Size font_size, bool has_prefixText, bool has_suffixText, bool has_prefix, bool has_suffix)
{
int hr = 0;
if (has_suffixText)
@@ -507,7 +507,7 @@ namespace AntdUI
if (hr > 0) return new Rectangle(rect_read.X, rect_read.Y, rect_read.Width - hr, rect_read.Height);
return rect_read;
}
Rectangle PaintTextCenter(ICanvas g, Color color, Rectangle rect_read, Size font_size, bool has_prefixText, bool has_suffixText, bool has_prefix, bool has_suffix)
Rectangle PaintTextCenter(Canvas g, Color color, Rectangle rect_read, Size font_size, bool has_prefixText, bool has_suffixText, bool has_prefix, bool has_suffix)
{
int cex = rect_read.X + (rect_read.Width - font_size.Width) / 2;
if (has_prefixText)

View File

@@ -951,7 +951,7 @@ namespace AntdUI
}
StringFormat stringCenter = Helper.SF_NoWrap();
void PaintEmpty(ICanvas g, Rectangle rect)
void PaintEmpty(Canvas g, Rectangle rect)
{
using (var fore = new SolidBrush(Style.Db.Text))
{
@@ -1062,7 +1062,7 @@ namespace AntdUI
/// <summary>
/// 绘制阴影
/// </summary>
void DrawShadow(VirtualShadowItem it, ICanvas g, float radius)
void DrawShadow(VirtualShadowItem it, Canvas g, float radius)
{
if (shadow > 0)
{
@@ -1293,8 +1293,8 @@ namespace AntdUI
public bool CanClick { get; set; } = true;
public bool Hover { get; set; }
public object? Tag { get; set; }
public abstract Size Size(ICanvas g, VirtualPanelArgs e);
public abstract void Paint(ICanvas g, VirtualPanelArgs e);
public abstract Size Size(Canvas g, VirtualPanelArgs e);
public abstract void Paint(Canvas g, VirtualPanelArgs e);
public virtual bool MouseMove(VirtualPanel sender, VirtualPanelMouseArgs e) => true;
public virtual void MouseLeave(VirtualPanel sender, VirtualPanelMouseArgs e) { }
public virtual void MouseClick(VirtualPanel sender, VirtualPanelMouseArgs e) { }

View File

@@ -428,7 +428,7 @@ namespace AntdUI
return _rect;
}
int ChangeList(Rectangle rect, ICanvas g, MenuItem? Parent, MenuItemCollection items, ref int y, ref int icon_count, int height, int icon_size, int gap, int gapI, int depth)
int ChangeList(Rectangle rect, Canvas g, MenuItem? Parent, MenuItemCollection items, ref int y, ref int icon_count, int height, int icon_size, int gap, int gapI, int depth)
{
int collapsedWidth = 0;
foreach (var it in items)
@@ -473,7 +473,7 @@ namespace AntdUI
}
return collapsedWidth;
}
void ChangeListHorizontal(Rectangle rect, ICanvas g, MenuItemCollection items, int x, int icon_size, int gap, int gapI)
void ChangeListHorizontal(Rectangle rect, Canvas g, MenuItemCollection items, int x, int icon_size, int gap, int gapI)
{
foreach (var it in items)
{
@@ -556,7 +556,7 @@ namespace AntdUI
base.OnPaint(e);
}
void PaintItems(ICanvas g, Rectangle rect, int sy, MenuItemCollection items, Color fore, Color fore_active, Color fore_enabled, Color back_hover, Color back_active, float radius, SolidBrush sub_bg)
void PaintItems(Canvas g, Rectangle rect, int sy, MenuItemCollection items, Color fore, Color fore_active, Color fore_enabled, Color back_hover, Color back_active, float radius, SolidBrush sub_bg)
{
foreach (var it in items)
{
@@ -575,7 +575,7 @@ namespace AntdUI
}
}
}
void PaintItemExpand(ICanvas g, Rectangle rect, float sy, MenuItemCollection items, Color fore, Color fore_active, Color fore_enabled, Color back_hover, Color back_active, float radius)
void PaintItemExpand(Canvas g, Rectangle rect, float sy, MenuItemCollection items, Color fore, Color fore_active, Color fore_enabled, Color back_hover, Color back_active, float radius)
{
foreach (var it in items)
{
@@ -598,13 +598,13 @@ namespace AntdUI
}
}
void PaintIt(ICanvas g, MenuItem it, Color fore, Color fore_active, Color fore_enabled, Color back_hover, Color back_active, float radius)
void PaintIt(Canvas g, MenuItem it, Color fore, Color fore_active, Color fore_enabled, Color back_hover, Color back_active, float radius)
{
if (collapsed) PaintItemMini(g, it, fore, fore_active, fore_enabled, back_hover, back_active, radius);
else PaintItem(g, it, fore, fore_active, fore_enabled, back_hover, back_active, radius);
}
void PaintItemMini(ICanvas g, MenuItem it, Color fore, Color fore_active, Color fore_enabled, Color back_hover, Color back_active, float radius)
void PaintItemMini(Canvas g, MenuItem it, Color fore, Color fore_active, Color fore_enabled, Color back_hover, Color back_active, float radius)
{
if (it.Enabled)
{
@@ -648,7 +648,7 @@ namespace AntdUI
}
}
void PaintItem(ICanvas g, MenuItem it, Color fore, Color fore_active, Color fore_enabled, Color back_hover, Color back_active, float radius)
void PaintItem(Canvas g, MenuItem it, Color fore, Color fore_active, Color fore_enabled, Color back_hover, Color back_active, float radius)
{
if (it.Enabled)
{
@@ -720,7 +720,7 @@ namespace AntdUI
}
readonly StringFormat SL = Helper.SF_ALL(lr: StringAlignment.Near);
void PaintTextIcon(ICanvas g, MenuItem it, Color fore)
void PaintTextIcon(Canvas g, MenuItem it, Color fore)
{
using (var brush = new SolidBrush(fore))
{
@@ -728,7 +728,7 @@ namespace AntdUI
}
PaintIcon(g, it, fore);
}
void PaintTextIconExpand(ICanvas g, MenuItem it, Color fore)
void PaintTextIconExpand(Canvas g, MenuItem it, Color fore)
{
if (it.CanExpand)
{
@@ -755,13 +755,13 @@ namespace AntdUI
}
PaintIcon(g, it, fore);
}
void PaintIcon(ICanvas g, MenuItem it, Color fore)
void PaintIcon(Canvas g, MenuItem it, Color fore)
{
if (it.Icon != null) g.Image(it.Icon, it.ico_rect);
else if (it.IconSvg != null) g.GetImgExtend(it.IconSvg, it.ico_rect, fore);
}
void PaintBack(ICanvas g, Color color, Rectangle rect, float radius)
void PaintBack(Canvas g, Color color, Rectangle rect, float radius)
{
if (Round || radius > 0)
{

View File

@@ -371,14 +371,12 @@ namespace AntdUI
}
if (loading)
{
using (var brush = new Pen(Style.Db.Fill, 3F))
var bor3 = 3F * Config.Dpi;
g.DrawEllipse(Style.Db.Fill, bor3, rect_loading);
using (var pen = new Pen(Style.Db.Primary, bor3))
{
g.DrawEllipse(brush, rect_loading);
}
using (var brush = new Pen(Style.Db.Primary, 3F))
{
brush.StartCap = brush.EndCap = LineCap.Round;
g.DrawArc(brush, rect_loading, AnimationLoadingValue, 100);
pen.StartCap = pen.EndCap = LineCap.Round;
g.DrawArc(pen, rect_loading, AnimationLoadingValue, 100);
}
}
else if (config.Icon != TType.None) g.PaintIcons(config.Icon, rect_icon);
@@ -397,7 +395,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_client">客户区域</param>
/// <param name="rect_read">真实区域</param>
GraphicsPath DrawShadow(ICanvas g, Rectangle rect_client, Rectangle rect_read)
GraphicsPath DrawShadow(Canvas g, Rectangle rect_client, Rectangle rect_read)
{
var path = rect_read.RoundPath((int)(config.Radius * Config.Dpi));
if (Config.ShadowEnabled)
@@ -413,7 +411,7 @@ namespace AntdUI
}
Rectangle rect_icon, rect_loading, rect_txt;
Size RenderMeasure(ICanvas g, int shadow)
Size RenderMeasure(Canvas g, int shadow)
{
int shadow2 = shadow * 2;
float dpi = Config.Dpi;

View File

@@ -388,7 +388,7 @@ namespace AntdUI
if (config.Link != null)
{
using (var brush = new SolidBrush(Style.Db.Primary))
using (var pen = new Pen(Style.Db.Primary, 1F * Config.Dpi))
using (var pen = new Pen(Style.Db.Primary, Config.Dpi))
{
g.String(config.Link.Text, Font, brush, rect_link_text, s_f);
g.DrawLines(pen, TAlignMini.Right.TriangleLines(rect_links));
@@ -405,7 +405,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_client">客户区域</param>
/// <param name="rect_read">真实区域</param>
GraphicsPath DrawShadow(ICanvas g, Rectangle rect_client, Rectangle rect_read)
GraphicsPath DrawShadow(Canvas g, Rectangle rect_client, Rectangle rect_read)
{
var path = rect_read.RoundPath((int)(config.Radius * Config.Dpi));
if (Config.ShadowEnabled)
@@ -422,7 +422,7 @@ namespace AntdUI
Rectangle rect_icon, rect_title, rect_txt, rect_close;
Rectangle rect_link_text, rect_links;
Size RenderMeasure(ICanvas g, int shadow)
Size RenderMeasure(Canvas g, int shadow)
{
int shadow2 = shadow * 2;
float dpi = Config.Dpi;

View File

@@ -597,7 +597,7 @@ namespace AntdUI
base.OnPaint(e);
}
public Rectangle GetTitleRect(ICanvas g)
public Rectangle GetTitleRect(Canvas g)
{
var rect = ClientRectangle.PaddingRect(Padding, 0, 0, hasr, 0);
var size = g.MeasureString(text ?? Config.NullText, Font);
@@ -617,7 +617,7 @@ namespace AntdUI
}
}
int IPaintS(ICanvas g, Rectangle rect, int sHeight, float icon_ratio)
int IPaintS(Canvas g, Rectangle rect, int sHeight, float icon_ratio)
{
int u_x = 0;
int _gap = (int)(gap.HasValue ? gap.Value * Config.Dpi : sHeight * .6F);
@@ -641,7 +641,7 @@ namespace AntdUI
return u_x + _gap;
}
int IPaint(ICanvas g, Rectangle rect, Color fore, int sHeight, float icon_ratio)
int IPaint(Canvas g, Rectangle rect, Color fore, int sHeight, float icon_ratio)
{
int u_x = 0;
int _gap = (int)(gap.HasValue ? gap.Value * Config.Dpi : sHeight * .6F);
@@ -703,7 +703,7 @@ namespace AntdUI
}
return u_x + _gap;
}
void IPaintButton(ICanvas g, Rectangle rect, Color fore, Color fillsecondary, Size size)
void IPaintButton(Canvas g, Rectangle rect, Color fore, Color fillsecondary, Size size)
{
int btn_size = (int)(size.Height * 1.2F), btn_x = (rect_close.Width - btn_size) / 2, btn_y = (rect_close.Height - btn_size) / 2;
var rect_close_icon = new Rectangle(rect_close.X + btn_x, rect_close.Y + btn_y, btn_size, btn_size);
@@ -792,7 +792,7 @@ namespace AntdUI
#region
Bitmap? temp_logo = null, temp_back = null, temp_back_hover = null, temp_back_down = null, temp_min = null, temp_max = null, temp_restore = null, temp_close = null, temp_close_hover = null;
void PrintBack(ICanvas g, Color color, Rectangle rect_icon)
void PrintBack(Canvas g, Color color, Rectangle rect_icon)
{
if (temp_back == null || temp_back.Width != rect_icon.Width)
{
@@ -801,12 +801,12 @@ namespace AntdUI
}
if (temp_back != null) g.Image(temp_back, rect_icon);
}
void PrintBackHover(ICanvas g, Color color, Rectangle rect_icon)
void PrintBackHover(Canvas g, Color color, Rectangle rect_icon)
{
PrintBack(g, color, rect_icon);
g.GetImgExtend("ArrowLeftOutlined", rect_icon, Helper.ToColor(hove_back.Value, Style.Db.Primary));
}
void PrintBackHover(ICanvas g, Rectangle rect_icon)
void PrintBackHover(Canvas g, Rectangle rect_icon)
{
if (temp_back_hover == null || temp_back_hover.Width != rect_icon.Width)
{
@@ -815,7 +815,7 @@ namespace AntdUI
}
if (temp_back_hover != null) g.Image(temp_back_hover, rect_icon);
}
void PrintBackDown(ICanvas g, Rectangle rect_icon)
void PrintBackDown(Canvas g, Rectangle rect_icon)
{
if (temp_back_down == null || temp_back_down.Width != rect_icon.Width)
{
@@ -824,7 +824,7 @@ namespace AntdUI
}
if (temp_back_down != null) g.Image(temp_back_down, rect_icon);
}
void PrintClose(ICanvas g, Color color, Rectangle rect_icon)
void PrintClose(Canvas g, Color color, Rectangle rect_icon)
{
if (temp_close == null || temp_close.Width != rect_icon.Width)
{
@@ -833,7 +833,7 @@ namespace AntdUI
}
if (temp_close != null) g.Image(temp_close, rect_icon);
}
void PrintCloseHover(ICanvas g, Rectangle rect_icon)
void PrintCloseHover(Canvas g, Rectangle rect_icon)
{
if (temp_close_hover == null || temp_close_hover.Width != rect_icon.Width)
{
@@ -842,7 +842,7 @@ namespace AntdUI
}
if (temp_close_hover != null) g.Image(temp_close_hover, rect_icon);
}
void PrintMax(ICanvas g, Color color, Rectangle rect_icon)
void PrintMax(Canvas g, Color color, Rectangle rect_icon)
{
if (temp_max == null || temp_max.Width != rect_icon.Width)
{
@@ -851,7 +851,7 @@ namespace AntdUI
}
if (temp_max != null) g.Image(temp_max, rect_icon);
}
void PrintRestore(ICanvas g, Color color, Rectangle rect_icon)
void PrintRestore(Canvas g, Color color, Rectangle rect_icon)
{
if (temp_restore == null || temp_restore.Width != rect_icon.Width)
{
@@ -860,7 +860,7 @@ namespace AntdUI
}
if (temp_restore != null) g.Image(temp_restore, rect_icon);
}
void PrintMin(ICanvas g, Color color, Rectangle rect_icon)
void PrintMin(Canvas g, Color color, Rectangle rect_icon)
{
if (temp_min == null || temp_min.Width != rect_icon.Width)
{
@@ -869,7 +869,7 @@ namespace AntdUI
}
if (temp_min != null) g.Image(temp_min, rect_icon);
}
bool PrintLogo(ICanvas g, string svg, Color color, Rectangle rect_icon)
bool PrintLogo(Canvas g, string svg, Color color, Rectangle rect_icon)
{
if (temp_logo == null || temp_logo.Width != rect_icon.Width)
{

View File

@@ -352,10 +352,7 @@ namespace AntdUI
{
using (var path = btn.rect.RoundPath(_radius))
{
using (var pen = new Pen(color, border))
{
g.Draw(pen, path);
}
g.Draw(color, border, path);
}
}
g.String(btn.key, Font, brush, btn.rect, s_f);

View File

@@ -369,14 +369,7 @@ namespace AntdUI
{
g.Fill(brush, path);
if (backImage != null) g.Image(rect_read, backImage, backFit, _radius, false);
if (borderWidth > 0)
{
using (var brush_bor = new Pen(borderColor ?? Style.Db.BorderColor, borderWidth * Config.Dpi))
{
brush_bor.DashStyle = borderStyle;
g.Draw(brush_bor, path);
}
}
if (borderWidth > 0) g.Draw(borderColor ?? Style.Db.BorderColor, borderWidth * Config.Dpi, borderStyle, path);
}
if (ArrowAlign != TAlign.None) g.FillPolygon(brush, ArrowAlign.AlignLines(ArrowSize, rect, rect_read));
}
@@ -392,7 +385,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_client">客户区域</param>
/// <param name="rect_read">真实区域</param>
GraphicsPath DrawShadow(ICanvas g, float radius, Rectangle rect_client, Rectangle rect_read)
GraphicsPath DrawShadow(Canvas g, float radius, Rectangle rect_client, Rectangle rect_read)
{
var path = rect_read.RoundPath(radius, shadowAlign);
if (shadow > 0)

View File

@@ -587,7 +587,7 @@ namespace AntdUI
base.OnPaint(e);
}
void PaintShapeMini(ICanvas g, Rectangle rect, Color color)
void PaintShapeMini(Canvas g, Rectangle rect, Color color)
{
var _back = back ?? Color.FromArgb(40, color);
var font_size = g.MeasureString("100" + textUnit, Font);
@@ -600,10 +600,7 @@ namespace AntdUI
}
int w = radius == 0 ? (int)Math.Round(icon_rect.Width * .2F) : (int)(radius * Config.Dpi);
using (var brush = new Pen(_back, w))
{
g.DrawEllipse(brush, icon_rect);
}
g.DrawEllipse(_back, w, icon_rect);
#region
@@ -642,7 +639,7 @@ namespace AntdUI
#endregion
}
void PaintShapeSteps(ICanvas g, Rectangle rect_t, Rectangle rect, Color color)
void PaintShapeSteps(Canvas g, Rectangle rect_t, Rectangle rect, Color color)
{
var _back = back ?? Style.Db.FillSecondary;
var font_size = g.MeasureString("100" + textUnit, Font);
@@ -746,7 +743,7 @@ namespace AntdUI
g.PaintIcons(state, new Rectangle((rect.X + has_x2 + size_font_w) - ico_size, rect_t.Y + (rect_t.Height - ico_size) / 2, ico_size, ico_size));
}
}
void PaintShapeRound(ICanvas g, Rectangle rect_t, Rectangle rect, Color color, bool round)
void PaintShapeRound(Canvas g, Rectangle rect_t, Rectangle rect, Color color, bool round)
{
var _back = back ?? Style.Db.FillSecondary;
float _radius = radius * Config.Dpi;
@@ -813,7 +810,7 @@ namespace AntdUI
g.PaintIcons(state, new Rectangle(rect_rext.Right - ico_size, rect_rext.Y + (rect_rext.Height - ico_size) / 2, ico_size, ico_size));
}
}
void PaintShapeCircle(ICanvas g, Rectangle rect, Color color)
void PaintShapeCircle(Canvas g, Rectangle rect, Color color)
{
var _back = back ?? Style.Db.FillSecondary;
@@ -825,10 +822,7 @@ namespace AntdUI
prog_size -= w;
var rect_prog = new Rectangle(rect.X + (rect.Width - prog_size) / 2, rect.Y + (rect.Height - prog_size) / 2, prog_size, prog_size);
using (var brush = new Pen(_back, w))
{
g.DrawEllipse(brush, rect_prog);
}
g.DrawEllipse(_back, w, rect_prog);
#region
@@ -893,7 +887,7 @@ namespace AntdUI
}
}
void PaintProgress(ICanvas g, float radius, Rectangle rect, Color back, Color color)
void PaintProgress(Canvas g, float radius, Rectangle rect, Color back, Color color)
{
using (var path = rect.RoundPath(radius))
{

View File

@@ -233,10 +233,11 @@ namespace AntdUI
#region
internal void PaintChecked(ICanvas g, Rectangle rect, bool enabled, RectangleF icon_rect, bool right)
internal void PaintChecked(Canvas g, Rectangle rect, bool enabled, RectangleF icon_rect, bool right)
{
float dot_size = icon_rect.Height;
if (right) icon_rect.X = rect.Width - icon_rect.X - icon_rect.Width;
var bor2 = 2F * Config.Dpi;
if (enabled)
{
var color = fill ?? Style.Db.Primary;
@@ -253,75 +254,36 @@ namespace AntdUI
if (_checked)
{
float max = icon_rect.Height + ((rect.Height - icon_rect.Height) * AnimationCheckValue), alpha2 = 100 * (1F - AnimationCheckValue);
using (var brush = new SolidBrush(Helper.ToColor(alpha2, color)))
{
g.FillEllipse(brush, new RectangleF(icon_rect.X + (icon_rect.Width - max) / 2F, icon_rect.Y + (icon_rect.Height - max) / 2F, max, max));
}
}
using (var brush = new Pen(color, 2F))
{
g.DrawEllipse(brush, icon_rect);
g.FillEllipse(Helper.ToColor(alpha2, color), new RectangleF(icon_rect.X + (icon_rect.Width - max) / 2F, icon_rect.Y + (icon_rect.Height - max) / 2F, max, max));
}
g.DrawEllipse(color, bor2, icon_rect);
}
else if (_checked)
{
float dot = dot_size * 0.3F, dot2 = dot / 2F;
using (var brush = new Pen(Color.FromArgb(250, color), dot))
{
g.DrawEllipse(brush, new RectangleF(icon_rect.X + dot2, icon_rect.Y + dot2, icon_rect.Width - dot, icon_rect.Height - dot));
}
using (var brush = new Pen(color, 2F))
{
g.DrawEllipse(brush, icon_rect);
}
g.DrawEllipse(Color.FromArgb(250, color), dot, new RectangleF(icon_rect.X + dot2, icon_rect.Y + dot2, icon_rect.Width - dot, icon_rect.Height - dot));
g.DrawEllipse(color, bor2, icon_rect);
}
else
{
if (AnimationHover)
{
using (var brush = new Pen(Style.Db.BorderColor, 2F))
{
g.DrawEllipse(brush, icon_rect);
}
using (var brush = new Pen(Helper.ToColor(AnimationHoverValue, color), 2F))
{
g.DrawEllipse(brush, icon_rect);
}
}
else if (ExtraMouseHover)
{
using (var brush = new Pen(color, 2F))
{
g.DrawEllipse(brush, icon_rect);
}
}
else
{
using (var brush = new Pen(Style.Db.BorderColor, 2F))
{
g.DrawEllipse(brush, icon_rect);
}
g.DrawEllipse(Style.Db.BorderColor, bor2, icon_rect);
g.DrawEllipse(Helper.ToColor(AnimationHoverValue, color), bor2, icon_rect);
}
else if (ExtraMouseHover) g.DrawEllipse(color, bor2, icon_rect);
else g.DrawEllipse(Style.Db.BorderColor, bor2, icon_rect);
}
}
else
{
using (var brush = new SolidBrush(Style.Db.FillQuaternary))
{
g.FillEllipse(brush, icon_rect);
}
g.FillEllipse(Style.Db.FillQuaternary, icon_rect);
if (_checked)
{
float dot = dot_size / 2F, dot2 = dot / 2F;
using (var brush2 = new SolidBrush(Style.Db.TextQuaternary))
{
g.FillEllipse(brush2, new RectangleF(icon_rect.X + dot2, icon_rect.Y + dot2, icon_rect.Width - dot, icon_rect.Height - dot));
}
}
using (var brush = new Pen(Style.Db.BorderColorDisable, 2F))
{
g.DrawEllipse(brush, icon_rect);
g.FillEllipse(Style.Db.TextQuaternary, new RectangleF(icon_rect.X + dot2, icon_rect.Y + dot2, icon_rect.Width - dot, icon_rect.Height - dot));
}
g.DrawEllipse(Style.Db.BorderColorDisable, bor2, icon_rect);
}
}

View File

@@ -427,11 +427,11 @@ namespace AntdUI
#region
public virtual void Paint(ICanvas g)
public virtual void Paint(Canvas g)
{
Paint(g, Style.Db.TextBase);
}
public virtual void Paint(ICanvas g, Color baseColor)
public virtual void Paint(Canvas g, Color baseColor)
{
if (Config.ScrollBarHide)
{
@@ -598,7 +598,7 @@ namespace AntdUI
if (AnimationHoverX) return new SolidBrush(Color.FromArgb((int)(10 * AnimationHoverXValue), color));
else return new SolidBrush(Color.FromArgb(10, color));
}
void PaintY(ICanvas g, Color color)
void PaintY(Canvas g, Color color)
{
if (AnimationHoverY)
{
@@ -623,7 +623,7 @@ namespace AntdUI
}
}
}
void PaintX(ICanvas g, Color color)
void PaintX(Canvas g, Color color)
{
if (AnimationHoverX)
{

View File

@@ -158,11 +158,11 @@ namespace AntdUI
/// 渲染滚动条竖
/// </summary>
/// <param name="g"></param>
public virtual void Paint(ICanvas g)
public virtual void Paint(Canvas g)
{
Paint(g, Style.Db.TextBase);
}
public virtual void Paint(ICanvas g, Color baseColor)
public virtual void Paint(Canvas g, Color baseColor)
{
if (Show)
{

View File

@@ -946,7 +946,7 @@ namespace AntdUI
base.OnPaint(e);
}
bool PaintImg(ICanvas g, SegmentedItem it, Color color, string? svg, Image? bmp)
bool PaintImg(Canvas g, SegmentedItem it, Color color, string? svg, Image? bmp)
{
if (svg != null)
{

View File

@@ -354,7 +354,7 @@ namespace AntdUI
get => showicon;
}
protected override void PaintRIcon(ICanvas g, Rectangle rect_r)
protected override void PaintRIcon(Canvas g, Rectangle rect_r)
{
if (showicon)
{

View File

@@ -257,7 +257,7 @@ namespace AntdUI
get => showicon;
}
protected override void PaintRIcon(ICanvas g, Rectangle rect_r)
protected override void PaintRIcon(Canvas g, Rectangle rect_r)
{
if (showicon)
{
@@ -353,7 +353,7 @@ namespace AntdUI
return 0;
}
protected override void PaintOtherBor(ICanvas g, RectangleF rect_read, float radius, Color back, Color borderColor, Color borderActive)
protected override void PaintOtherBor(Canvas g, RectangleF rect_read, float radius, Color back, Color borderColor, Color borderActive)
{
if (selectedValue.Length > 0 && style_left.Length == rect_lefts.Length)
{

View File

@@ -51,12 +51,21 @@ namespace AntdUI
}
}
/// <summary>
/// 满格颜色
/// </summary>
[Description("满格颜色"), Category("外观"), DefaultValue(null)]
public Color? FillFully { get; set; }
/// <summary>
/// 警告颜色
/// </summary>
[Description("警告颜色"), Category("外观"), DefaultValue(null)]
public Color? FillWarn { get; set; }
/// <summary>
/// 危险颜色
/// </summary>
[Description("危险颜色"), Category("外观"), DefaultValue(null)]
public Color? FillDanger { get; set; }
@@ -185,7 +194,6 @@ namespace AntdUI
path.AddRectangle(rect_4);
path.AddRectangle(rect_5);
using (var pen = new Pen(color2, 1 * Config.Dpi))
using (var brush = new LinearGradientBrush(rect_dot, color2, color1, 0F))
{
brush.InterpolationColors = new ColorBlend(3)
@@ -194,7 +202,7 @@ namespace AntdUI
Positions = new float[] { 0, loading_vol / 100F, 1F }
};
g.Fill(brush, path);
g.Draw(pen, path);
g.Draw(color2, Config.Dpi, path);
}
}
}
@@ -279,7 +287,7 @@ namespace AntdUI
if (loading)
{
Color color1 = fill ?? Style.Db.FillQuaternary, color2 = FillFully ?? Style.Db.Success;
using (var pen = new Pen(color2, 1 * Config.Dpi))
using (var pen = new Pen(color2, Config.Dpi))
using (var brush = new LinearGradientBrush(rect_pie, color1, color2, 90F))
{
brush.InterpolationColors = new ColorBlend(2)

View File

@@ -297,7 +297,7 @@ namespace AntdUI
this.PaintBadge(g);
}
internal virtual void IPaint(ICanvas g, Rectangle rect, bool enabled, Color color, Color color_dot, Color color_hover, Color color_active)
internal virtual void IPaint(Canvas g, Rectangle rect, bool enabled, Color color, Color color_dot, Color color_hover, Color color_active)
{
float prog = ProgValue(_value);
@@ -336,7 +336,7 @@ namespace AntdUI
readonly StringFormat s_f = Helper.SF_NoWrap();
internal RectangleF rectEllipse;
internal void PaintEllipse(ICanvas g, Rectangle rect, RectangleF rect_read, float prog, SolidBrush brush, Color color, Color color_hover, Color color_active, int LineSize)
internal void PaintEllipse(Canvas g, Rectangle rect, RectangleF rect_read, float prog, SolidBrush brush, Color color, Color color_hover, Color color_active, int LineSize)
{
int DotSize = (int)(dotSize * Config.Dpi), DotSizeActive = (int)(dotSizeActive * Config.Dpi);
rectEllipse = RectDot(rect, rect_read, prog, DotSizeActive + LineSize);
@@ -391,7 +391,7 @@ namespace AntdUI
g.FillEllipse(brush, RectDot(rect, rect_read, prog, DotSize));
}
}
internal void PaintMarksEllipse(ICanvas g, Rectangle rect, RectangleF rect_read, SolidBrush brush, Color color, int LineSize)
internal void PaintMarksEllipse(Canvas g, Rectangle rect, RectangleF rect_read, SolidBrush brush, Color color, int LineSize)
{
if (marks != null && marks.Count > 0)
{

View File

@@ -65,7 +65,7 @@ namespace AntdUI
#region
internal override void IPaint(ICanvas g, Rectangle rect, bool enabled, Color color, Color color_dot, Color color_hover, Color color_active)
internal override void IPaint(Canvas g, Rectangle rect, bool enabled, Color color, Color color_dot, Color color_hover, Color color_active)
{
float prog = ProgValue(Value), prog2 = ProgValue(_value2);
@@ -104,7 +104,7 @@ namespace AntdUI
}
RectangleF rectEllipse2;
internal void PaintEllipse2(ICanvas g, Rectangle rect, RectangleF rect_read, float prog, SolidBrush brush, Color color, Color color_hover, Color color_active, int LineSize)
internal void PaintEllipse2(Canvas g, Rectangle rect, RectangleF rect_read, float prog, SolidBrush brush, Color color, Color color_hover, Color color_active, int LineSize)
{
int DotSize = (int)(dotSize * Config.Dpi), DotSizeActive = (int)(dotSizeActive * Config.Dpi);
rectEllipse2 = RectDot(rect, rect_read, prog, DotSizeActive + LineSize);

View File

@@ -267,7 +267,7 @@ namespace AntdUI
}
readonly StringFormat s_f = Helper.SF_ALL();
public void Paint(ICanvas g, Rectangle rect, string? text, Color color, Font? font, Control control)
public void Paint(Canvas g, Rectangle rect, string? text, Color color, Font? font, Control control)
{
if (prog_size == 0) prog_size = g.MeasureString(text ?? Config.NullText, font ?? control.Font).Height;

View File

@@ -155,7 +155,7 @@ namespace AntdUI
if (rect.Width == 0 || rect.Height == 0) return;
Helper.GDI(g =>
{
int gap = (int)(8F * Config.Dpi), split = (int)(1F * Config.Dpi);
int gap = (int)(8F * Config.Dpi), split = (int)Config.Dpi;
var _splits = new List<RectangleF>(items.Count);
using (var font_description = new Font(Font.FontFamily, Font.Size * 0.875F))
{
@@ -254,7 +254,7 @@ namespace AntdUI
return;
}
int MaxHeight(ICanvas g, Font font_description, int gap, out int height)
int MaxHeight(Canvas g, Font font_description, int gap, out int height)
{
int w = 0, temp_t = 0, temp = 0;
foreach (StepsItem it in Items)
@@ -414,7 +414,7 @@ namespace AntdUI
base.OnPaint(e);
}
bool PaintIcon(ICanvas g, StepsItem it, Color fore)
bool PaintIcon(Canvas g, StepsItem it, Color fore)
{
if (it.Icon != null) { g.Image(it.Icon, it.ico_rect); return false; }
else if (it.IconSvg != null)

View File

@@ -252,7 +252,7 @@ namespace AntdUI
this.PaintBadge(g);
base.OnPaint(e);
}
internal void PaintClick(ICanvas g, GraphicsPath path, Rectangle rect, RectangleF rect_read, Color color)
internal void PaintClick(Canvas g, GraphicsPath path, Rectangle rect, RectangleF rect_read, Color color)
{
if (AnimationClick)
{

View File

@@ -22,9 +22,9 @@ namespace AntdUI
{
partial class CellBadge
{
internal override void PaintBack(ICanvas g) { }
internal override void PaintBack(Canvas g) { }
internal override void Paint(ICanvas g, Font font, SolidBrush fore)
internal override void Paint(Canvas g, Font font, SolidBrush fore)
{
if (PARENT == null) return;
Color color;
@@ -51,10 +51,7 @@ namespace AntdUI
if (State == TState.Processing && PARENT.PARENT != null)
{
float max = (TxtHeight - 6F) * PARENT.PARENT.AnimationStateValue, alpha = 255 * (1F - PARENT.PARENT.AnimationStateValue);
using (var pen = new Pen(Helper.ToColor(alpha, brush.Color), 4F))
{
g.DrawEllipse(pen, new RectangleF(RectDot.X + (RectDot.Width - max) / 2F, RectDot.Y + (RectDot.Height - max) / 2F, max, max));
}
g.DrawEllipse(Helper.ToColor(alpha, brush.Color), 4F * Config.Dpi, new RectangleF(RectDot.X + (RectDot.Width - max) / 2F, RectDot.Y + (RectDot.Height - max) / 2F, max, max));
}
g.FillEllipse(brush, RectDot);
}
@@ -68,7 +65,7 @@ namespace AntdUI
else g.String(Text, font, fore, Rect, Table.StringF(PARENT.COLUMN));
}
internal override Size GetSize(ICanvas g, Font font, int gap, int gap2)
internal override Size GetSize(Canvas g, Font font, int gap, int gap2)
{
if (string.IsNullOrEmpty(Text))
{
@@ -87,7 +84,7 @@ namespace AntdUI
int TxtHeight = 0;
RectangleF Rect;
RectangleF RectDot;
internal override void SetRect(ICanvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
internal override void SetRect(Canvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
{
TxtHeight = size.Height;
float dot_size = size.Height / 2.5F;

View File

@@ -23,12 +23,12 @@ namespace AntdUI
{
partial class CellButton
{
internal override void Paint(ICanvas g, Font font, SolidBrush fore)
internal override void Paint(Canvas g, Font font, SolidBrush fore)
{
Table.PaintButton(g, font, (PARENT == null || PARENT.PARENT == null) ? 12 : PARENT.PARENT.Gap, Rect, this);
}
internal override Size GetSize(ICanvas g, Font font, int gap, int gap2)
internal override Size GetSize(Canvas g, Font font, int gap, int gap2)
{
if (string.IsNullOrEmpty(Text))
{

View File

@@ -22,9 +22,9 @@ namespace AntdUI
{
partial class CellDivider
{
internal override void PaintBack(ICanvas g) { }
internal override void PaintBack(Canvas g) { }
internal override void Paint(ICanvas g, Font font, SolidBrush fore)
internal override void Paint(Canvas g, Font font, SolidBrush fore)
{
using (var brush = new SolidBrush(Style.Db.Split))
{
@@ -32,14 +32,14 @@ namespace AntdUI
}
}
internal override Size GetSize(ICanvas g, Font font, int gap, int gap2)
internal override Size GetSize(Canvas g, Font font, int gap, int gap2)
{
var size = g.MeasureString(Config.NullText, font);
return new Size(gap, size.Height + gap);
}
Rectangle Rect;
internal override void SetRect(ICanvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
internal override void SetRect(Canvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
{
int h = size.Height - gap2;
Rect = new Rectangle(rect.X + (rect.Width - 1) / 2, rect.Y + (rect.Height - h) / 2, 1, h);

View File

@@ -35,7 +35,7 @@ namespace AntdUI
/// <param name="font">字体</param>
/// <param name="gap">边距</param>
/// <param name="gap2">边距2</param>
internal abstract Size GetSize(ICanvas g, Font font, int gap, int gap2);
internal abstract Size GetSize(Canvas g, Font font, int gap, int gap2);
/// <summary>
/// 设置渲染位置坐标
@@ -46,10 +46,10 @@ namespace AntdUI
/// <param name="size">真实区域</param>
/// <param name="gap">边距</param>
/// <param name="gap2">边距2</param>
internal abstract void SetRect(ICanvas g, Font font, Rectangle rect, Size size, int gap, int gap2);
internal abstract void SetRect(Canvas g, Font font, Rectangle rect, Size size, int gap, int gap2);
internal abstract void PaintBack(ICanvas g);
internal abstract void Paint(ICanvas g, Font font, SolidBrush fore);
internal abstract void PaintBack(Canvas g);
internal abstract void Paint(Canvas g, Font font, SolidBrush fore);
/// <summary>
/// 模板父级

View File

@@ -24,9 +24,9 @@ namespace AntdUI
{
partial class CellImage
{
internal override void PaintBack(ICanvas g) { }
internal override void PaintBack(Canvas g) { }
internal override void Paint(ICanvas g, Font font, SolidBrush fore)
internal override void Paint(Canvas g, Font font, SolidBrush fore)
{
float radius = Radius * Config.Dpi;
using (var path = Rect.RoundPath(radius))
@@ -55,18 +55,11 @@ namespace AntdUI
}
}
if (BorderWidth > 0 && BorderColor.HasValue)
{
float border = BorderWidth * Config.Dpi;
using (var brush = new Pen(BorderColor.Value, border))
{
g.Draw(brush, path);
}
}
if (BorderWidth > 0 && BorderColor.HasValue) g.Draw(BorderColor.Value, BorderWidth * Config.Dpi, path);
}
}
internal override Size GetSize(ICanvas g, Font font, int gap, int gap2)
internal override Size GetSize(Canvas g, Font font, int gap, int gap2)
{
if (Size.HasValue)
{
@@ -80,7 +73,7 @@ namespace AntdUI
}
internal Rectangle Rect;
internal override void SetRect(ICanvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
internal override void SetRect(Canvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
{
int w = size.Width - gap2, h = size.Height - gap2;
Rect = new Rectangle(rect.X + (rect.Width - w) / 2, rect.Y + (rect.Height - h) / 2, w, h);

View File

@@ -22,21 +22,21 @@ namespace AntdUI
{
partial class CellLink
{
internal override void PaintBack(ICanvas g) { }
internal override void PaintBack(Canvas g) { }
internal override void Paint(ICanvas g, Font font, SolidBrush fore)
internal override void Paint(Canvas g, Font font, SolidBrush fore)
{
Table.PaintLink(g, font, Rect, this);
}
internal override Size GetSize(ICanvas g, Font font, int gap, int gap2)
internal override Size GetSize(Canvas g, Font font, int gap, int gap2)
{
var size = g.MeasureString(Text ?? Config.NullText, font);
return new Size(size.Width + gap2 * 2, size.Height + gap);
}
internal Rectangle Rect;
internal override void SetRect(ICanvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
internal override void SetRect(Canvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
{
Rect = new Rectangle(rect.X + gap, rect.Y + (rect.Height - size.Height) / 2, rect.Width - gap2, size.Height);
}

View File

@@ -23,18 +23,15 @@ namespace AntdUI
{
partial class CellProgress
{
internal override void PaintBack(ICanvas g) { }
internal override void PaintBack(Canvas g) { }
internal override void Paint(ICanvas g, Font font, SolidBrush fore)
internal override void Paint(Canvas g, Font font, SolidBrush fore)
{
Color _color = Fill ?? Style.Db.Primary, _back = Back ?? Style.Db.FillSecondary;
if (Shape == TShape.Circle)
{
float w = Radius * Config.Dpi;
using (var brush = new Pen(_back, w))
{
g.DrawEllipse(brush, Rect);
}
g.DrawEllipse(_back, w, Rect);
if (Value > 0)
{
int max = (int)(360 * Value);
@@ -86,7 +83,7 @@ namespace AntdUI
}
}
internal override Size GetSize(ICanvas g, Font font, int gap, int gap2)
internal override Size GetSize(Canvas g, Font font, int gap, int gap2)
{
int height = g.MeasureString(Config.NullText, font).Height;
if (Shape == TShape.Circle)
@@ -102,7 +99,7 @@ namespace AntdUI
}
Rectangle Rect;
internal override void SetRect(ICanvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
internal override void SetRect(Canvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
{
int w = rect.Width - gap2, h = size.Height;
if (Shape == TShape.Circle)

View File

@@ -22,9 +22,9 @@ namespace AntdUI
{
partial class CellTag
{
internal override void PaintBack(ICanvas g) { }
internal override void PaintBack(Canvas g) { }
internal override void Paint(ICanvas g, Font font, SolidBrush fore)
internal override void Paint(Canvas g, Font font, SolidBrush fore)
{
using (var path = Rect.RoundPath(6))
{
@@ -71,7 +71,7 @@ namespace AntdUI
g.Fill(_back, path);
if (BorderWidth > 0) g.Draw(_bor, BorderWidth * Config.Dpi, path);
if (borderWidth > 0) g.Draw(_bor, borderWidth * Config.Dpi, path);
#endregion
@@ -79,14 +79,14 @@ namespace AntdUI
}
}
internal override Size GetSize(ICanvas g, Font font, int gap, int gap2)
internal override Size GetSize(Canvas g, Font font, int gap, int gap2)
{
var size = g.MeasureString(Text, font);
return new Size(size.Width + gap2 * 2, size.Height + gap);
}
Rectangle Rect;
internal override void SetRect(ICanvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
internal override void SetRect(Canvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
{
Rect = new Rectangle(rect.X + gap, rect.Y + (rect.Height - size.Height) / 2, rect.Width - gap2, size.Height);
}

View File

@@ -72,17 +72,17 @@ namespace AntdUI
}
}
float borderwidth = 1F;
float borderWidth = 1F;
/// <summary>
/// 边框宽度
/// </summary>
public float BorderWidth
{
get => borderwidth;
get => borderWidth;
set
{
if (borderwidth == value) return;
borderwidth = value;
if (borderWidth == value) return;
borderWidth = value;
OnPropertyChanged();
}
}

View File

@@ -22,7 +22,7 @@ namespace AntdUI
{
partial class CellText
{
internal override void PaintBack(ICanvas g)
internal override void PaintBack(Canvas g)
{
if (PARENT == null) return;
if (Back.HasValue)
@@ -34,7 +34,7 @@ namespace AntdUI
}
}
internal override void Paint(ICanvas g, Font font, SolidBrush fore)
internal override void Paint(Canvas g, Font font, SolidBrush fore)
{
if (PARENT == null) return;
var state = g.Save();
@@ -55,7 +55,7 @@ namespace AntdUI
else if (Suffix != null) g.Image(Suffix, RectR);
}
internal override Size GetSize(ICanvas g, Font font, int gap, int gap2)
internal override Size GetSize(Canvas g, Font font, int gap, int gap2)
{
var size = g.MeasureString(Text, Font ?? font);
bool has_prefix = HasPrefix, has_suffix = HasSuffix;
@@ -73,7 +73,7 @@ namespace AntdUI
}
Rectangle Rect, RectL, RectR;
internal override void SetRect(ICanvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
internal override void SetRect(Canvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
{
bool has_prefix = HasPrefix, has_suffix = HasSuffix;
if (has_prefix && has_suffix)

View File

@@ -23,7 +23,7 @@ namespace AntdUI
{
partial class Table
{
internal static void PaintButton(ICanvas g, Font font, int gap, Rectangle rect_read, CellButton btn)
internal static void PaintButton(Canvas g, Font font, int gap, Rectangle rect_read, CellButton btn)
{
float _radius = (btn.Shape == TShape.Round || btn.Shape == TShape.Circle) ? rect_read.Height : btn.Radius * Config.Dpi;
@@ -85,39 +85,24 @@ namespace AntdUI
float border = btn.BorderWidth * Config.Dpi;
if (btn.ExtraMouseDown)
{
using (var brush = new Pen(_back_active, border))
{
g.Draw(brush, path);
}
g.Draw(_back_active, border, path);
PaintButton(g, font, btn, _back_active, rect_read);
}
else if (btn.AnimationHover)
{
var colorHover = Helper.ToColor(btn.AnimationHoverValue, _back_hover);
using (var brush = new Pen(Style.Db.DefaultBorder, border))
{
g.Draw(brush, path);
}
using (var brush = new Pen(colorHover, border))
{
g.Draw(brush, path);
}
g.Draw(Style.Db.DefaultBorder, border, path);
g.Draw(colorHover, border, path);
PaintButton(g, font, btn, _fore, colorHover, rect_read);
}
else if (btn.ExtraMouseHover)
{
using (var brush = new Pen(_back_hover, border))
{
g.Draw(brush, path);
}
g.Draw(_back_hover, border, path);
PaintButton(g, font, btn, _back_hover, rect_read);
}
else
{
using (var brush = new Pen(btn.DefaultBorderColor ?? Style.Db.DefaultBorder, border))
{
g.Draw(brush, path);
}
g.Draw(btn.DefaultBorderColor ?? Style.Db.DefaultBorder, border, path);
PaintButton(g, font, btn, _fore, rect_read);
}
}
@@ -205,31 +190,19 @@ namespace AntdUI
float border = btn.BorderWidth * Config.Dpi;
if (btn.ExtraMouseDown)
{
using (var brush = new Pen(_back_active, border))
{
g.Draw(brush, path);
}
g.Draw(_back_active, border, path);
PaintButton(g, font, btn, _back_active, rect_read);
}
else if (btn.AnimationHover)
{
var colorHover = Helper.ToColor(btn.AnimationHoverValue, _back_hover);
using (var brush = new Pen(btn.Enabled ? _back : Style.Db.FillTertiary, border))
{
g.Draw(brush, path);
}
using (var brush = new Pen(colorHover, border))
{
g.Draw(brush, path);
}
g.Draw(btn.Enabled ? _back : Style.Db.FillTertiary, border, path);
g.Draw(colorHover, border, path);
PaintButton(g, font, btn, _back, colorHover, rect_read);
}
else if (btn.ExtraMouseHover)
{
using (var brush = new Pen(_back_hover, border))
{
g.Draw(brush, path);
}
g.Draw(_back_hover, border, path);
PaintButton(g, font, btn, _back_hover, rect_read);
}
else
@@ -238,19 +211,10 @@ namespace AntdUI
{
using (var brushback = btn.BackExtend.BrushEx(rect_read, _back))
{
using (var brush = new Pen(brushback, border))
{
g.Draw(brush, path);
}
}
}
else
{
using (var brush = new Pen(Style.Db.FillTertiary, border))
{
g.Draw(brush, path);
g.Draw(brushback, border, path);
}
}
else g.Draw(Style.Db.FillTertiary, border, path);
PaintButton(g, font, btn, btn.Enabled ? _back : Style.Db.TextQuaternary, rect_read);
}
}
@@ -309,7 +273,7 @@ namespace AntdUI
return rect_read.RoundPath(_radius);
}
static void PaintButton(ICanvas g, Font font, CellButton btn, Color color, Rectangle rect_read)
static void PaintButton(Canvas g, Font font, CellButton btn, Color color, Rectangle rect_read)
{
if (string.IsNullOrEmpty(btn.Text))
{
@@ -420,7 +384,7 @@ namespace AntdUI
}
}
static void PaintButton(ICanvas g, Font font, CellButton btn, Color color, Color colorHover, Rectangle rect_read)
static void PaintButton(Canvas g, Font font, CellButton btn, Color color, Color colorHover, Rectangle rect_read)
{
if (string.IsNullOrEmpty(btn.Text))
{
@@ -580,7 +544,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="color">颜色</param>
/// <param name="rect">区域</param>
static bool PaintButtonImageNoText(ICanvas g, CellButton btn, Color? color, Rectangle rect)
static bool PaintButtonImageNoText(Canvas g, CellButton btn, Color? color, Rectangle rect)
{
if (btn.AnimationImageHover)
{
@@ -599,7 +563,7 @@ namespace AntdUI
return true;
}
static bool PaintButtonCoreImage(ICanvas g, CellButton btn, Rectangle rect, Color? color, float opacity = 1F)
static bool PaintButtonCoreImage(Canvas g, CellButton btn, Rectangle rect, Color? color, float opacity = 1F)
{
if (btn.IconSvg != null)
{
@@ -620,7 +584,7 @@ namespace AntdUI
return false;
}
static bool PaintButtonCoreImageHover(ICanvas g, CellButton btn, Rectangle rect, Color? color, float opacity = 1F)
static bool PaintButtonCoreImageHover(Canvas g, CellButton btn, Rectangle rect, Color? color, float opacity = 1F)
{
if (btn.IconHoverSvg != null)
{
@@ -653,7 +617,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="color">颜色</param>
/// <param name="rectl">图标区域</param>
static void PaintButtonPaintImage(ICanvas g, CellButton btn, Color? color, Rectangle rectl)
static void PaintButtonPaintImage(Canvas g, CellButton btn, Color? color, Rectangle rectl)
{
if (btn.AnimationImageHover)
{
@@ -673,7 +637,7 @@ namespace AntdUI
#endregion
internal static void PaintLink(ICanvas g, Font font, Rectangle rect_read, CellLink link)
internal static void PaintLink(Canvas g, Font font, Rectangle rect_read, CellLink link)
{
if (link.ExtraMouseDown)
{

View File

@@ -53,7 +53,7 @@ namespace AntdUI
base.OnPaint(e);
}
void PaintTable(ICanvas g, RowTemplate[] rows, Rectangle rect, Font column_font)
void PaintTable(Canvas g, RowTemplate[] rows, Rectangle rect, Font column_font)
{
float _radius = radius * Config.Dpi;
int sx = ScrollBar.ValueX, sy = ScrollBar.ValueY;
@@ -207,7 +207,7 @@ namespace AntdUI
if (bordered)
{
var splitsize = dividerHs.Length > 0 ? dividerHs[0].Width : (int)(1F * Config.Dpi);
var splitsize = dividerHs.Length > 0 ? dividerHs[0].Width : (int)Config.Dpi;
if (_radius > 0)
{
using (var pen = new Pen(brush_split.Color, splitsize))
@@ -228,20 +228,14 @@ namespace AntdUI
}
}
}
else
{
using (var pen = new Pen(brush_split.Color, splitsize))
{
g.Draw(pen, rect_divider);
}
}
else g.Draw(brush_split.Color, splitsize, rect_divider);
}
}
}
#region
void PaintTableBgHeader(ICanvas g, RowTemplate row, float radius)
void PaintTableBgHeader(Canvas g, RowTemplate row, float radius)
{
using (var brush = new SolidBrush(columnback ?? Style.Db.TagDefaultBg))
{
@@ -265,7 +259,7 @@ namespace AntdUI
}
}
}
void PaintTableHeader(ICanvas g, RowTemplate row, SolidBrush fore, Font column_font, float radius)
void PaintTableHeader(Canvas g, RowTemplate row, SolidBrush fore, Font column_font, float radius)
{
foreach (TCellColumn column in row.cells)
{
@@ -334,7 +328,7 @@ namespace AntdUI
/// <summary>
/// 渲染背景行(前置)
/// </summary>
void PaintBgRowFront(ICanvas g, StyleRow row)
void PaintBgRowFront(Canvas g, StyleRow row)
{
if (row.style != null && row.style.BackColor.HasValue)
{
@@ -373,7 +367,7 @@ namespace AntdUI
/// <summary>
/// 渲染背景行
/// </summary>
void PaintBg(ICanvas g, RowTemplate row)
void PaintBg(Canvas g, RowTemplate row)
{
if (row.AnimationHover)
{
@@ -396,7 +390,7 @@ namespace AntdUI
/// <summary>
/// 渲染背景行
/// </summary>
void PaintBgRowItem(ICanvas g, RowTemplate row)
void PaintBgRowItem(Canvas g, RowTemplate row)
{
foreach (var cel in row.cells) PaintItemBg(g, cel);
}
@@ -404,7 +398,7 @@ namespace AntdUI
/// <summary>
/// 渲染单元格背景
/// </summary>
void PaintItemBg(ICanvas g, TCell it)
void PaintItemBg(Canvas g, TCell it)
{
if (it is Template obj)
{
@@ -415,7 +409,7 @@ namespace AntdUI
/// <summary>
/// 渲染前景行
/// </summary>
void PaintForeItem(ICanvas g, StyleRow row, SolidBrush fore)
void PaintForeItem(Canvas g, StyleRow row, SolidBrush fore)
{
if (selectedIndex == row.row.INDEX && rowSelectedFore.HasValue)
{
@@ -436,7 +430,7 @@ namespace AntdUI
#region
void PaintItem(ICanvas g, TCell it, SolidBrush fore)
void PaintItem(Canvas g, TCell it, SolidBrush fore)
{
if (it.COLUMN.Style == null || it.COLUMN.Style.ForeColor == null) PaintItem(g, it.INDEX, it, fore);
else
@@ -451,7 +445,7 @@ namespace AntdUI
/// <summary>
/// 渲染单元格(浮动)
/// </summary>
void PaintItemFixed(ICanvas g, TCell it, SolidBrush fore, CellStyleInfo? style)
void PaintItemFixed(Canvas g, TCell it, SolidBrush fore, CellStyleInfo? style)
{
if (selectedIndex == it.ROW.INDEX && rowSelectedFore.HasValue)
{
@@ -477,7 +471,7 @@ namespace AntdUI
}
}
void PaintItem(ICanvas g, int columnIndex, TCell it, SolidBrush fore)
void PaintItem(Canvas g, int columnIndex, TCell it, SolidBrush fore)
{
var state = g.Save();
if (it is TCellCheck check) PaintCheck(g, check);
@@ -513,7 +507,7 @@ namespace AntdUI
#endregion
void PaintArrow(ICanvas g, RowTemplate item, SolidBrush color, int ArrowProg)
void PaintArrow(Canvas g, RowTemplate item, SolidBrush color, int ArrowProg)
{
int size = item.RectExpand.Width, size_arrow = size / 2;
var state = g.Save();
@@ -531,7 +525,7 @@ namespace AntdUI
#region
void PaintFixedColumnL(ICanvas g, Rectangle rect, RowTemplate[] rows, List<StyleRow> shows, SolidBrush fore, SolidBrush forecolumn, Font column_font, SolidBrush brush_split, int sx, int sy, float radius)
void PaintFixedColumnL(Canvas g, Rectangle rect, RowTemplate[] rows, List<StyleRow> shows, SolidBrush fore, SolidBrush forecolumn, Font column_font, SolidBrush brush_split, int sx, int sy, float radius)
{
if (fixedColumnL != null && sx > 0)
{
@@ -585,7 +579,7 @@ namespace AntdUI
}
else showFixedColumnL = false;
}
void PaintFixedColumnR(ICanvas g, Rectangle rect, RowTemplate[] rows, List<StyleRow> shows, SolidBrush fore, SolidBrush forecolumn, Font column_font, SolidBrush brush_split, int sx, int sy, float radius)
void PaintFixedColumnR(Canvas g, Rectangle rect, RowTemplate[] rows, List<StyleRow> shows, SolidBrush fore, SolidBrush forecolumn, Font column_font, SolidBrush brush_split, int sx, int sy, float radius)
{
if (fixedColumnR != null && ScrollBar.ShowX)
{
@@ -676,7 +670,7 @@ namespace AntdUI
#region
void PaintCheck(ICanvas g, TCellColumn check, ColumnCheck columnCheck)
void PaintCheck(Canvas g, TCellColumn check, ColumnCheck columnCheck)
{
using (var path_check = Helper.RoundPath(check.RECT_REAL, check_radius, false))
{
@@ -704,10 +698,7 @@ namespace AntdUI
g.FillEllipse(brush, new RectangleF(check.RECT_REAL.X + (check.RECT_REAL.Width - max) / 2F, check.RECT_REAL.Y + (check.RECT_REAL.Height - max) / 2F, max, max));
}
}
using (var brush = new Pen(Style.Db.Primary, check_border))
{
g.Draw(brush, path_check);
}
g.Draw(Style.Db.Primary, check_border, path_check);
}
}
else if (columnCheck.CheckState == CheckState.Indeterminate)
@@ -731,7 +722,7 @@ namespace AntdUI
}
}
}
void PaintCheck(ICanvas g, TCellCheck check)
void PaintCheck(Canvas g, TCellCheck check)
{
using (var path_check = Helper.RoundPath(check.RECT_REAL, check_radius, false))
{
@@ -755,10 +746,7 @@ namespace AntdUI
g.FillEllipse(brush, new RectangleF(check.RECT_REAL.X + (check.RECT_REAL.Width - max) / 2F, check.RECT_REAL.Y + (check.RECT_REAL.Height - max) / 2F, max, max));
}
}
using (var brush = new Pen(Style.Db.Primary, check_border))
{
g.Draw(brush, path_check);
}
g.Draw(Style.Db.Primary, check_border, path_check);
}
else if (check.Checked)
{
@@ -780,7 +768,7 @@ namespace AntdUI
#region
void PaintRadio(ICanvas g, TCellRadio radio)
void PaintRadio(Canvas g, TCellRadio radio)
{
var dot_size = radio.RECT_REAL.Height;
using (var brush_bg = new SolidBrush(Style.Db.BgBase))
@@ -800,42 +788,25 @@ namespace AntdUI
if (radio.Checked)
{
float max = radio.RECT_REAL.Height + radio.RECT_REAL.Height * radio.AnimationCheckValue, alpha2 = 100 * (1F - radio.AnimationCheckValue);
using (var brush = new SolidBrush(Helper.ToColor(alpha2, Style.Db.Primary)))
{
g.FillEllipse(brush, new RectangleF(radio.RECT_REAL.X + (radio.RECT_REAL.Width - max) / 2F, radio.RECT_REAL.Y + (radio.RECT_REAL.Height - max) / 2F, max, max));
}
}
using (var brush = new Pen(Style.Db.Primary, check_border))
{
g.DrawEllipse(brush, radio.RECT_REAL);
g.FillEllipse(Helper.ToColor(alpha2, Style.Db.Primary), new RectangleF(radio.RECT_REAL.X + (radio.RECT_REAL.Width - max) / 2F, radio.RECT_REAL.Y + (radio.RECT_REAL.Height - max) / 2F, max, max));
}
g.DrawEllipse(Style.Db.Primary, check_border, radio.RECT_REAL);
}
else if (radio.Checked)
{
float dot = dot_size * 0.3F, dot2 = dot / 2F;
using (var brush = new Pen(Color.FromArgb(250, Style.Db.Primary), dot))
{
g.DrawEllipse(brush, new RectangleF(radio.RECT_REAL.X + dot2, radio.RECT_REAL.Y + dot2, radio.RECT_REAL.Width - dot, radio.RECT_REAL.Height - dot));
}
using (var brush = new Pen(Style.Db.Primary, check_border))
{
g.DrawEllipse(brush, radio.RECT_REAL);
}
}
else
{
using (var brush = new Pen(Style.Db.BorderColor, check_border))
{
g.DrawEllipse(brush, radio.RECT_REAL);
}
g.DrawEllipse(Color.FromArgb(250, Style.Db.Primary), dot, new RectangleF(radio.RECT_REAL.X + dot2, radio.RECT_REAL.Y + dot2, radio.RECT_REAL.Width - dot, radio.RECT_REAL.Height - dot));
g.DrawEllipse(Style.Db.Primary, check_border, radio.RECT_REAL);
}
else g.DrawEllipse(Style.Db.BorderColor, check_border, radio.RECT_REAL);
}
#endregion
#region
void PaintSwitch(ICanvas g, TCellSwitch _switch)
void PaintSwitch(Canvas g, TCellSwitch _switch)
{
var color = Style.Db.Primary;
using (var path = _switch.RECT_REAL.RoundPath(_switch.RECT_REAL.Height))
@@ -927,7 +898,7 @@ namespace AntdUI
#endregion
void PaintEmpty(ICanvas g, Rectangle rect)
void PaintEmpty(Canvas g, Rectangle rect)
{
using (var fore = new SolidBrush(Style.Db.Text))
{

View File

@@ -247,7 +247,7 @@ namespace AntdUI
#endregion
public override void SetSize(ICanvas g, Font font, Rectangle _rect, int ox, int gap, int gap2)
public override void SetSize(Canvas g, Font font, Rectangle _rect, int ox, int gap, int gap2)
{
}
public void SetSize(Rectangle _rect, int check_size)
@@ -256,7 +256,7 @@ namespace AntdUI
RECT_REAL = new Rectangle(_rect.X + (_rect.Width - check_size) / 2, _rect.Y + (_rect.Height - check_size) / 2, check_size, check_size);
}
public override Size GetSize(ICanvas g, Font font, int width, int gap, int gap2)
public override Size GetSize(Canvas g, Font font, int width, int gap, int gap2)
{
var size = g.MeasureString(Config.NullText, font);
MinWidth = size.Width;
@@ -355,7 +355,7 @@ namespace AntdUI
#endregion
public override void SetSize(ICanvas g, Font font, Rectangle _rect, int ox, int gap, int gap2)
public override void SetSize(Canvas g, Font font, Rectangle _rect, int ox, int gap, int gap2)
{
}
public void SetSize(Rectangle _rect, int check_size)
@@ -364,7 +364,7 @@ namespace AntdUI
RECT_REAL = new Rectangle(_rect.X + (_rect.Width - check_size) / 2, _rect.Y + (_rect.Height - check_size) / 2, check_size, check_size);
}
public override Size GetSize(ICanvas g, Font font, int width, int gap, int gap2)
public override Size GetSize(Canvas g, Font font, int width, int gap, int gap2)
{
var size = g.MeasureString(Config.NullText, font);
MinWidth = size.Width;
@@ -560,7 +560,7 @@ namespace AntdUI
#endregion
public override void SetSize(ICanvas g, Font font, Rectangle _rect, int ox, int gap, int gap2)
public override void SetSize(Canvas g, Font font, Rectangle _rect, int ox, int gap, int gap2)
{
}
@@ -571,7 +571,7 @@ namespace AntdUI
RECT_REAL = new Rectangle(_rect.X + (_rect.Width - check_size2) / 2, _rect.Y + (_rect.Height - check_size) / 2, check_size2, check_size);
}
public override Size GetSize(ICanvas g, Font font, int width, int gap, int gap2)
public override Size GetSize(Canvas g, Font font, int width, int gap, int gap2)
{
var size = g.MeasureString(Config.NullText, font);
MinWidth = size.Width;
@@ -605,13 +605,13 @@ namespace AntdUI
/// </summary>
public string? value { get; set; }
public override void SetSize(ICanvas g, Font font, Rectangle _rect, int ox, int gap, int gap2)
public override void SetSize(Canvas g, Font font, Rectangle _rect, int ox, int gap, int gap2)
{
RECT = _rect;
RECT_REAL = new Rectangle(_rect.X + gap + ox, _rect.Y + gap, _rect.Width - gap2, _rect.Height - gap2);
}
public override Size GetSize(ICanvas g, Font font, int width, int gap, int gap2)
public override Size GetSize(Canvas g, Font font, int width, int gap, int gap2)
{
if (COLUMN.LineBreak)
{
@@ -656,7 +656,7 @@ namespace AntdUI
public Rectangle rect_up { get; set; }
public Rectangle rect_down { get; set; }
public override void SetSize(ICanvas g, Font font, Rectangle _rect, int ox, int gap, int gap2)
public override void SetSize(Canvas g, Font font, Rectangle _rect, int ox, int gap, int gap2)
{
RECT = _rect;
if (COLUMN.SortOrder)
@@ -667,7 +667,7 @@ namespace AntdUI
}
}
public override Size GetSize(ICanvas g, Font font, int width, int gap, int gap2)
public override Size GetSize(Canvas g, Font font, int width, int gap, int gap2)
{
var size = g.MeasureString(value, font);
SortWidth = COLUMN.SortOrder ? (int)(size.Height * 0.8F) : 0;
@@ -755,8 +755,8 @@ namespace AntdUI
public bool CONTAIN(int x, int y) => RECT.Contains(x, y);
public bool CONTAIN_REAL(int x, int y) => RECT_REAL.Contains(x, y);
public abstract void SetSize(ICanvas g, Font font, Rectangle _rect, int ox, int gap, int gap2);
public abstract Size GetSize(ICanvas g, Font font, int width, int gap, int gap2);
public abstract void SetSize(Canvas g, Font font, Rectangle _rect, int ox, int gap, int gap2);
public abstract Size GetSize(Canvas g, Font font, int width, int gap, int gap2);
#endregion
}
@@ -787,7 +787,7 @@ namespace AntdUI
/// </summary>
internal IList<ITemplate> value { get; set; }
public override void SetSize(ICanvas g, Font font, Rectangle _rect, int ox, int _gap, int _gap2)
public override void SetSize(Canvas g, Font font, Rectangle _rect, int ox, int _gap, int _gap2)
{
RECT = RECT_REAL = _rect;
int rx = _rect.X + ox;
@@ -820,7 +820,7 @@ namespace AntdUI
}
Size[] SIZES = new Size[0];
public override Size GetSize(ICanvas g, Font font, int width, int _gap, int _gap2)
public override Size GetSize(Canvas g, Font font, int width, int _gap, int _gap2)
{
int gap = _gap / 2, gap2 = _gap;
int w = 0, h = 0;
@@ -866,7 +866,7 @@ namespace AntdUI
public bool CONTAINS(int x, int y) => RECT.Contains(x, y);
public void SetRect(ICanvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
public void SetRect(Canvas g, Font font, Rectangle rect, Size size, int gap, int gap2)
{
RECT = rect;
Value.SetRect(g, font, rect, size, gap, gap2);

View File

@@ -271,7 +271,7 @@ namespace AntdUI
});
}
public void Paint(Tabs owner, ICanvas g, TabCollection items)
public void Paint(Tabs owner, Canvas g, TabCollection items)
{
if (rects.Length > 0)
{
@@ -331,7 +331,7 @@ namespace AntdUI
#region
Dictionary<TabPage, Size> GetDir(Tabs owner, ICanvas g, TabCollection items, int gap, int gapI, out int ico_size, out int sizewh)
Dictionary<TabPage, Size> GetDir(Tabs owner, Canvas g, TabCollection items, int gap, int gapI, out int ico_size, out int sizewh)
{
sizewh = 0;
var size_t = g.MeasureString(Config.NullText, owner.Font);
@@ -374,7 +374,7 @@ namespace AntdUI
return owner.HandItemSize(rect_dir, ref sizewh);
}
void PaintText(ICanvas g, TabPageRect rects, Tabs owner, TabPage page, SolidBrush brush)
void PaintText(Canvas g, TabPageRect rects, Tabs owner, TabPage page, SolidBrush brush)
{
if (page.HasIcon)
{
@@ -384,7 +384,7 @@ namespace AntdUI
g.String(page.Text, owner.Font, brush, rects.Rect_Text, owner.s_c);
owner.PaintBadge(g, page, rects.Rect_Text);
}
void PaintBar(ICanvas g, RectangleF rect, SolidBrush brush)
void PaintBar(Canvas g, RectangleF rect, SolidBrush brush)
{
if (radius > 0)
{
@@ -395,7 +395,7 @@ namespace AntdUI
}
else g.Fill(brush, rect);
}
void PaintBar(ICanvas g, Rectangle rect, SolidBrush brush)
void PaintBar(Canvas g, Rectangle rect, SolidBrush brush)
{
if (radius > 0)
{
@@ -935,7 +935,7 @@ namespace AntdUI
});
}
public void Paint(Tabs owner, ICanvas g, TabCollection items)
public void Paint(Tabs owner, Canvas g, TabCollection items)
{
if (rects.Length == items.Count)
{
@@ -973,13 +973,7 @@ namespace AntdUI
using (var path = Helper.RoundPath(page.Rect, radius, false, false, true, true))
{
g.Fill(owner.hover_i == i ? brush_bg_hover : brush_bg, path);
if (bor > 0)
{
using (var pen_bg = new Pen(border ?? AntdUI.Style.Db.BorderSecondary, bor))
{
g.Draw(pen_bg, path);
}
}
if (bor > 0) g.Draw(border ?? AntdUI.Style.Db.BorderSecondary, bor, path);
if (owner.hover_i == i) PaintText(g, rects[i], owner, page, page.MDown ? brush_active : brush_hover);
else PaintText(g, rects[i], owner, page, brush_fore);
}
@@ -1037,13 +1031,7 @@ namespace AntdUI
using (var path = Helper.RoundPath(page.Rect, radius, true, false, false, true))
{
g.Fill(owner.hover_i == i ? brush_bg_hover : brush_bg, path);
if (bor > 0)
{
using (var pen_bg = new Pen(border ?? AntdUI.Style.Db.BorderSecondary, bor))
{
g.Draw(pen_bg, path);
}
}
if (bor > 0) g.Draw(border ?? AntdUI.Style.Db.BorderSecondary, bor, path);
if (owner.hover_i == i) PaintText(g, rects[i], owner, page, page.MDown ? brush_active : brush_hover);
else PaintText(g, rects[i], owner, page, brush_fore);
}
@@ -1102,13 +1090,7 @@ namespace AntdUI
using (var path = Helper.RoundPath(page.Rect, radius, false, true, true, false))
{
g.Fill(owner.hover_i == i ? brush_bg_hover : brush_bg, path);
if (bor > 0)
{
using (var pen_bg = new Pen(border ?? AntdUI.Style.Db.BorderSecondary, bor))
{
g.Draw(pen_bg, path);
}
}
if (bor > 0) g.Draw(border ?? AntdUI.Style.Db.BorderSecondary, bor, path);
if (owner.hover_i == i) PaintText(g, rects[i], owner, page, page.MDown ? brush_active : brush_hover);
else PaintText(g, rects[i], owner, page, brush_fore);
}
@@ -1167,13 +1149,7 @@ namespace AntdUI
using (var path = Helper.RoundPath(page.Rect, radius, true, true, false, false))
{
g.Fill(owner.hover_i == i ? brush_bg_hover : brush_bg, path);
if (bor > 0)
{
using (var pen_bg = new Pen(border ?? AntdUI.Style.Db.BorderSecondary, bor))
{
g.Draw(pen_bg, path);
}
}
if (bor > 0) g.Draw(border ?? AntdUI.Style.Db.BorderSecondary, bor, path);
if (owner.hover_i == i) PaintText(g, rects[i], owner, page, page.MDown ? brush_active : brush_hover);
else PaintText(g, rects[i], owner, page, brush_fore);
}
@@ -1222,7 +1198,7 @@ namespace AntdUI
#region
Dictionary<TabPage, Size> GetDir(Tabs owner, ICanvas g, TabCollection items, int gap, out int ico_size, out int close_size, out int sizewh)
Dictionary<TabPage, Size> GetDir(Tabs owner, Canvas g, TabCollection items, int gap, out int ico_size, out int close_size, out int sizewh)
{
sizewh = 0;
var size_t = g.MeasureString(Config.NullText, owner.Font);
@@ -1283,7 +1259,7 @@ namespace AntdUI
return owner.HandItemSize(rect_dir, ref sizewh);
}
void PaintText(ICanvas g, TabPageRect rects, Tabs owner, TabPage page, SolidBrush brush)
void PaintText(Canvas g, TabPageRect rects, Tabs owner, TabPage page, SolidBrush brush)
{
if (page.HasIcon)
{
@@ -1802,7 +1778,7 @@ namespace AntdUI
});
}
public void Paint(Tabs owner, ICanvas g, TabCollection items)
public void Paint(Tabs owner, Canvas g, TabCollection items)
{
if (rects.Length == items.Count)
{
@@ -1840,13 +1816,7 @@ namespace AntdUI
using (var path = Helper.RoundPath(page.Rect, radius, true, true, true, true))
{
g.Fill(owner.hover_i == i ? brush_bg_hover : brush_bg, path);
if (bor > 0)
{
using (var pen_bg = new Pen(border ?? AntdUI.Style.Db.BorderSecondary, bor))
{
g.Draw(pen_bg, path);
}
}
if (bor > 0) g.Draw(border ?? AntdUI.Style.Db.BorderSecondary, bor, path);
if (owner.hover_i == i) PaintText(g, rects[i], owner, page, page.MDown ? brush_active : brush_hover, true);
else PaintText(g, rects[i], owner, page, brush_fore, closable == CloseType.always ? true : false);
}
@@ -1862,16 +1832,13 @@ namespace AntdUI
{
if (bor > 0)
{
using (var pen_bg = new Pen(BorderActive ?? AntdUI.Style.Db.BorderColor, bor))
float ly = rect_page.Y + borb2;
if (owner.scroll_show) g.TranslateTransform(-owner.scroll_x, -owner.scroll_y);
using (var path2 = Helper.RoundPath(new RectangleF(rect_page.X + borb2, rect_page.Y - borb2, rect_page.Width - bor, rect_page.Height + borb2), radius, true, true, true, true))
{
float ly = rect_page.Y + borb2;
if (owner.scroll_show) g.TranslateTransform(-owner.scroll_x, -owner.scroll_y);
using (var path2 = Helper.RoundPath(new RectangleF(rect_page.X + borb2, rect_page.Y - borb2, rect_page.Width - bor, rect_page.Height + borb2), radius, true, true, true, true))
{
g.Fill(brush_bg_active, path2);
}
g.Draw(pen_bg, path);
g.Fill(brush_bg_active, path2);
}
g.Draw(BorderActive ?? AntdUI.Style.Db.BorderColor, bor, path);
}
else
{
@@ -1900,13 +1867,7 @@ namespace AntdUI
using (var path = Helper.RoundPath(page.Rect, radius, true, true, true, true))
{
g.Fill(owner.hover_i == i ? brush_bg_hover : brush_bg, path);
if (bor > 0)
{
using (var pen_bg = new Pen(border ?? AntdUI.Style.Db.BorderSecondary, bor))
{
g.Draw(pen_bg, path);
}
}
if (bor > 0) g.Draw(border ?? AntdUI.Style.Db.BorderSecondary, bor, path);
if (owner.hover_i == i) PaintText(g, rects[i], owner, page, page.MDown ? brush_active : brush_hover, true);
else PaintText(g, rects[i], owner, page, brush_fore, closable == CloseType.always ? true : false);
}
@@ -1922,16 +1883,13 @@ namespace AntdUI
{
if (bor > 0)
{
using (var pen_bg = new Pen(BorderActive ?? AntdUI.Style.Db.BorderColor, bor))
float lx = rect_page.Right - borb2;
if (owner.scroll_show) g.TranslateTransform(-owner.scroll_x, -owner.scroll_y);
using (var path2 = Helper.RoundPath(new RectangleF(rect_page.X - borb2, rect_page.Y + borb2, rect_page.Width + borb2, rect_page.Height - bor), radius, true, true, true, true))
{
float lx = rect_page.Right - borb2;
if (owner.scroll_show) g.TranslateTransform(-owner.scroll_x, -owner.scroll_y);
using (var path2 = Helper.RoundPath(new RectangleF(rect_page.X - borb2, rect_page.Y + borb2, rect_page.Width + borb2, rect_page.Height - bor), radius, true, true, true, true))
{
g.Fill(brush_bg_active, path2);
}
g.Draw(pen_bg, path);
g.Fill(brush_bg_active, path2);
}
g.Draw(BorderActive ?? AntdUI.Style.Db.BorderColor, bor, path);
}
else
{
@@ -1961,13 +1919,7 @@ namespace AntdUI
using (var path = Helper.RoundPath(page.Rect, radius, true, true, true, true))
{
g.Fill(owner.hover_i == i ? brush_bg_hover : brush_bg, path);
if (bor > 0)
{
using (var pen_bg = new Pen(border ?? AntdUI.Style.Db.BorderSecondary, bor))
{
g.Draw(pen_bg, path);
}
}
if (bor > 0) g.Draw(border ?? AntdUI.Style.Db.BorderSecondary, bor, path);
if (owner.hover_i == i) PaintText(g, rects[i], owner, page, page.MDown ? brush_active : brush_hover, true);
else PaintText(g, rects[i], owner, page, brush_fore, closable == CloseType.always ? true : false);
}
@@ -1983,16 +1935,13 @@ namespace AntdUI
{
if (bor > 0)
{
using (var pen_bg = new Pen(BorderActive ?? AntdUI.Style.Db.BorderColor, bor))
float lx = rect_page.X + borb2;
if (owner.scroll_show) g.TranslateTransform(-owner.scroll_x, -owner.scroll_y);
using (var path2 = Helper.RoundPath(new RectangleF(rect_page.X - borb2, rect_page.Y + borb2, rect_page.Width + borb2, rect_page.Height - bor), radius, true, true, true, true))
{
float lx = rect_page.X + borb2;
if (owner.scroll_show) g.TranslateTransform(-owner.scroll_x, -owner.scroll_y);
using (var path2 = Helper.RoundPath(new RectangleF(rect_page.X - borb2, rect_page.Y + borb2, rect_page.Width + borb2, rect_page.Height - bor), radius, true, true, true, true))
{
g.Fill(brush_bg_active, path2);
}
g.Draw(pen_bg, path);
g.Fill(brush_bg_active, path2);
}
g.Draw(BorderActive ?? AntdUI.Style.Db.BorderColor, bor, path);
}
else
{
@@ -2022,13 +1971,7 @@ namespace AntdUI
using (var path = Helper.RoundPath(page.Rect, radius, true, true, true, true))
{
g.Fill(owner.hover_i == i ? brush_bg_hover : brush_bg, path);
if (bor > 0)
{
using (var pen_bg = new Pen(border ?? AntdUI.Style.Db.BorderSecondary, bor))
{
g.Draw(pen_bg, path);
}
}
if (bor > 0) g.Draw(border ?? AntdUI.Style.Db.BorderSecondary, bor, path);
if (owner.hover_i == i) PaintText(g, rects[i], owner, page, page.MDown ? brush_active : brush_hover, true);
else PaintText(g, rects[i], owner, page, brush_fore, closable == CloseType.always ? true : false);
}
@@ -2044,16 +1987,13 @@ namespace AntdUI
{
if (bor > 0)
{
using (var pen_bg = new Pen(BorderActive ?? AntdUI.Style.Db.BorderColor, bor))
float ly = rect_page.Bottom - borb2;
if (owner.scroll_show) g.TranslateTransform(-owner.scroll_x, -owner.scroll_y);
using (var path2 = Helper.RoundPath(new RectangleF(rect_page.X + borb2, rect_page.Y - borb2, rect_page.Width - bor, rect_page.Height + borb2), radius, true, true, true, true))
{
float ly = rect_page.Bottom - borb2;
if (owner.scroll_show) g.TranslateTransform(-owner.scroll_x, -owner.scroll_y);
using (var path2 = Helper.RoundPath(new RectangleF(rect_page.X + borb2, rect_page.Y - borb2, rect_page.Width - bor, rect_page.Height + borb2), radius, true, true, true, true))
{
g.Fill(brush_bg_active, path2);
}
g.Draw(pen_bg, path);
g.Fill(brush_bg_active, path2);
}
g.Draw(BorderActive ?? AntdUI.Style.Db.BorderColor, bor, path);
}
else
{
@@ -2073,7 +2013,7 @@ namespace AntdUI
#region
Dictionary<TabPage, Size> GetDir(Tabs owner, ICanvas g, TabCollection items, int gap, out int ico_size, out int close_size, out int sizewh)
Dictionary<TabPage, Size> GetDir(Tabs owner, Canvas g, TabCollection items, int gap, out int ico_size, out int close_size, out int sizewh)
{
sizewh = 0;
var size_t = g.MeasureString(Config.NullText, owner.Font);
@@ -2134,7 +2074,7 @@ namespace AntdUI
return owner.HandItemSize(rect_dir, ref sizewh);
}
void PaintText(ICanvas g, TabPageRect rects, Tabs owner, TabPage page, SolidBrush brush, bool closshow = false)
void PaintText(Canvas g, TabPageRect rects, Tabs owner, TabPage page, SolidBrush brush, bool closshow = false)
{
if (page.HasIcon)
{
@@ -2281,7 +2221,7 @@ namespace AntdUI
public interface IStyle
{
void LoadLayout(Tabs owner, Rectangle rect, TabCollection items);
void Paint(Tabs owner, ICanvas g, TabCollection items);
void Paint(Tabs owner, Canvas g, TabCollection items);
void SelectedIndexChanged(int i, int old);
bool MouseClick(TabPage page, int i, int x, int y);
void MouseMove(int x, int y);

View File

@@ -500,14 +500,13 @@ namespace AntdUI
base.OnPaint(e);
}
void PaintBadge(ICanvas g, TabPage page, Rectangle rect)
void PaintBadge(Canvas g, TabPage page, Rectangle rect)
{
if (page.Badge != null)
{
var color = page.BadgeBack ?? AntdUI.Style.Db.Error;
using (var brush_fore = new SolidBrush(AntdUI.Style.Db.ErrorColor))
{
float borsize = 1F * Config.Dpi;
using (var font = new Font(Font.FontFamily, Font.Size * page.BadgeSize))
{
if (string.IsNullOrEmpty(page.Badge) || page.Badge == "" || page.Badge == " ")
@@ -517,10 +516,7 @@ namespace AntdUI
using (var brush = new SolidBrush(color))
{
g.FillEllipse(brush, rect_badge);
using (var pen = new Pen(brush_fore.Color, borsize))
{
g.DrawEllipse(pen, rect_badge);
}
g.DrawEllipse(brush_fore.Color, Config.Dpi, rect_badge);
}
}
else
@@ -533,10 +529,7 @@ namespace AntdUI
using (var brush = new SolidBrush(color))
{
g.FillEllipse(brush, rect_badge);
using (var pen = new Pen(brush_fore.Color, borsize))
{
g.DrawEllipse(pen, rect_badge);
}
g.DrawEllipse(brush_fore.Color, Config.Dpi, rect_badge);
}
g.String(page.Badge, font, brush_fore, rect_badge, s_f);
}
@@ -549,10 +542,7 @@ namespace AntdUI
using (var path = rect_badge.RoundPath(rect_badge.Height))
{
g.Fill(brush, path);
using (var pen = new Pen(brush_fore.Color, borsize))
{
g.Draw(pen, path);
}
g.Draw(brush_fore.Color, Config.Dpi, path);
}
}
g.String(page.Badge, font, brush_fore, rect_badge, s_f);
@@ -894,7 +884,7 @@ namespace AntdUI
}
Bitmap? bitblock_l = null, bitblock_r = null;
public virtual void PaintExceed(ICanvas g, Color color, int radius, Rectangle rect, Rectangle first, Rectangle last, bool full)
public virtual void PaintExceed(Canvas g, Color color, int radius, Rectangle rect, Rectangle first, Rectangle last, bool full)
{
switch (typExceed)
{
@@ -913,7 +903,7 @@ namespace AntdUI
}
}
public virtual void PaintExceedButton(ICanvas g, Color color, int radius, Rectangle rect, Rectangle first, Rectangle last, bool full)
public virtual void PaintExceedButton(Canvas g, Color color, int radius, Rectangle rect, Rectangle first, Rectangle last, bool full)
{
g.ResetClip();
g.ResetTransform();
@@ -1030,7 +1020,7 @@ namespace AntdUI
break;
}
}
public virtual void PaintExceedLR(ICanvas g, Color color, int radius, Rectangle rect, Rectangle first, Rectangle last, bool full)
public virtual void PaintExceedLR(Canvas g, Color color, int radius, Rectangle rect, Rectangle first, Rectangle last, bool full)
{
g.ResetClip();
g.ResetTransform();
@@ -1133,7 +1123,7 @@ namespace AntdUI
break;
}
}
public virtual void PaintExceedLR_Shadow(ICanvas g, Color color, int radius, Rectangle rect, Rectangle first, Rectangle last, bool full)
public virtual void PaintExceedLR_Shadow(Canvas g, Color color, int radius, Rectangle rect, Rectangle first, Rectangle last, bool full)
{
g.ResetClip();
g.ResetTransform();

View File

@@ -382,7 +382,7 @@ namespace AntdUI
#region
internal void PaintText(ICanvas g, string? text, Color color, Rectangle rect_read)
internal void PaintText(Canvas g, string? text, Color color, Rectangle rect_read)
{
var font_size = g.MeasureString(text ?? Config.NullText, Font);
if (text == null)
@@ -426,7 +426,7 @@ namespace AntdUI
/// <param name="color">颜色</param>
/// <param name="font_size">字体大小</param>
/// <param name="rect_read">客户区域</param>
bool PaintImageNoText(ICanvas g, Color? color, Size font_size, Rectangle rect_read)
bool PaintImageNoText(Canvas g, Color? color, Size font_size, Rectangle rect_read)
{
if (imageSvg != null)
{
@@ -466,7 +466,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="color">颜色</param>
/// <param name="rectl">图标区域</param>
void PaintImage(ICanvas g, Color? color, Rectangle rectl)
void PaintImage(Canvas g, Color? color, Rectangle rectl)
{
if (imageSvg != null) g.GetImgExtend(imageSvg, GetImageRect(rectl), color);
else if (image != null) g.Image(image, GetImageRect(rectl));

View File

@@ -100,7 +100,7 @@ namespace AntdUI
get => showicon;
}
protected override void PaintRIcon(ICanvas g, Rectangle rect_r)
protected override void PaintRIcon(Canvas g, Rectangle rect_r)
{
if (showicon)
{

View File

@@ -229,10 +229,7 @@ namespace AntdUI
}
g.FillEllipse(brush_dotback, it.ico_rect);
using (var pen = new Pen(fill, it.pen_w))
{
g.DrawEllipse(pen, it.ico_rect);
}
g.DrawEllipse(fill, it.pen_w, it.ico_rect);
}
}
}
@@ -243,7 +240,7 @@ namespace AntdUI
base.OnPaint(e);
}
bool PaintIcon(ICanvas g, TimelineItem it, Color fore)
bool PaintIcon(Canvas g, TimelineItem it, Color fore)
{
if (it.Icon != null) { g.Image(it.Icon, it.ico_rect); return false; }
else if (it.IconSvg != null)

View File

@@ -434,7 +434,7 @@ namespace AntdUI
{
#region
public static Size RenderMeasure(this ITooltip core, ICanvas g, out bool multiline)
public static Size RenderMeasure(this ITooltip core, Canvas g, out bool multiline)
{
multiline = core.Text.Contains("\n");
int padding = (int)Math.Ceiling(20 * Config.Dpi);
@@ -454,7 +454,7 @@ namespace AntdUI
else return new Size(font_size.Width + padding + core.ArrowSize, font_size.Height + padding);
}
public static void Render(this ITooltip core, ICanvas g, Rectangle rect, bool multiline, StringFormat s_c, StringFormat s_l)
public static void Render(this ITooltip core, Canvas g, Rectangle rect, bool multiline, StringFormat s_c, StringFormat s_l)
{
int gap = (int)Math.Ceiling(5 * Config.Dpi), padding = gap * 2, padding2 = padding * 2;
using (var brush = new SolidBrush(Config.Mode == TMode.Dark ? Color.FromArgb(66, 66, 66) : Color.FromArgb(38, 38, 38)))
@@ -501,13 +501,13 @@ namespace AntdUI
}
}
static void RenderText(ITooltip core, ICanvas g, Rectangle rect, bool multiline, int padding, int padding2, StringFormat s_c, StringFormat s_l)
static void RenderText(ITooltip core, Canvas g, Rectangle rect, bool multiline, int padding, int padding2, StringFormat s_c, StringFormat s_l)
{
if (multiline) g.String(core.Text, core.Font, Brushes.White, new Rectangle(rect.X + padding, rect.Y + padding, rect.Width - padding2, rect.Height - padding2), s_l);
else g.String(core.Text, core.Font, Brushes.White, rect, s_c);
}
static void DrawShadow(this ITooltip core, ICanvas _g, Rectangle brect, Rectangle rect, int size, GraphicsPath path2)
static void DrawShadow(this ITooltip core, Canvas _g, Rectangle brect, Rectangle rect, int size, GraphicsPath path2)
{
using (var bmp = new Bitmap(brect.Width, brect.Height))
{

View File

@@ -452,7 +452,7 @@ namespace AntdUI
}
}
void ChangeList(ICanvas g, Rectangle rect, TreeItem? Parent, TreeItemCollection items, bool has_sub, ref int x, ref int y, int height, int icon_size, int gap, int gapI, int depth, bool expand)
void ChangeList(Canvas g, Rectangle rect, TreeItem? Parent, TreeItemCollection items, bool has_sub, ref int x, ref int y, int height, int icon_size, int gap, int gapI, int depth, bool expand)
{
foreach (var it in items)
{
@@ -513,7 +513,7 @@ namespace AntdUI
base.OnPaint(e);
}
void PaintItem(ICanvas g, Rectangle rect, int sx, int sy, TreeItemCollection items, SolidBrush fore, SolidBrush fore_active, SolidBrush hover, SolidBrush active, SolidBrush brushTextTertiary, float radius)
void PaintItem(Canvas g, Rectangle rect, int sx, int sy, TreeItemCollection items, SolidBrush fore, SolidBrush fore_active, SolidBrush hover, SolidBrush active, SolidBrush brushTextTertiary, float radius)
{
foreach (var it in items)
{
@@ -533,7 +533,7 @@ namespace AntdUI
}
readonly StringFormat s_c = Helper.SF_Ellipsis(), s_l = Helper.SF_ALL(lr: StringAlignment.Near);
void PaintItem(ICanvas g, TreeItem item, SolidBrush fore, SolidBrush fore_active, SolidBrush hover, SolidBrush active, SolidBrush brushTextTertiary, float radius, int sx, int sy)
void PaintItem(Canvas g, TreeItem item, SolidBrush fore, SolidBrush fore_active, SolidBrush hover, SolidBrush active, SolidBrush brushTextTertiary, float radius, int sx, int sy)
{
if (item.Select)
{
@@ -596,6 +596,7 @@ namespace AntdUI
{
using (var path_check = Helper.RoundPath(item.check_rect, check_radius, false))
{
var bor2 = 2F * Config.Dpi;
if (item.Enabled)
{
if (item.AnimationCheck)
@@ -604,27 +605,15 @@ namespace AntdUI
if (item.CheckState == CheckState.Indeterminate || (item.checkStateOld == CheckState.Indeterminate && !item.Checked))
{
using (var brush = new Pen(Style.Db.BorderColor, 2F))
{
g.Draw(brush, path_check);
}
using (var brush = new SolidBrush(Helper.ToColor(alpha, Style.Db.Primary)))
{
g.Fill(brush, PaintBlock(item.check_rect));
}
g.Draw(Style.Db.BorderColor, bor2, path_check);
g.Fill(Helper.ToColor(alpha, Style.Db.Primary), PaintBlock(item.check_rect));
}
else
{
float dot = item.check_rect.Width * 0.3F;
using (var brush = new SolidBrush(Helper.ToColor(alpha, Style.Db.Primary)))
{
g.Fill(brush, path_check);
}
using (var brush = new Pen(Helper.ToColor(alpha, Style.Db.BgBase), 3F * Config.Dpi))
{
g.DrawLines(brush, PaintArrow(item.check_rect));
}
g.Fill(Helper.ToColor(alpha, Style.Db.Primary), path_check);
g.DrawLines(Helper.ToColor(alpha, Style.Db.BgBase), 3F * Config.Dpi, PaintArrow(item.check_rect));
if (item.Checked)
{
@@ -634,59 +623,32 @@ namespace AntdUI
g.FillEllipse(brush, new RectangleF(item.check_rect.X + (item.check_rect.Width - max) / 2F, item.check_rect.Y + (item.check_rect.Height - max) / 2F, max, max));
}
}
using (var brush = new Pen(Style.Db.Primary, 2F * Config.Dpi))
{
g.Draw(brush, path_check);
}
g.Draw(Style.Db.Primary, 2F * Config.Dpi, path_check);
}
}
else if (item.CheckState == CheckState.Indeterminate)
{
using (var brush = new Pen(Style.Db.BorderColor, 2F * Config.Dpi))
{
g.Draw(brush, path_check);
}
using (var brush = new SolidBrush(Style.Db.Primary))
{
g.Fill(brush, PaintBlock(item.check_rect));
}
g.Draw(Style.Db.BorderColor, bor2, path_check);
g.Fill(Style.Db.Primary, PaintBlock(item.check_rect));
}
else if (item.Checked)
{
g.Fill(Style.Db.Primary, path_check);
using (var brush = new Pen(Style.Db.BgBase, 3F * Config.Dpi))
{
g.DrawLines(brush, PaintArrow(item.check_rect));
}
}
else
{
using (var brush = new Pen(Style.Db.BorderColor, 2F * Config.Dpi))
{
g.Draw(brush, path_check);
}
g.DrawLines(Style.Db.BgBase, 3F * Config.Dpi, PaintArrow(item.check_rect));
}
else g.Draw(Style.Db.BorderColor, bor2, path_check);
}
else
{
g.Fill(Style.Db.FillQuaternary, path_check);
if (item.CheckState == CheckState.Indeterminate) g.Fill(Style.Db.TextQuaternary, PaintBlock(item.check_rect));
else if (item.Checked)
{
using (var brush = new Pen(Style.Db.TextQuaternary, 3F * Config.Dpi))
{
g.DrawLines(brush, PaintArrow(item.check_rect));
}
}
using (var brush = new Pen(Style.Db.BorderColorDisable, 2F * Config.Dpi))
{
g.Draw(brush, path_check);
}
else if (item.Checked) g.DrawLines(Style.Db.TextQuaternary, 3F * Config.Dpi, PaintArrow(item.check_rect));
g.Draw(Style.Db.BorderColorDisable, bor2, path_check);
}
}
}
}
void PaintItemText(ICanvas g, TreeItem item, SolidBrush fore, SolidBrush brushTextTertiary)
void PaintItemText(Canvas g, TreeItem item, SolidBrush fore, SolidBrush brushTextTertiary)
{
Color color = fore.Color;
if (item.Fore.HasValue)
@@ -718,7 +680,7 @@ namespace AntdUI
};
}
void PaintArrow(ICanvas g, TreeItem item, SolidBrush color, int sx, int sy)
void PaintArrow(Canvas g, TreeItem item, SolidBrush color, int sx, int sy)
{
using (var pen = new Pen(color, 2F))
{
@@ -730,7 +692,7 @@ namespace AntdUI
}
}
void PaintArrow(ICanvas g, TreeItem item, Pen pen, int sx, int sy, float rotate)
void PaintArrow(Canvas g, TreeItem item, Pen pen, int sx, int sy, float rotate)
{
int size_arrow = item.arr_rect.Width / 2;
g.TranslateTransform(item.arr_rect.X + size_arrow, item.arr_rect.Y + size_arrow);
@@ -740,7 +702,7 @@ namespace AntdUI
g.TranslateTransform(-sx, -sy);
}
void PaintBack(ICanvas g, SolidBrush brush, Rectangle rect, float radius)
void PaintBack(Canvas g, SolidBrush brush, Rectangle rect, float radius)
{
if (round || radius > 0)
{
@@ -1442,7 +1404,7 @@ namespace AntdUI
internal Tree? PARENT { get; set; }
public TreeItem? PARENTITEM { get; set; }
internal void SetRect(ICanvas g, Font font, int depth, bool checkable, bool blockNode, bool has_sub, Rectangle _rect, int icon_size, int gap)
internal void SetRect(Canvas g, Font font, int depth, bool checkable, bool blockNode, bool has_sub, Rectangle _rect, int icon_size, int gap)
{
Depth = depth;
rect = _rect;

View File

@@ -363,31 +363,11 @@ namespace AntdUI
var borw = borderWidth * Config.Dpi;
if (AnimationHover)
{
using (var brush = new Pen(borderColor ?? Style.Db.BorderColor, borw))
{
g.Draw(brush, path);
}
using (var brush = new Pen(Helper.ToColor(AnimationHoverValue, Style.Db.PrimaryHover), borw))
{
g.Draw(brush, path);
}
}
else if (ExtraMouseHover)
{
using (var brush_bor = new Pen(Style.Db.PrimaryHover, borw))
{
brush_bor.DashStyle = borderStyle;
g.Draw(brush_bor, path);
}
}
else
{
using (var brush_bor = new Pen(borderColor ?? Style.Db.BorderColor, borw))
{
brush_bor.DashStyle = borderStyle;
g.Draw(brush_bor, path);
}
g.Draw(borderColor ?? Style.Db.BorderColor, borw, path);
g.Draw(Helper.ToColor(AnimationHoverValue, Style.Db.PrimaryHover), borw, path);
}
else if (ExtraMouseHover) g.Draw(Style.Db.PrimaryHover, borw, borderStyle, path);
else g.Draw(borderColor ?? Style.Db.BorderColor, borw, borderStyle, path);
}
}
this.PaintBadge(g);

View File

@@ -540,7 +540,7 @@ namespace AntdUI
Bitmap? temp_logo = null, temp_min = null, temp_max = null, temp_restore = null, temp_close = null, temp_close_hover = null;
void PrintClose(ICanvas g, Color color, Rectangle rect_icon)
void PrintClose(Canvas g, Color color, Rectangle rect_icon)
{
if (temp_close == null || temp_close.Width != rect_icon.Width)
{
@@ -549,7 +549,7 @@ namespace AntdUI
}
if (temp_close != null) g.Image(temp_close, rect_icon);
}
void PrintCloseHover(ICanvas g, Rectangle rect_icon)
void PrintCloseHover(Canvas g, Rectangle rect_icon)
{
if (temp_close_hover == null || temp_close_hover.Width != rect_icon.Width)
{
@@ -558,7 +558,7 @@ namespace AntdUI
}
if (temp_close_hover != null) g.Image(temp_close_hover, rect_icon);
}
void PrintMax(ICanvas g, Color color, Rectangle rect_icon)
void PrintMax(Canvas g, Color color, Rectangle rect_icon)
{
if (temp_max == null || temp_max.Width != rect_icon.Width)
{
@@ -567,7 +567,7 @@ namespace AntdUI
}
if (temp_max != null) g.Image(temp_max, rect_icon);
}
void PrintRestore(ICanvas g, Color color, Rectangle rect_icon)
void PrintRestore(Canvas g, Color color, Rectangle rect_icon)
{
if (temp_restore == null || temp_restore.Width != rect_icon.Width)
{
@@ -576,7 +576,7 @@ namespace AntdUI
}
if (temp_restore != null) g.Image(temp_restore, rect_icon);
}
void PrintMin(ICanvas g, Color color, Rectangle rect_icon)
void PrintMin(Canvas g, Color color, Rectangle rect_icon)
{
if (temp_min == null || temp_min.Width != rect_icon.Width)
{
@@ -585,7 +585,7 @@ namespace AntdUI
}
if (temp_min != null) g.Image(temp_min, rect_icon);
}
bool PrintLogo(ICanvas g, string svg, Color color, Rectangle rect_icon)
bool PrintLogo(Canvas g, string svg, Color color, Rectangle rect_icon)
{
if (temp_logo == null || temp_logo.Width != rect_icon.Width)
{

View File

@@ -296,7 +296,7 @@ namespace AntdUI.Design
Rectangle rect_colors_big;
Rectangle rect_colors;
Bitmap? bmp_colors = null;
void PaintColors(ICanvas g, Rectangle rect)
void PaintColors(Canvas g, Rectangle rect)
{
using (var brush = new SolidBrush(ValueHue))
{
@@ -340,7 +340,7 @@ namespace AntdUI.Design
Rectangle rect_hue_big;
Rectangle rect_hue;
Bitmap? bmp_hue = null;
void PaintHue(ICanvas g, Rectangle rect)
void PaintHue(Canvas g, Rectangle rect)
{
int width = (rect.Width - 4) / 6;
Rectangle rect1 = new Rectangle(2, 0, width, rect.Height), rect2 = new Rectangle(rect1.X + width, 0, width, rect.Height),
@@ -423,7 +423,7 @@ namespace AntdUI.Design
Rectangle rect_alpha;
Bitmap? bmp_alpha = null, bmp_alpha_read = null;
Color color_alpha = Color.White;
void PaintAlpha(ICanvas g, Rectangle rect, bool add)
void PaintAlpha(Canvas g, Rectangle rect, bool add)
{
if (add)
{

View File

@@ -202,13 +202,7 @@ namespace AntdUI
g.Image(bitbmp, new Rectangle(shadow2, 0, bitmap.Width - shadow4, shadow), new Rectangle(shadow2, 0, bitbmp.Width - shadow4, shadow), GraphicsUnit.Pixel);
g.ResetClip();
if (form.BorderWidth > 0)
{
using (var pen = new Pen(form.BorderColor, form.BorderWidth * Config.Dpi))
{
g.Draw(pen, path);
}
}
if (form.BorderWidth > 0) g.Draw(form.BorderColor, form.BorderWidth * Config.Dpi, path);
}
}
return bitmap;

View File

@@ -470,7 +470,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintYear(ICanvas g, Rectangle rect_read, List<Calendari> datas)
void PrintYear(Canvas g, Rectangle rect_read, List<Calendari> datas)
{
using (var brush_fore_disable = new SolidBrush(Style.Db.TextQuaternary))
using (var brush_bg_disable = new SolidBrush(Style.Db.FillTertiary))
@@ -520,25 +520,13 @@ namespace AntdUI
else if (it.enable)
{
if (it.hover) g.Fill(Style.Db.FillTertiary, path);
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, it.t == 1 ? brush_fore : brush_fore_disable, it.rect, s_f);
}
else
{
g.Fill(brush_bg_disable, new Rectangle(it.rect.X, it.rect_read.Y, it.rect.Width, it.rect_read.Height));
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore_disable, it.rect, s_f);
}
}
@@ -556,7 +544,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintMonth(ICanvas g, Rectangle rect_read, List<Calendari> datas)
void PrintMonth(Canvas g, Rectangle rect_read, List<Calendari> datas)
{
using (var brush_fore_disable = new SolidBrush(Style.Db.TextQuaternary))
using (var brush_bg_disable = new SolidBrush(Style.Db.FillTertiary))
@@ -606,25 +594,13 @@ namespace AntdUI
else if (it.enable)
{
if (it.hover) g.Fill(Style.Db.FillTertiary, path);
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore, it.rect, s_f);
}
else
{
g.Fill(brush_bg_disable, new Rectangle(it.rect.X, it.rect_read.Y, it.rect.Width, it.rect_read.Height));
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore_disable, it.rect, s_f);
}
}
@@ -643,7 +619,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintDay(ICanvas g, Rectangle rect_read, List<Calendari> datas)
void PrintDay(Canvas g, Rectangle rect_read, List<Calendari> datas)
{
using (var brush_fore = new SolidBrush(Style.Db.TextBase))
{
@@ -784,10 +760,7 @@ namespace AntdUI
{
using (var path = it.rect_read.RoundPath(Radius))
{
using (var pen_active = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(pen_active, path);
}
g.Draw(Style.Db.Primary, Config.Dpi, path);
}
}
}
@@ -944,7 +917,7 @@ namespace AntdUI
/// </summary>
/// <param name="g">GDI</param>
/// <param name="rect">客户区域</param>
void DrawShadow(ICanvas g, Rectangle rect)
void DrawShadow(Canvas g, Rectangle rect)
{
if (Config.ShadowEnabled)
{

View File

@@ -915,7 +915,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintYear(ICanvas g, Rectangle rect_read, List<Calendari> datas)
void PrintYear(Canvas g, Rectangle rect_read, List<Calendari> datas)
{
using (var brush_fore_disable = new SolidBrush(Style.Db.TextQuaternary))
using (var brush_bg_disable = new SolidBrush(Style.Db.FillTertiary))
@@ -965,25 +965,13 @@ namespace AntdUI
else if (it.enable)
{
if (it.hover) g.Fill(Style.Db.FillTertiary, path);
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, it.t == 1 ? brush_fore : brush_fore_disable, it.rect, s_f);
}
else
{
g.Fill(brush_bg_disable, new Rectangle(it.rect.X, it.rect_read.Y, it.rect.Width, it.rect_read.Height));
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore_disable, it.rect, s_f);
}
}
@@ -1001,7 +989,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintMonth(ICanvas g, Rectangle rect_read, List<Calendari> datas)
void PrintMonth(Canvas g, Rectangle rect_read, List<Calendari> datas)
{
using (var brush_fore_disable = new SolidBrush(Style.Db.TextQuaternary))
using (var brush_bg_disable = new SolidBrush(Style.Db.FillTertiary))
@@ -1051,25 +1039,13 @@ namespace AntdUI
else if (it.enable)
{
if (it.hover) g.Fill(Style.Db.FillTertiary, path);
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore, it.rect, s_f);
}
else
{
g.Fill(brush_bg_disable, new Rectangle(it.rect.X, it.rect_read.Y, it.rect.Width, it.rect_read.Height));
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore_disable, it.rect, s_f);
}
}
@@ -1088,7 +1064,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintDay(ICanvas g, Rectangle rect_read, List<Calendari> datas, List<Calendari> datas2)
void PrintDay(Canvas g, Rectangle rect_read, List<Calendari> datas, List<Calendari> datas2)
{
using (var brush_fore = new SolidBrush(Style.Db.TextBase))
{
@@ -1173,7 +1149,7 @@ namespace AntdUI
using (var brush_split = new SolidBrush(Style.Db.Split))
{
g.Fill(brush_split, new RectangleF(t_x + rect_read.X, rect_read.Y + t_top, t_width - t_x, 1F));
g.Fill(brush_split, new RectangleF(t_x + rect_read.X, rect_read.Y + t_top, t_width - t_x, Config.Dpi));
if (left_buttons != null) g.Fill(brush_split, new RectangleF(t_x + rect_read.X, rect_read.Y, 1F, rect_read.Height));
}
int y = rect_read.Y + t_top + 12;
@@ -1295,7 +1271,7 @@ namespace AntdUI
}
}
}
void PrintCalendarMutual(ICanvas g, DateTime oldTime, DateTime oldTimeHover, Brush brush_bg_active, Brush brush_bg_activebg, List<Calendari> datas)
void PrintCalendarMutual(Canvas g, DateTime oldTime, DateTime oldTimeHover, Brush brush_bg_active, Brush brush_bg_activebg, List<Calendari> datas)
{
foreach (var it in datas)
{
@@ -1336,7 +1312,7 @@ namespace AntdUI
/// <param name="brush_bg_activebg">激活背景色</param>
/// <param name="brush_fore_active">激活字体色</param>
/// <param name="datas">DATA</param>
void PrintCalendar(ICanvas g, Brush brush_fore, Brush brush_fore_disable, Brush brush_bg_disable, Brush brush_bg_active, Brush brush_bg_activebg, Brush brush_fore_active, List<Calendari> datas)
void PrintCalendar(Canvas g, Brush brush_fore, Brush brush_fore_disable, Brush brush_bg_disable, Brush brush_bg_active, Brush brush_bg_activebg, Brush brush_fore_active, List<Calendari> datas)
{
foreach (var it in datas)
{
@@ -1448,10 +1424,7 @@ namespace AntdUI
{
using (var path = it.rect_read.RoundPath(Radius))
{
using (var pen_active = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(pen_active, path);
}
g.Draw(Style.Db.Primary, Config.Dpi, path);
}
}
}
@@ -1469,7 +1442,7 @@ namespace AntdUI
/// </summary>
/// <param name="g">GDI</param>
/// <param name="rect">客户区域</param>
void DrawShadow(ICanvas g, Rectangle rect)
void DrawShadow(Canvas g, Rectangle rect)
{
if (Config.ShadowEnabled)
{

View File

@@ -261,7 +261,7 @@ namespace AntdUI
/// </summary>
/// <param name="g">GDI</param>
/// <param name="rect">客户区域</param>
void DrawShadow(ICanvas g, Rectangle rect)
void DrawShadow(Canvas g, Rectangle rect)
{
if (Config.ShadowEnabled)
{

View File

@@ -476,7 +476,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintYear(ICanvas g, Rectangle rect_read, List<Calendari> datas)
void PrintYear(Canvas g, Rectangle rect_read, List<Calendari> datas)
{
using (var brush_fore_disable = new SolidBrush(Style.Db.TextQuaternary))
using (var brush_bg_disable = new SolidBrush(Style.Db.FillTertiary))
@@ -489,18 +489,9 @@ namespace AntdUI
if (hover_year.Animation)
{
g.String(year_str, font, brush_fore, rect_l, s_f);
using (var brush_hove = new SolidBrush(Helper.ToColor(hover_year.Value, Style.Db.Primary)))
{
g.String(year_str, font, brush_hove, rect_l, s_f);
}
}
else if (hover_year.Switch)
{
using (var brush_hove = new SolidBrush(Style.Db.Primary))
{
g.String(year_str, font, brush_hove, rect_l, s_f);
}
g.String(year_str, font, Helper.ToColor(hover_year.Value, Style.Db.Primary), rect_l, s_f);
}
else if (hover_year.Switch) g.String(year_str, font, Style.Db.Primary, rect_l, s_f);
else g.String(year_str, font, brush_fore, rect_l, s_f);
}
@@ -526,25 +517,13 @@ namespace AntdUI
else if (it.enable)
{
if (it.hover) g.Fill(Style.Db.FillTertiary, path);
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, it.t == 1 ? brush_fore : brush_fore_disable, it.rect, s_f);
}
else
{
g.Fill(brush_bg_disable, new Rectangle(it.rect.X, it.rect_read.Y, it.rect.Width, it.rect_read.Height));
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore_disable, it.rect, s_f);
}
}
@@ -562,7 +541,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintMonth(ICanvas g, Rectangle rect_read, List<Calendari> datas)
void PrintMonth(Canvas g, Rectangle rect_read, List<Calendari> datas)
{
using (var brush_fore_disable = new SolidBrush(Style.Db.TextQuaternary))
using (var brush_bg_disable = new SolidBrush(Style.Db.FillTertiary))
@@ -612,25 +591,13 @@ namespace AntdUI
else if (it.enable)
{
if (it.hover) g.Fill(Style.Db.FillTertiary, path);
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore, it.rect, s_f);
}
else
{
g.Fill(brush_bg_disable, new Rectangle(it.rect.X, it.rect_read.Y, it.rect.Width, it.rect_read.Height));
if (DateNow.ToString("yyyy-MM-dd") == it.date_str)
{
using (var brush_hove = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(brush_hove, path);
}
}
if (DateNow.ToString("yyyy-MM-dd") == it.date_str) g.Draw(Style.Db.Primary, Config.Dpi, path);
g.String(it.v, Font, brush_fore_disable, it.rect, s_f);
}
}
@@ -649,7 +616,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_read">真实区域</param>
/// <param name="datas">数据</param>
void PrintDay(ICanvas g, Rectangle rect_read, List<Calendari> datas)
void PrintDay(Canvas g, Rectangle rect_read, List<Calendari> datas)
{
using (var brush_fore = new SolidBrush(Style.Db.TextBase))
{
@@ -695,10 +662,10 @@ namespace AntdUI
using (var brush_split = new SolidBrush(Style.Db.Split))
{
g.Fill(brush_split, new RectangleF(t_x + rect_read.X, rect_read.Y + t_top, t_one_width, 1F));
g.Fill(brush_split, new RectangleF(t_x + rect_read.X, rect_button.Y, rect_read.Width - t_x, 1F));
g.Fill(brush_split, new RectangleF(t_x + rect_read.X + t_one_width, rect_read.Y, 1F, rect_read.Height));
if (left_buttons != null) g.Fill(brush_split, new RectangleF(t_x + rect_read.X, rect_read.Y, 1F, rect_read.Height));
g.Fill(brush_split, new RectangleF(t_x + rect_read.X, rect_read.Y + t_top, t_one_width, Config.Dpi));
g.Fill(brush_split, new RectangleF(t_x + rect_read.X, rect_button.Y, rect_read.Width - t_x, Config.Dpi));
g.Fill(brush_split, new RectangleF(t_x + rect_read.X + t_one_width, rect_read.Y, Config.Dpi, rect_read.Height));
if (left_buttons != null) g.Fill(brush_split, new RectangleF(t_x + rect_read.X, rect_read.Y, Config.Dpi, rect_read.Height));
}
int y = rect_read.Y + t_top + 12;
int size = (t_one_width - 16) / 7;
@@ -1078,10 +1045,7 @@ namespace AntdUI
{
using (var path = it.rect_read.RoundPath(Radius))
{
using (var pen_active = new Pen(Style.Db.Primary, Config.Dpi))
{
g.Draw(pen_active, path);
}
g.Draw(Style.Db.Primary, Config.Dpi, path);
}
}
}
@@ -1091,7 +1055,7 @@ namespace AntdUI
}
}
void PrintCalendarMutual(ICanvas g, DateTime STime, DateTime ETime, Brush brush_bg_active, Brush brush_bg_activebg, List<Calendari> datas)
void PrintCalendarMutual(Canvas g, DateTime STime, DateTime ETime, Brush brush_bg_active, Brush brush_bg_activebg, List<Calendari> datas)
{
foreach (var it in datas)
{
@@ -1131,7 +1095,7 @@ namespace AntdUI
/// </summary>
/// <param name="g">GDI</param>
/// <param name="rect">客户区域</param>
void DrawShadow(ICanvas g, Rectangle rect)
void DrawShadow(Canvas g, Rectangle rect)
{
if (Config.ShadowEnabled)
{

View File

@@ -673,7 +673,7 @@ namespace AntdUI
Rectangle rect_colors;
Bitmap? bmp_colors = null;
Dictionary<string, Color>? bmp_colors_mouse = null;
void PaintColors(ICanvas g, Rectangle rect)
void PaintColors(Canvas g, Rectangle rect)
{
using (var brush = new SolidBrush(ValueHue))
{
@@ -722,7 +722,7 @@ namespace AntdUI
Rectangle rect_hue_big;
Rectangle rect_hue;
Bitmap? bmp_hue = null;
void PaintHue(ICanvas g, Rectangle rect)
void PaintHue(Canvas g, Rectangle rect)
{
int width = (rect.Width - 4) / 6;
Rectangle rect1 = new Rectangle(2, 0, width, rect.Height), rect2 = new Rectangle(rect1.X + width, 0, width, rect.Height),
@@ -805,7 +805,7 @@ namespace AntdUI
Rectangle rect_alpha;
Bitmap? bmp_alpha = null, bmp_alpha_read = null;
Color color_alpha = Color.White;
void PaintAlpha(ICanvas g, Rectangle rect, bool add)
void PaintAlpha(Canvas g, Rectangle rect, bool add)
{
if (add)
{
@@ -859,7 +859,7 @@ namespace AntdUI
/// </summary>
/// <param name="g">GDI</param>
/// <param name="rect">客户区域</param>
void DrawShadow(ICanvas g, Rectangle rect)
void DrawShadow(Canvas g, Rectangle rect)
{
if (Config.ShadowEnabled)
{

View File

@@ -429,7 +429,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_client">客户区域</param>
/// <param name="rect_read">真实区域</param>
GraphicsPath DrawShadow(ICanvas g, Rectangle rect_client, Rectangle rect_read)
GraphicsPath DrawShadow(Canvas g, Rectangle rect_client, Rectangle rect_read)
{
var path = rect_read.RoundPath(radius);
if (Config.ShadowEnabled)

View File

@@ -646,7 +646,7 @@ namespace AntdUI
/// </summary>
/// <param name="g">GDI</param>
/// <param name="rect">客户区域</param>
Rectangle DrawShadow(ICanvas g, Rectangle rect)
Rectangle DrawShadow(Canvas g, Rectangle rect)
{
var matrix = new ColorMatrix { Matrix33 = 0.3F };
switch (config.Align)

View File

@@ -234,7 +234,7 @@ namespace AntdUI
readonly StringFormat stringBadge = Helper.SF_NoWrap();
void PrintBadge(ICanvas g, FloatButton.ConfigBtn it)
void PrintBadge(Canvas g, FloatButton.ConfigBtn it)
{
if (it.Badge != null)
{
@@ -245,14 +245,8 @@ namespace AntdUI
if (it.Badge == " ")
{
var rect_badge = new Rectangle(it.rect_read.Right - BadgeSize, it.rect_read.Y, BadgeSize, BadgeSize);
using (var brush = new SolidBrush(color))
{
g.FillEllipse(brush, rect_badge);
using (var pen = new Pen(brush_fore.Color, 1F))
{
g.DrawEllipse(pen, rect_badge);
}
}
g.FillEllipse(color, rect_badge);
g.DrawEllipse(color, Config.Dpi, rect_badge);
}
else
{
@@ -263,30 +257,18 @@ namespace AntdUI
if (size.Height > size.Width)
{
var rect_badge = new RectangleF(it.rect_read.Right + size_badge2 - size_badge, it.rect_read.Y - size_badge2, size_badge, size_badge);
using (var brush = new SolidBrush(color))
{
g.FillEllipse(brush, rect_badge);
using (var pen = new Pen(brush_fore.Color, 1F))
{
g.DrawEllipse(pen, rect_badge);
}
}
g.FillEllipse(color, rect_badge);
g.DrawEllipse(color, Config.Dpi, rect_badge);
g.String(it.Badge, font, brush_fore, rect_badge, stringBadge);
}
else
{
var w_badge = size.Width * 1.2F;
var rect_badge = new RectangleF(it.rect_read.Right + size_badge2 - w_badge, it.rect_read.Y - size_badge2, w_badge, size_badge);
using (var brush = new SolidBrush(color))
using (var path = rect_badge.RoundPath(rect_badge.Height))
{
using (var path = rect_badge.RoundPath(rect_badge.Height))
{
g.Fill(brush, path);
using (var pen = new Pen(brush_fore.Color, 1F))
{
g.Draw(pen, path);
}
}
g.Fill(color, path);
g.Draw(color, Config.Dpi, path);
}
g.String(it.Badge, font, brush_fore, rect_badge, stringBadge);
}
@@ -300,7 +282,7 @@ namespace AntdUI
/// 绘制阴影
/// </summary>
/// <param name="g">GDI</param>
GraphicsPath DrawShadow(ICanvas g, FloatButton.ConfigBtn it)
GraphicsPath DrawShadow(Canvas g, FloatButton.ConfigBtn it)
{
bool round = it.Round;
float radius = round ? it.rect_read.Height : it.Radius * Config.Dpi;

View File

@@ -352,7 +352,7 @@ namespace AntdUI
return original_bmp;
}
void DrawItem(ICanvas g, SolidBrush brush, OMenuItem it)
void DrawItem(Canvas g, SolidBrush brush, OMenuItem it)
{
if (it.Val.Enabled)
{
@@ -516,12 +516,12 @@ namespace AntdUI
}
if (it.has_sub) PaintArrow(g, it, brush.Color);
}
void PaintIcon(ICanvas g, OMenuItem it, Color fore)
void PaintIcon(Canvas g, OMenuItem it, Color fore)
{
if (it.Val.Icon != null) g.Image(it.Val.Icon, it.RectIcon);
else if (it.Val.IconSvg != null) g.GetImgExtend(it.Val.IconSvg, it.RectIcon, fore);
}
void PaintArrow(ICanvas g, OMenuItem item, Color color)
void PaintArrow(Canvas g, OMenuItem item, Color color)
{
int size = item.arr_rect.Width, size_arrow = size / 2;
g.TranslateTransform(item.arr_rect.X + size_arrow, item.arr_rect.Y + size_arrow);
@@ -540,7 +540,7 @@ namespace AntdUI
/// </summary>
/// <param name="g">GDI</param>
/// <param name="rect">客户区域</param>
void DrawShadow(ICanvas g, Rectangle rect)
void DrawShadow(Canvas g, Rectangle rect)
{
if (Config.ShadowEnabled)
{

View File

@@ -310,7 +310,7 @@ namespace AntdUI
/// <param name="g">GDI</param>
/// <param name="rect_client">客户区域</param>
/// <param name="rect_read">真实区域</param>
GraphicsPath DrawShadow(ICanvas g, Rectangle rect_client, RectangleF rect_read)
GraphicsPath DrawShadow(Canvas g, Rectangle rect_client, RectangleF rect_read)
{
var path = rect_read.RoundPath((int)(config.Radius * Config.Dpi));
if (Config.ShadowEnabled)

View File

@@ -341,66 +341,50 @@ namespace AntdUI
}
if (loading)
{
using (var pen = new Pen(Color.FromArgb(220, Style.Db.PrimaryColor), 6 * Config.Dpi))
using (var penpro = new Pen(Style.Db.Primary, pen.Width))
var bor6 = 6F * Config.Dpi;
int loading_size = (int)(40 * Config.Dpi);
var rect_loading = new Rectangle(rect_read.X + (rect_read.Width - loading_size) / 2, rect_read.Y + (rect_read.Height - loading_size) / 2, loading_size, loading_size);
g.DrawEllipse(Color.FromArgb(220, Style.Db.PrimaryColor), bor6, rect_loading);
if (_value > -1)
{
int loading_size = (int)(40 * Config.Dpi);
var rect_loading = new Rectangle(rect_read.X + (rect_read.Width - loading_size) / 2, rect_read.Y + (rect_read.Height - loading_size) / 2, loading_size, loading_size);
g.DrawEllipse(pen, rect_loading);
if (_value > -1)
using (var penpro = new Pen(Style.Db.Primary, bor6))
{
try
{
g.DrawArc(penpro, rect_loading, -90, 360F * _value);
}
catch { }
if (LoadingProgressStr != null)
{
rect_loading.Offset(0, loading_size);
using (var brush = new SolidBrush(Style.Db.PrimaryColor))
{
g.String(LoadingProgressStr, Font, brush, rect_loading, s_f);
}
}
g.DrawArc(penpro, rect_loading, -90, 360F * _value);
}
if (LoadingProgressStr != null)
{
rect_loading.Offset(0, loading_size);
g.String(LoadingProgressStr, Font, Style.Db.PrimaryColor, rect_loading, s_f);
}
}
}
else if (LoadingProgressStr != null)
{
using (var pen = new Pen(Style.Db.Error, 6 * Config.Dpi))
else if (LoadingProgressStr != null)
{
int loading_size = (int)(40 * Config.Dpi);
var rect_loading = new Rectangle(rect_read.X + (rect_read.Width - loading_size) / 2, rect_read.Y + (rect_read.Height - loading_size) / 2, loading_size, loading_size);
g.DrawEllipse(pen, rect_loading);
g.DrawEllipse(Style.Db.Error, bor6, rect_loading);
rect_loading.Offset(0, loading_size);
using (var brush = new SolidBrush(Style.Db.ErrorColor))
g.String(LoadingProgressStr, Font, Style.Db.ErrorColor, rect_loading, s_f);
}
using (var path = rect_panel.RoundPath(rect_panel.Height))
{
using (var brush = new SolidBrush(Color.FromArgb(26, 0, 0, 0)))
{
g.String(LoadingProgressStr, Font, brush, rect_loading, s_f);
g.Fill(brush, path);
PaintBtn(g, brush, rect_close, rect_close_icon, SvgDb.IcoClose, hoverClose, true);
if (PageSize > 1)
{
PaintBtn(g, brush, rect_left, rect_left_icon, SvgDb.IcoLeft, hoverLeft, enabledLeft);
PaintBtn(g, brush, rect_right, rect_right_icon, SvgDb.IcoRight, hoverRight, enabledRight);
}
}
}
}
using (var path = rect_panel.RoundPath(rect_panel.Height))
{
using (var brush = new SolidBrush(Color.FromArgb(26, 0, 0, 0)))
foreach (var it in btns)
{
g.Fill(brush, path);
PaintBtn(g, brush, rect_close, rect_close_icon, SvgDb.IcoClose, hoverClose, true);
if (PageSize > 1)
using (var bmp = SvgExtend.GetImgExtend(it.svg, it.rect, it.hover ? colorHover : colorDefault))
{
PaintBtn(g, brush, rect_left, rect_left_icon, SvgDb.IcoLeft, hoverLeft, enabledLeft);
PaintBtn(g, brush, rect_right, rect_right_icon, SvgDb.IcoRight, hoverRight, enabledRight);
}
}
}
foreach (var it in btns)
{
using (var bmp = SvgExtend.GetImgExtend(it.svg, it.rect, it.hover ? colorHover : colorDefault))
{
if (bmp != null)
{
if (it.enabled) g.Image(bmp, it.rect);
else g.Image(bmp, it.rect, 0.3F);
if (bmp != null)
{
if (it.enabled) g.Image(bmp, it.rect);
else g.Image(bmp, it.rect, 0.3F);
}
}
}
}
@@ -408,7 +392,7 @@ namespace AntdUI
return original_bmp;
}
void PaintBtn(ICanvas g, SolidBrush brush, Rectangle rect, Rectangle rect_ico, string svg, bool hover, bool enabled)
void PaintBtn(Canvas g, SolidBrush brush, Rectangle rect, Rectangle rect_ico, string svg, bool hover, bool enabled)
{
using (var bmp = SvgExtend.GetImgExtend(svg, rect_ico, Color.White))
{

View File

@@ -149,7 +149,7 @@ namespace AntdUI
Helper.GDI(g =>
{
var size = g.MeasureString(Config.NullText, Font);
int sp = (int)(1 * Config.Dpi), gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
int sp = (int)Config.Dpi, gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
gap2 = gap * 2, gap_x2 = gap_x * 2, gap_y2 = gap_y * 2,
text_height = size.Height, item_height = text_height + gap_y2;
y += gap;
@@ -353,7 +353,7 @@ namespace AntdUI
}
}
void InitReadList(ICanvas g, object obj, ref int btext, ref bool ui_online, ref bool ui_icon, ref bool ui_arrow)
void InitReadList(Canvas g, object obj, ref int btext, ref bool ui_online, ref bool ui_icon, ref bool ui_arrow)
{
if (obj is SelectItem it)
{
@@ -460,7 +460,7 @@ namespace AntdUI
Helper.GDI(g =>
{
var size = g.MeasureString(Config.NullText, Font);
int sp = (int)(1 * Config.Dpi), gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
int sp = (int)Config.Dpi, gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
gap2 = gap * 2, gap_x2 = gap_x * 2, gap_y2 = gap_y * 2,
text_height = size.Height, item_height = text_height + gap_y2;
y += gap;
@@ -571,7 +571,7 @@ namespace AntdUI
Helper.GDI(g =>
{
var size = g.MeasureString(Config.NullText, Font);
int sp = (int)(1 * Config.Dpi), gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
int sp = (int)Config.Dpi, gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
gap2 = gap * 2, gap_x2 = gap_x * 2, gap_y2 = gap_y * 2,
text_height = size.Height, item_height = text_height + gap_y2;
y += gap;
@@ -651,7 +651,7 @@ namespace AntdUI
Helper.GDI(g =>
{
var size = g.MeasureString(Config.NullText, Font);
int sp = (int)(1 * Config.Dpi), gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
int sp = (int)Config.Dpi, gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
gap2 = gap * 2, gap_x2 = gap_x * 2, gap_y2 = gap_y * 2,
text_height = size.Height, item_height = text_height + gap_y2;
y += gap;
@@ -863,7 +863,7 @@ namespace AntdUI
return original_bmp;
}
void DrawItem(ICanvas g, SolidBrush brush, SolidBrush subbrush, SolidBrush brush_back_hover, SolidBrush brush_fore, SolidBrush brush_split, ObjectItem it)
void DrawItem(Canvas g, SolidBrush brush, SolidBrush subbrush, SolidBrush brush_back_hover, SolidBrush brush_fore, SolidBrush brush_split, ObjectItem it)
{
if (it.ID == -1) g.Fill(brush_split, it.Rect);
else if (it.Group) g.String(it.Text, Font, brush_fore, it.RectText, stringFormatLeft);
@@ -909,7 +909,7 @@ namespace AntdUI
if (it.has_sub) DrawArrow(g, it, Style.Db.TextBase);
}
void DrawTextIconSelect(ICanvas g, ObjectItem it)
void DrawTextIconSelect(Canvas g, ObjectItem it)
{
using (var font = new Font(Font, FontStyle.Bold))
{
@@ -930,7 +930,7 @@ namespace AntdUI
}
DrawIcon(g, it, Style.Db.TextBase);
}
void DrawTextIcon(ICanvas g, ObjectItem it, SolidBrush brush)
void DrawTextIcon(Canvas g, ObjectItem it, SolidBrush brush)
{
if (it.Enable) g.String(it.Text, Font, brush, it.RectText, stringFormatLeft);
else
@@ -942,7 +942,7 @@ namespace AntdUI
}
DrawIcon(g, it, brush.Color);
}
void DrawIcon(ICanvas g, ObjectItem it, Color color)
void DrawIcon(Canvas g, ObjectItem it, Color color)
{
if (it.IconSvg != null)
{
@@ -962,7 +962,7 @@ namespace AntdUI
else g.Image(it.Icon, it.RectIcon, 0.25F);
}
}
void DrawArrow(ICanvas g, ObjectItem item, Color color)
void DrawArrow(Canvas g, ObjectItem item, Color color)
{
int size = item.RectArrow.Width, size_arrow = size / 2;
g.TranslateTransform(item.RectArrow.X + size_arrow, item.RectArrow.Y + size_arrow);
@@ -982,7 +982,7 @@ namespace AntdUI
/// </summary>
/// <param name="g">GDI</param>
/// <param name="rect">客户区域</param>
void DrawShadow(ICanvas g, Rectangle rect)
void DrawShadow(Canvas g, Rectangle rect)
{
if (Config.ShadowEnabled)
{

View File

@@ -56,7 +56,7 @@ namespace AntdUI
Helper.GDI(g =>
{
var size = g.MeasureString(Config.NullText, Font);
int sp = (int)(1 * Config.Dpi), gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
int sp = (int)Config.Dpi, gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
gap2 = gap * 2, gap_x2 = gap_x * 2, gap_y2 = gap_y * 2,
text_height = size.Height, item_height = text_height + gap_y2;
y += gap;
@@ -203,7 +203,7 @@ namespace AntdUI
}
}
void InitReadList(ICanvas g, object obj, ref int btext, ref bool ui_online, ref bool ui_icon, ref bool ui_arrow)
void InitReadList(Canvas g, object obj, ref int btext, ref bool ui_online, ref bool ui_icon, ref bool ui_arrow)
{
if (obj is SelectItem it)
{
@@ -311,7 +311,7 @@ namespace AntdUI
Helper.GDI(g =>
{
var size = g.MeasureString(Config.NullText, Font);
int sp = (int)(1 * Config.Dpi), gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
int sp = (int)Config.Dpi, gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
gap2 = gap * 2, gap_x2 = gap_x * 2, gap_y2 = gap_y * 2,
text_height = size.Height, item_height = text_height + gap_y2;
y += gap;
@@ -391,7 +391,7 @@ namespace AntdUI
Helper.GDI(g =>
{
var size = g.MeasureString(Config.NullText, Font);
int sp = (int)(1 * Config.Dpi), gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
int sp = (int)Config.Dpi, gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
gap2 = gap * 2, gap_x2 = gap_x * 2, gap_y2 = gap_y * 2,
text_height = size.Height, item_height = text_height + gap_y2;
y += gap;
@@ -643,7 +643,7 @@ namespace AntdUI
return false;
}
void DrawItemSelect(ICanvas g, SolidBrush brush, SolidBrush subbrush, SolidBrush brush_split, ObjectItem it, bool TL, bool TR, bool BR, bool BL)
void DrawItemSelect(Canvas g, SolidBrush brush, SolidBrush subbrush, SolidBrush brush_split, ObjectItem it, bool TL, bool TR, bool BR, bool BL)
{
if (it.ID == -1) g.Fill(brush_split, it.Rect);
else
@@ -670,7 +670,7 @@ namespace AntdUI
}
}
void DrawItem(ICanvas g, SolidBrush brush, SolidBrush subbrush, SolidBrush brush_back_hover, SolidBrush brush_fore, SolidBrush brush_split, ObjectItem it)
void DrawItem(Canvas g, SolidBrush brush, SolidBrush subbrush, SolidBrush brush_back_hover, SolidBrush brush_fore, SolidBrush brush_split, ObjectItem it)
{
if (it.ID == -1) g.Fill(brush_split, it.Rect);
else if (it.Group) g.String(it.Text, Font, brush_fore, it.RectText, stringFormatLeft);
@@ -703,7 +703,7 @@ namespace AntdUI
}
}
}
void DrawItemR(ICanvas g, SolidBrush brush, SolidBrush brush_back_hover, SolidBrush brush_split, ObjectItem it)
void DrawItemR(Canvas g, SolidBrush brush, SolidBrush brush_back_hover, SolidBrush brush_split, ObjectItem it)
{
if (it.ID == -1) g.Fill(brush_split, it.Rect);
else if (selectedValue.Contains(it.Val) || it.Val is SelectItem item && selectedValue.Contains(item.Tag))
@@ -729,7 +729,7 @@ namespace AntdUI
}
}
void DrawTextIconSelect(ICanvas g, ObjectItem it)
void DrawTextIconSelect(Canvas g, ObjectItem it)
{
if (it.Enable)
{
@@ -747,7 +747,7 @@ namespace AntdUI
}
DrawIcon(g, it, Style.Db.TextBase);
}
void DrawTextIcon(ICanvas g, ObjectItem it, SolidBrush brush)
void DrawTextIcon(Canvas g, ObjectItem it, SolidBrush brush)
{
if (it.Enable) g.String(it.Text, Font, brush, it.RectText, stringFormatLeft);
else
@@ -759,7 +759,7 @@ namespace AntdUI
}
DrawIcon(g, it, brush.Color);
}
void DrawIcon(ICanvas g, ObjectItem it, Color color)
void DrawIcon(Canvas g, ObjectItem it, Color color)
{
if (it.IconSvg != null)
{
@@ -786,7 +786,7 @@ namespace AntdUI
/// </summary>
/// <param name="g">GDI</param>
/// <param name="rect">客户区域</param>
void DrawShadow(ICanvas g, Rectangle rect)
void DrawShadow(Canvas g, Rectangle rect)
{
if (Config.ShadowEnabled)
{

View File

@@ -96,7 +96,7 @@ namespace AntdUI
Helper.GDI(g =>
{
var size = g.MeasureString(Config.NullText, Font);
int sp = (int)(1 * Config.Dpi), gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
int sp = (int)Config.Dpi, gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
gap2 = gap * 2, gap_x2 = gap_x * 2, gap_y2 = gap_y * 2,
text_height = size.Height, item_height = text_height + gap_y2;
y += gap;
@@ -274,7 +274,7 @@ namespace AntdUI
}
}
void InitReadList(ICanvas g, object obj, ref int btext, ref bool ui_online, ref bool ui_icon, ref bool ui_arrow)
void InitReadList(Canvas g, object obj, ref int btext, ref bool ui_online, ref bool ui_icon, ref bool ui_arrow)
{
if (obj is SelectItem it)
{
@@ -382,7 +382,7 @@ namespace AntdUI
Helper.GDI(g =>
{
var size = g.MeasureString(Config.NullText, Font);
int sp = (int)(1 * Config.Dpi), gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
int sp = (int)Config.Dpi, gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
gap2 = gap * 2, gap_x2 = gap_x * 2, gap_y2 = gap_y * 2,
text_height = size.Height, item_height = text_height + gap_y2;
y += gap;
@@ -462,7 +462,7 @@ namespace AntdUI
Helper.GDI(g =>
{
var size = g.MeasureString(Config.NullText, Font);
int sp = (int)(1 * Config.Dpi), gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
int sp = (int)Config.Dpi, gap = (int)(4 * Config.Dpi), gap_y = (int)(DPadding.Height * Config.Dpi), gap_x = (int)(DPadding.Width * Config.Dpi),
gap2 = gap * 2, gap_x2 = gap_x * 2, gap_y2 = gap_y * 2,
text_height = size.Height, item_height = text_height + gap_y2;
y += gap;
@@ -784,7 +784,7 @@ namespace AntdUI
return false;
}
void DrawItemSelect(ICanvas g, SolidBrush brush, SolidBrush subbrush, SolidBrush brush_split, ObjectItemCheck it, bool TL, bool TR, bool BR, bool BL)
void DrawItemSelect(Canvas g, SolidBrush brush, SolidBrush subbrush, SolidBrush brush_split, ObjectItemCheck it, bool TL, bool TR, bool BR, bool BL)
{
if (it.ID == -1) g.Fill(brush_split, it.Rect);
else
@@ -811,7 +811,7 @@ namespace AntdUI
}
}
void DrawItem(ICanvas g, SolidBrush brush, SolidBrush subbrush, SolidBrush brush_back_hover, SolidBrush brush_fore, SolidBrush brush_split, ObjectItemCheck it)
void DrawItem(Canvas g, SolidBrush brush, SolidBrush subbrush, SolidBrush brush_back_hover, SolidBrush brush_fore, SolidBrush brush_split, ObjectItemCheck it)
{
if (it.ID == -1) g.Fill(brush_split, it.Rect);
else if (it.Group) g.String(it.Text, Font, brush_fore, it.RectText, stringFormatLeft);
@@ -845,7 +845,7 @@ namespace AntdUI
if (it.has_sub) DrawArrow(g, it, Style.Db.TextBase);
}
}
void DrawItemR(ICanvas g, SolidBrush brush, SolidBrush brush_back_hover, SolidBrush brush_split, ObjectItemCheck it)
void DrawItemR(Canvas g, SolidBrush brush, SolidBrush brush_back_hover, SolidBrush brush_split, ObjectItemCheck it)
{
if (it.ID == -1) g.Fill(brush_split, it.Rect);
else if (selectedValue.Contains(it.Val) || it.Val is SelectItem item && selectedValue.Contains(item.Tag))
@@ -871,7 +871,7 @@ namespace AntdUI
if (it.has_sub) DrawArrow(g, it, Style.Db.TextBase);
}
void DrawTextIconSelect(ICanvas g, ObjectItemCheck it)
void DrawTextIconSelect(Canvas g, ObjectItemCheck it)
{
if (it.Enable)
{
@@ -898,7 +898,7 @@ namespace AntdUI
}
}
}
void DrawTextIcon(ICanvas g, ObjectItemCheck it, SolidBrush brush)
void DrawTextIcon(Canvas g, ObjectItemCheck it, SolidBrush brush)
{
if (it.Enable) g.String(it.Text, Font, brush, it.RectText, stringFormatLeft);
else
@@ -912,13 +912,10 @@ namespace AntdUI
using (var path = it.RectCheck.RoundPath(Radius / 2))
{
using (var brushb = new Pen(Style.Db.BorderColor, 2F))
{
g.Draw(brushb, path);
}
g.Draw(Style.Db.BorderColor, 2F * Config.Dpi, path);
}
}
void DrawIcon(ICanvas g, ObjectItemCheck it, Color color)
void DrawIcon(Canvas g, ObjectItemCheck it, Color color)
{
if (it.IconSvg != null)
{
@@ -938,7 +935,7 @@ namespace AntdUI
else g.Image(it.Icon, it.RectIcon, 0.25F);
}
}
void DrawArrow(ICanvas g, ObjectItemCheck item, Color color)
void DrawArrow(Canvas g, ObjectItemCheck item, Color color)
{
int size = item.RectArrow.Width, size_arrow = size / 2;
g.TranslateTransform(item.RectArrow.X + size_arrow, item.RectArrow.Y + size_arrow);
@@ -958,7 +955,7 @@ namespace AntdUI
/// </summary>
/// <param name="g">GDI</param>
/// <param name="rect">客户区域</param>
void DrawShadow(ICanvas g, Rectangle rect)
void DrawShadow(Canvas g, Rectangle rect)
{
if (Config.ShadowEnabled)
{

View File

@@ -100,26 +100,26 @@ namespace AntdUI
return new SolidBrush(def);
}
public static ICanvas High(this Graphics g)
public static Canvas High(this Graphics g)
{
Config.SetDpi(g);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
if (Config.TextRenderingHint.HasValue) g.TextRenderingHint = Config.TextRenderingHint.Value;
return new Core.Canvas(g);
return new Core.CanvasGDI(g);
}
public static ICanvas HighLay(this Graphics g)
public static Canvas HighLay(this Graphics g)
{
Config.SetDpi(g);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
return new Core.Canvas(g);
return new Core.CanvasGDI(g);
}
public static void GDI(Action<ICanvas> action)
public static void GDI(Action<Canvas> action)
{
using (var bmp = new Bitmap(1, 1))
{
@@ -131,7 +131,7 @@ namespace AntdUI
}
}
public static T GDI<T>(Func<ICanvas, T> action)
public static T GDI<T>(Func<Canvas, T> action)
{
using (var bmp = new Bitmap(1, 1))
{
@@ -363,7 +363,7 @@ namespace AntdUI
#region
internal static void PaintIcons(this ICanvas g, TType icon, Rectangle rect)
internal static void PaintIcons(this Canvas g, TType icon, Rectangle rect)
{
switch (icon)
{
@@ -397,7 +397,7 @@ namespace AntdUI
break;
}
}
internal static void PaintIcons(this ICanvas g, TType icon, Rectangle rect, Color back)
internal static void PaintIcons(this Canvas g, TType icon, Rectangle rect, Color back)
{
using (var brush = new SolidBrush(back))
{
@@ -435,7 +435,7 @@ namespace AntdUI
break;
}
}
internal static void PaintIconGhosts(this ICanvas g, TType icon, Rectangle rect, Color color)
internal static void PaintIconGhosts(this Canvas g, TType icon, Rectangle rect, Color color)
{
switch (icon)
{
@@ -469,11 +469,11 @@ namespace AntdUI
break;
}
}
internal static void PaintIconClose(this ICanvas g, Rectangle rect, Color color)
internal static void PaintIconClose(this Canvas g, Rectangle rect, Color color)
{
PaintIconCore(g, rect, SvgDb.IcoErrorGhost, color);
}
internal static void PaintIconClose(this ICanvas g, Rectangle rect, Color color, float dot)
internal static void PaintIconClose(this Canvas g, Rectangle rect, Color color, float dot)
{
PaintIconCore(g, rect, SvgDb.IcoErrorGhost, color, dot);
}
@@ -481,7 +481,7 @@ namespace AntdUI
/// <summary>
/// 绘制带圆背景的镂空图标
/// </summary>
internal static void PaintIconCoreGhost(this ICanvas g, Rectangle rect, string svg, Color back, Color fore)
internal static void PaintIconCoreGhost(this Canvas g, Rectangle rect, string svg, Color back, Color fore)
{
using (var brush = new SolidBrush(back))
{
@@ -489,7 +489,7 @@ namespace AntdUI
}
g.GetImgExtend(svg, rect, fore);
}
internal static void PaintIconCore(this ICanvas g, Rectangle rect, string svg, Color back, Color fore)
internal static void PaintIconCore(this Canvas g, Rectangle rect, string svg, Color back, Color fore)
{
using (var brush = new SolidBrush(back))
{
@@ -497,8 +497,8 @@ namespace AntdUI
}
g.GetImgExtend(svg, rect, fore);
}
internal static void PaintIconCore(this ICanvas g, Rectangle rect, string svg, Color color) => g.GetImgExtend(svg, rect, color);
internal static void PaintIconCore(this ICanvas g, Rectangle rect, string svg, Color color, float dot)
internal static void PaintIconCore(this Canvas g, Rectangle rect, string svg, Color color) => g.GetImgExtend(svg, rect, color);
internal static void PaintIconCore(this Canvas g, Rectangle rect, string svg, Color color, float dot)
{
int size = (int)(rect.Height * dot);
var rect_ico = new Rectangle(rect.X + (rect.Width - size) / 2, rect.Y + (rect.Height - size) / 2, size, size);
@@ -511,7 +511,7 @@ namespace AntdUI
#region
public static void PaintBadge(this IControl control, ICanvas g)
public static void PaintBadge(this IControl control, Canvas g)
{
if (control.BadgeSvg != null)
{
@@ -527,74 +527,56 @@ namespace AntdUI
{
var color = control.BadgeBack ?? Style.Db.Error;
var rect = control.ClientRectangle;
using (var brush_fore = new SolidBrush(Style.Db.ErrorColor))
float borsize = Config.Dpi;
using (var font = new Font(control.Font.FontFamily, control.Font.Size * control.BadgeSize))
{
float borsize = 1F * Config.Dpi;
using (var font = new Font(control.Font.FontFamily, control.Font.Size * control.BadgeSize))
int hasx = (int)(control.BadgeOffsetX * Config.Dpi), hasy = (int)(control.BadgeOffsetY * Config.Dpi);
if (string.IsNullOrWhiteSpace(control.Badge))
{
int hasx = (int)(control.BadgeOffsetX * Config.Dpi), hasy = (int)(control.BadgeOffsetY * Config.Dpi);
if (string.IsNullOrWhiteSpace(control.Badge))
var size = g.MeasureString(Config.NullText, font).Height;
var rect_badge = PaintBadge(rect, control.BadgeAlign, hasx, hasy, size, size);
using (var brush = new SolidBrush(color))
{
var size = g.MeasureString(Config.NullText, font).Height;
var rect_badge = PaintBadge(rect, control.BadgeAlign, hasx, hasy, size, size);
using (var brush = new SolidBrush(color))
if (control.BadgeMode)
{
if (control.BadgeMode)
float b2 = borsize * 2, rr = size * 0.2F, rr2 = rr * 2;
g.FillEllipse(Style.Db.ErrorColor, new RectangleF(rect_badge.X - borsize, rect_badge.Y - borsize, rect_badge.Width + b2, rect_badge.Height + b2));
using (var path = rect_badge.RoundPath(1, true))
{
float b2 = borsize * 2, rr = size * 0.2F, rr2 = rr * 2;
g.FillEllipse(brush_fore, new RectangleF(rect_badge.X - borsize, rect_badge.Y - borsize, rect_badge.Width + b2, rect_badge.Height + b2));
using (var path = rect_badge.RoundPath(1, true))
{
path.AddEllipse(new RectangleF(rect_badge.X + rr, rect_badge.Y + rr, rect_badge.Width - rr2, rect_badge.Height - rr2));
g.Fill(brush, path);
}
}
else
{
g.FillEllipse(brush, rect_badge);
using (var pen = new Pen(brush_fore.Color, borsize))
{
g.DrawEllipse(pen, rect_badge);
}
path.AddEllipse(new RectangleF(rect_badge.X + rr, rect_badge.Y + rr, rect_badge.Width - rr2, rect_badge.Height - rr2));
g.Fill(brush, path);
}
}
}
else
{
var size = g.MeasureString(control.Badge, font);
using (var s_f = SF_NoWrap())
else
{
int size_badge = (int)(size.Height * 1.2F);
if (size.Height > size.Width)
g.FillEllipse(Style.Db.ErrorColor, rect_badge);
g.DrawEllipse(Style.Db.ErrorColor, borsize, rect_badge);
}
}
}
else
{
var size = g.MeasureString(control.Badge, font);
using (var s_f = SF_NoWrap())
{
int size_badge = (int)(size.Height * 1.2F);
if (size.Height > size.Width)
{
var rect_badge = PaintBadge(rect, control.BadgeAlign, hasx, hasy, size_badge, size_badge);
g.FillEllipse(color, rect_badge);
g.DrawEllipse(Style.Db.ErrorColor, borsize, rect_badge);
g.String(control.Badge, font, Style.Db.ErrorColor, rect_badge, s_f);
}
else
{
int w_badge = size.Width + (size_badge - size.Height);
var rect_badge = PaintBadge(rect, control.BadgeAlign, hasx, hasy, w_badge, size_badge);
using (var path = rect_badge.RoundPath(rect_badge.Height))
{
var rect_badge = PaintBadge(rect, control.BadgeAlign, hasx, hasy, size_badge, size_badge);
using (var brush = new SolidBrush(color))
{
g.FillEllipse(brush, rect_badge);
}
using (var pen = new Pen(brush_fore.Color, borsize))
{
g.DrawEllipse(pen, rect_badge);
}
g.String(control.Badge, font, brush_fore, rect_badge, s_f);
}
else
{
int w_badge = size.Width + (size_badge - size.Height);
var rect_badge = PaintBadge(rect, control.BadgeAlign, hasx, hasy, w_badge, size_badge);
using (var brush = new SolidBrush(color))
{
using (var path = rect_badge.RoundPath(rect_badge.Height))
{
g.Fill(brush, path);
using (var pen = new Pen(brush_fore.Color, borsize))
{
g.Draw(pen, path);
}
}
}
g.String(control.Badge, font, brush_fore, rect_badge, s_f);
g.Fill(color, path);
g.Draw(color, borsize, path);
}
g.String(control.Badge, font, Style.Db.ErrorColor, rect_badge, s_f);
}
}
}
@@ -621,63 +603,45 @@ namespace AntdUI
return new Rectangle(rect.Right - x - w, rect.Y + y, w, h);
}
}
public static void PaintBadge(this IControl control, DateBadge badge, Font font, RectangleF rect, ICanvas g)
public static void PaintBadge(this IControl control, DateBadge badge, Font font, RectangleF rect, Canvas g)
{
var color = badge.Fill ?? control.BadgeBack ?? Style.Db.Error;
using (var brush_fore = new SolidBrush(Style.Db.ErrorColor))
float borsize = Config.Dpi;
if (badge.Count == 0)
{
float borsize = 1F * Config.Dpi;
if (badge.Count == 0)
var rect_badge = new RectangleF(rect.Right - 10F, rect.Top + 2F, 8, 8);
g.FillEllipse(color, rect_badge);
g.DrawEllipse(color, borsize, rect_badge);
}
else
{
using (var s_f = SF_NoWrap())
{
var rect_badge = new RectangleF(rect.Right - 10F, rect.Top + 2F, 8, 8);
using (var brush = new SolidBrush(color))
{
g.FillEllipse(brush, rect_badge);
using (var pen = new Pen(brush_fore.Color, borsize))
{
g.DrawEllipse(pen, rect_badge);
}
}
}
else
{
using (var s_f = SF_NoWrap())
{
string countStr;
if (badge.Count == 999) countStr = "999";
else if (badge.Count > 1000) countStr = (badge.Count / 1000).ToString().Substring(0, 1) + "K+";
else if (badge.Count > 99) countStr = "99+";
else countStr = badge.Count.ToString();
string countStr;
if (badge.Count == 999) countStr = "999";
else if (badge.Count > 1000) countStr = (badge.Count / 1000).ToString().Substring(0, 1) + "K+";
else if (badge.Count > 99) countStr = "99+";
else countStr = badge.Count.ToString();
var size = g.MeasureString(countStr, font);
int size_badge = (int)(size.Height * 1.2F);
if (size.Height > size.Width)
var size = g.MeasureString(countStr, font);
int size_badge = (int)(size.Height * 1.2F);
if (size.Height > size.Width)
{
var rect_badge = new RectangleF(rect.Right - size_badge + 6F, rect.Top - 8F, size_badge, size_badge);
g.FillEllipse(color, rect_badge);
g.DrawEllipse(color, borsize, rect_badge);
g.String(countStr, font, Style.Db.ErrorColor, rect_badge, s_f);
}
else
{
int w_badge = size.Width + (size_badge - size.Height);
var rect_badge = new RectangleF(rect.Right - w_badge + 6F, rect.Top - 8F, w_badge, size_badge);
using (var path = rect_badge.RoundPath(rect_badge.Height))
{
var rect_badge = new RectangleF(rect.Right - size_badge + 6F, rect.Top - 8F, size_badge, size_badge);
using (var brush = new SolidBrush(color))
{
g.FillEllipse(brush, rect_badge);
using (var pen = new Pen(brush_fore.Color, borsize))
{
g.DrawEllipse(pen, rect_badge);
}
}
g.String(countStr, font, brush_fore, rect_badge, s_f);
}
else
{
int w_badge = size.Width + (size_badge - size.Height);
var rect_badge = new RectangleF(rect.Right - w_badge + 6F, rect.Top - 8F, w_badge, size_badge);
using (var brush = new SolidBrush(color))
{
using (var path = rect_badge.RoundPath(rect_badge.Height))
{
g.Fill(brush, path);
g.Draw(brush_fore.Color, borsize, path);
}
}
g.String(countStr, font, brush_fore, rect_badge, s_f);
g.Fill(color, path);
g.Draw(color, borsize, path);
}
g.String(countStr, font, Style.Db.ErrorColor, rect_badge, s_f);
}
}
}
@@ -685,7 +649,7 @@ namespace AntdUI
#endregion
public static void PaintShadow(this ICanvas g, ShadowConfig config, Rectangle _rect, Rectangle rect, float radius, bool round)
public static void PaintShadow(this Canvas g, ShadowConfig config, Rectangle _rect, Rectangle rect, float radius, bool round)
{
int shadow = (int)(config.Shadow * Config.Dpi), shadowOffsetX = (int)(config.ShadowOffsetX * Config.Dpi), shadowOffsetY = (int)(config.ShadowOffsetY * Config.Dpi);
using (var bmp_shadow = new Bitmap(_rect.Width, _rect.Height))

View File

@@ -27,7 +27,7 @@ namespace AntdUI
if (rect.Width > 0 && rect.Height > 0) return SvgToBmp(svg, rect.Width, rect.Height, color);
return null;
}
public static bool GetImgExtend(this ICanvas g, string svg, Rectangle rect, Color? color = null)
public static bool GetImgExtend(this Canvas g, string svg, Rectangle rect, Color? color = null)
{
if (rect.Width > 0 && rect.Height > 0)
{