* ISymbol:增加SymbolOffset接口

This commit is contained in:
Sunny 2021-07-15 13:54:31 +08:00
parent 88f803845e
commit a9ed0ed86d
23 changed files with 188 additions and 91 deletions

4
.editorconfig Normal file
View File

@ -0,0 +1,4 @@
[*.cs]
# IDE0090: 使用 "new(...)"
dotnet_diagnostic.IDE0090.severity = none

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -480,6 +480,9 @@
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<None Include="..\.editorconfig">
<Link>.editorconfig</Link>
</None>
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@ -34,7 +34,7 @@ namespace Sunny.UI
[DefaultEvent("Click")] [DefaultEvent("Click")]
[DefaultProperty("Symbol")] [DefaultProperty("Symbol")]
[ToolboxItem(true)] [ToolboxItem(true)]
public sealed class UIAvatar : UIControl public sealed class UIAvatar : UIControl, ISymbol
{ {
/// <summary> /// <summary>
/// 头像图标类型 /// 头像图标类型
@ -218,6 +218,48 @@ namespace Sunny.UI
} }
} }
private Point symbolOffset = new Point(0, 0);
[DefaultValue(typeof(Point), "0, 0")]
[Description("字体图标的偏移位置"), Category("SunnyUI")]
public Point SymbolOffset
{
get => symbolOffset;
set
{
symbolOffset = value;
Invalidate();
}
}
private Point textOffset = new Point(0, 0);
[DefaultValue(typeof(Point), "0, 0")]
[Description("文字的偏移位置"), Category("SunnyUI")]
public Point TextOffset
{
get => textOffset;
set
{
textOffset = value;
Invalidate();
}
}
private Point imageOffset = new Point(0, 0);
[DefaultValue(typeof(Point), "0, 0")]
[Description("文字的偏移位置"), Category("SunnyUI")]
public Point ImageOffset
{
get => imageOffset;
set
{
imageOffset = value;
Invalidate();
}
}
/// <summary> /// <summary>
/// OnPaintFill /// OnPaintFill
/// </summary> /// </summary>
@ -225,7 +267,6 @@ namespace Sunny.UI
/// <param name="path">path</param> /// <param name="path">path</param>
protected override void OnPaintFill(Graphics g, GraphicsPath path) protected override void OnPaintFill(Graphics g, GraphicsPath path)
{ {
int size = Math.Min(Width, Height) - 3;
Rectangle rect = new Rectangle((Width - avatarSize) / 2, (Height - avatarSize) / 2, avatarSize, avatarSize); Rectangle rect = new Rectangle((Width - avatarSize) / 2, (Height - avatarSize) / 2, avatarSize, avatarSize);
switch (Shape) switch (Shape)
@ -240,10 +281,10 @@ namespace Sunny.UI
} }
} }
[DefaultValue(0), Description("水平偏移"), Category("SunnyUI")] [Browsable(false), DefaultValue(0), Description("水平偏移"), Category("SunnyUI")]
public int OffsetX { get; set; } = 0; public int OffsetX { get; set; } = 0;
[DefaultValue(0), Description("垂直偏移"), Category("SunnyUI")] [Browsable(false), DefaultValue(0), Description("垂直偏移"), Category("SunnyUI")]
public int OffsetY { get; set; } = 0; public int OffsetY { get; set; } = 0;
public event PaintEventHandler PaintAgain; public event PaintEventHandler PaintAgain;
@ -276,7 +317,7 @@ namespace Sunny.UI
(int)(Image.Height * 1.0 / Math.Min(sc1, sc2) + 0.5)); (int)(Image.Height * 1.0 / Math.Min(sc1, sc2) + 0.5));
Bitmap bmp = scaleImage.Split(size, Shape); Bitmap bmp = scaleImage.Split(size, Shape);
e.Graphics.DrawImage(bmp, (Width - avatarSize) / 2 + 1 + OffsetX, (Height - avatarSize) / 2 + 1 + OffsetY); e.Graphics.DrawImage(bmp, (Width - avatarSize) / 2 + 1 + ImageOffset.X, (Height - avatarSize) / 2 + 1 + ImageOffset.Y);
bmp.Dispose(); bmp.Dispose();
scaleImage.Dispose(); scaleImage.Dispose();
e.Graphics.SetHighQuality(); e.Graphics.SetHighQuality();
@ -285,12 +326,12 @@ namespace Sunny.UI
{ {
if (Shape == UIShape.Circle) if (Shape == UIShape.Circle)
{ {
e.Graphics.DrawEllipse(pn, (Width - avatarSize) / 2 + 1 + OffsetX, (Height - avatarSize) / 2 + 1 + OffsetY, size, size); e.Graphics.DrawEllipse(pn, (Width - avatarSize) / 2 + 1 + ImageOffset.X, (Height - avatarSize) / 2 + 1 + ImageOffset.Y, size, size);
} }
if (Shape == UIShape.Square) if (Shape == UIShape.Square)
{ {
e.Graphics.DrawRoundRectangle(pn, (Width - avatarSize) / 2 + 1 + OffsetX, (Height - avatarSize) / 2 + 1 + OffsetY, size, size, 5); e.Graphics.DrawRoundRectangle(pn, (Width - avatarSize) / 2 + 1 + ImageOffset.X, (Height - avatarSize) / 2 + 1 + ImageOffset.Y, size, size, 5);
} }
} }
@ -299,13 +340,14 @@ namespace Sunny.UI
if (Icon == UIIcon.Symbol) if (Icon == UIIcon.Symbol)
{ {
e.Graphics.DrawFontImage(symbol, symbolSize, ForeColor, new Rectangle((Width - avatarSize) / 2 + 1 + OffsetX, (Height - avatarSize) / 2 + 1 + OffsetY, avatarSize, avatarSize)); e.Graphics.DrawFontImage(symbol, symbolSize, ForeColor, new Rectangle((Width - avatarSize) / 2 + 1 + SymbolOffset.X,
(Height - avatarSize) / 2 + 1 + SymbolOffset.Y, avatarSize, avatarSize));
} }
if (Icon == UIIcon.Text) if (Icon == UIIcon.Text)
{ {
SizeF sf = e.Graphics.MeasureString(Text, Font); SizeF sf = e.Graphics.MeasureString(Text, Font);
e.Graphics.DrawString(Text, Font, foreColor, (Width - sf.Width) / 2.0f + OffsetX, (Height - sf.Height) / 2.0f + 1 + OffsetY); e.Graphics.DrawString(Text, Font, foreColor, (Width - sf.Width) / 2.0f + TextOffset.X, (Height - sf.Height) / 2.0f + 1 + TextOffset.Y);
} }
PaintAgain?.Invoke(this, e); PaintAgain?.Invoke(this, e);

View File

@ -30,7 +30,6 @@ using System.Drawing.Drawing2D;
using System.Windows.Forms; using System.Windows.Forms;
// ReSharper disable All // ReSharper disable All
#pragma warning disable 1591
namespace Sunny.UI namespace Sunny.UI
{ {

View File

@ -34,7 +34,7 @@ namespace Sunny.UI
[DefaultEvent("Click")] [DefaultEvent("Click")]
[DefaultProperty("Text")] [DefaultProperty("Text")]
[ToolboxItem(true)] [ToolboxItem(true)]
public class UIHeaderButton : UIControl, IButtonControl public class UIHeaderButton : UIControl, IButtonControl, ISymbol
{ {
public UIHeaderButton() public UIHeaderButton()
{ {

View File

@ -22,6 +22,7 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
@ -355,7 +356,7 @@ namespace Sunny.UI
} }
} }
public class NavMenuItem public class NavMenuItem : ISymbol
{ {
public string Text { get; set; } public string Text { get; set; }
@ -367,6 +368,8 @@ namespace Sunny.UI
public int SymbolSize { get; set; } = 24; public int SymbolSize { get; set; } = 24;
public Point SymbolOffset { get; set; } = new Point(0, 0);
public int PageIndex { get; set; } public int PageIndex { get; set; }
public string TipsText { get; set; } public string TipsText { get; set; }
@ -379,6 +382,7 @@ namespace Sunny.UI
public bool AlwaysOpen { get; set; } = false; public bool AlwaysOpen { get; set; } = false;
public NavMenuItem() public NavMenuItem()
{ {
} }

View File

@ -31,7 +31,7 @@ namespace Sunny.UI
{ {
[DefaultEvent("Click")] [DefaultEvent("Click")]
[DefaultProperty("Text")] [DefaultProperty("Text")]
public class UISymbolButton : UIButton public class UISymbolButton : UIButton, ISymbol
{ {
private int _symbolSize = 24; private int _symbolSize = 24;
private int _imageInterval = 2; private int _imageInterval = 2;
@ -121,6 +121,20 @@ namespace Sunny.UI
} }
} }
private Point symbolOffset = new Point(0, 0);
[DefaultValue(typeof(Point), "0, 0")]
[Description("字体图标的偏移位置"), Category("SunnyUI")]
public Point SymbolOffset
{
get => symbolOffset;
set
{
symbolOffset = value;
Invalidate();
}
}
protected override void OnPaintFill(Graphics g, GraphicsPath path) protected override void OnPaintFill(Graphics g, GraphicsPath path)
{ {
if (IsCircle) if (IsCircle)
@ -153,13 +167,11 @@ namespace Sunny.UI
if (IsCircle) if (IsCircle)
{ {
int size = Math.Min(Width, Height) - 2 - CircleRectWidth; int size = Math.Min(Width, Height) - 2 - CircleRectWidth;
using (Pen pn = new Pen(GetRectColor(), CircleRectWidth)) using var pn = new Pen(GetRectColor(), CircleRectWidth);
{
g.SetHighQuality(); g.SetHighQuality();
g.DrawEllipse(pn, (Width - size) / 2.0f, (Height - size) / 2.0f, size, size); g.DrawEllipse(pn, (Width - size) / 2.0f, (Height - size) / 2.0f, size, size);
g.SetDefaultQuality(); g.SetDefaultQuality();
} }
}
else else
{ {
base.OnPaintRect(g, path); base.OnPaintRect(g, path);
@ -204,7 +216,7 @@ namespace Sunny.UI
new RectangleF( new RectangleF(
(Width - ImageSize.Width) / 2.0f, (Width - ImageSize.Width) / 2.0f,
Padding.Top + (Height - ImageSize.Height - Padding.Top - Padding.Bottom) / 2.0f, Padding.Top + (Height - ImageSize.Height - Padding.Top - Padding.Bottom) / 2.0f,
ImageSize.Width, ImageSize.Height)); ImageSize.Width, ImageSize.Height), SymbolOffset.X, SymbolOffset.Y);
} }
if (Image != null) if (Image != null)
@ -223,7 +235,7 @@ namespace Sunny.UI
if (Symbol > 0 && Image == null) if (Symbol > 0 && Image == null)
{ {
e.Graphics.DrawFontImage(Symbol, SymbolSize, color, e.Graphics.DrawFontImage(Symbol, SymbolSize, color,
new RectangleF((Width - allWidth) / 2.0f, (Height - ImageSize.Height) / 2.0f, ImageSize.Width, ImageSize.Height)); new RectangleF((Width - allWidth) / 2.0f, (Height - ImageSize.Height) / 2.0f, ImageSize.Width, ImageSize.Height), SymbolOffset.X, SymbolOffset.Y);
} }
if (Image != null) if (Image != null)
@ -294,7 +306,7 @@ namespace Sunny.UI
if (Symbol > 0 && Image == null) if (Symbol > 0 && Image == null)
{ {
e.Graphics.DrawFontImage(Symbol, SymbolSize, color, e.Graphics.DrawFontImage(Symbol, SymbolSize, color,
new RectangleF(left, top, ImageSize.Width, ImageSize.Height)); new RectangleF(left, top, ImageSize.Width, ImageSize.Height), SymbolOffset.X, SymbolOffset.Y);
} }
if (Image != null) if (Image != null)

View File

@ -31,7 +31,7 @@ namespace Sunny.UI
[ToolboxItem(true)] [ToolboxItem(true)]
[DefaultEvent("Click")] [DefaultEvent("Click")]
[DefaultProperty("Text")] [DefaultProperty("Text")]
public sealed class UISymbolLabel : UIControl public sealed class UISymbolLabel : UIControl, ISymbol
{ {
private int _symbolSize = 24; private int _symbolSize = 24;
private int _imageInterval = 2; private int _imageInterval = 2;
@ -147,6 +147,20 @@ namespace Sunny.UI
} }
} }
private Point symbolOffset = new Point(0, 0);
[DefaultValue(typeof(Point), "0, 0")]
[Description("字体图标的偏移位置"), Category("SunnyUI")]
public Point SymbolOffset
{
get => symbolOffset;
set
{
symbolOffset = value;
Invalidate();
}
}
protected override void OnPaintFill(Graphics g, GraphicsPath path) protected override void OnPaintFill(Graphics g, GraphicsPath path)
{ {
g.FillRectangle(BackColor, Bounds); g.FillRectangle(BackColor, Bounds);
@ -171,13 +185,11 @@ namespace Sunny.UI
if (IsCircle) if (IsCircle)
{ {
int size = Math.Min(Width, Height) - 2 - CircleRectWidth; int size = Math.Min(Width, Height) - 2 - CircleRectWidth;
using (Pen pn = new Pen(GetRectColor(), CircleRectWidth)) using var pn = new Pen(GetRectColor(), CircleRectWidth);
{
g.SetHighQuality(); g.SetHighQuality();
g.DrawEllipse(pn, (Width - size) / 2.0f, (Height - size) / 2.0f, size, size); g.DrawEllipse(pn, (Width - size) / 2.0f, (Height - size) / 2.0f, size, size);
g.SetDefaultQuality(); g.SetDefaultQuality();
} }
}
else else
{ {
base.OnPaintRect(g, path); base.OnPaintRect(g, path);
@ -247,9 +259,9 @@ namespace Sunny.UI
} }
if (Text.IsNullOrEmpty()) if (Text.IsNullOrEmpty())
e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, ImageInterval + (Width - ImageSize.Width) / 2.0f, (Height - ImageSize.Height) / 2.0f); e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, ImageInterval + (Width - ImageSize.Width) / 2.0f, (Height - ImageSize.Height) / 2.0f, SymbolOffset.X, SymbolOffset.Y);
else else
e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, left, top); e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, left, top, SymbolOffset.X, SymbolOffset.Y);
} }
} }
} }

View File

@ -33,7 +33,7 @@ namespace Sunny.UI
{ {
[DefaultEvent("TextChanged")] [DefaultEvent("TextChanged")]
[DefaultProperty("Text")] [DefaultProperty("Text")]
public sealed partial class UITextBox : UIPanel public sealed partial class UITextBox : UIPanel, ISymbol
{ {
private readonly UIEdit edit = new UIEdit(); private readonly UIEdit edit = new UIEdit();
private readonly UIScrollBar bar = new UIScrollBar(); private readonly UIScrollBar bar = new UIScrollBar();
@ -377,7 +377,7 @@ namespace Sunny.UI
private void CalcEditHeight() private void CalcEditHeight()
{ {
TextBox edt = new TextBox(); TextBox edt = new();
edt.Font = edit.Font; edt.Font = edit.Font;
MinHeight = edt.PreferredHeight; MinHeight = edt.PreferredHeight;
edt.BorderStyle = BorderStyle.None; edt.BorderStyle = BorderStyle.None;
@ -901,20 +901,7 @@ namespace Sunny.UI
} }
else if (Symbol != 0) else if (Symbol != 0)
{ {
e.Graphics.DrawFontImage(Symbol, SymbolSize, SymbolColor, new Rectangle(4 + symbolOffset.X, (Height - SymbolSize) / 2 + 1 + symbolOffset.Y, SymbolSize, SymbolSize)); e.Graphics.DrawFontImage(Symbol, SymbolSize, SymbolColor, new Rectangle(4 + symbolOffset.X, (Height - SymbolSize) / 2 + 1 + symbolOffset.Y, SymbolSize, SymbolSize), SymbolOffset.X, SymbolOffset.Y);
}
}
private Point symbolOffset = new Point(0, 0);
[DefaultValue(typeof(Point), "0, 0")]
[Description("字体图标偏移"), Category("SunnyUI")]
public Point SymbolOffset
{
get => symbolOffset;
set
{
symbolOffset = value;
Invalidate();
} }
} }
@ -963,5 +950,19 @@ namespace Sunny.UI
Invalidate(); Invalidate();
} }
} }
private Point symbolOffset = new Point(0, 0);
[DefaultValue(typeof(Point), "0, 0")]
[Description("字体图标的偏移位置"), Category("SunnyUI")]
public Point SymbolOffset
{
get => symbolOffset;
set
{
symbolOffset = value;
Invalidate();
}
}
} }
} }

View File

@ -180,10 +180,7 @@ namespace Sunny.UI
{ {
var bmp = new Bitmap(e.ToolTipSize.Width, e.ToolTipSize.Height); var bmp = new Bitmap(e.ToolTipSize.Width, e.ToolTipSize.Height);
var g = Graphics.FromImage(bmp); var g = Graphics.FromImage(bmp);
int symbolWidth = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0; int symbolWidth = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
int symbolHeight = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
SizeF titleSize = new SizeF(0, 0); SizeF titleSize = new SizeF(0, 0);
if (tooltip.Title.IsValid()) if (tooltip.Title.IsValid())
{ {
@ -219,7 +216,6 @@ namespace Sunny.UI
} }
int symbolWidth = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0; int symbolWidth = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
int symbolHeight = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
SizeF titleSize = new SizeF(0, 0); SizeF titleSize = new SizeF(0, 0);
if (tooltip.Title.IsValid()) if (tooltip.Title.IsValid())
{ {
@ -249,7 +245,7 @@ namespace Sunny.UI
} }
} }
public class ToolTipControl public class ToolTipControl : ISymbol
{ {
public Control Control { get; set; } public Control Control { get; set; }
public string Title { get; set; } public string Title { get; set; }
@ -259,6 +255,8 @@ namespace Sunny.UI
public int SymbolSize { get; set; } = 32; public int SymbolSize { get; set; } = 32;
public Point SymbolOffset { get; set; } = new Point(0, 0);
public Color SymbolColor { get; set; } = UIChartStyles.Dark.ForeColor; public Color SymbolColor { get; set; } = UIChartStyles.Dark.ForeColor;
} }
} }

View File

@ -382,7 +382,7 @@ namespace Sunny.UI
return graphics.MeasureString(text, font).ToSize(); return graphics.MeasureString(text, font).ToSize();
} }
private Icon ToIcon(Bitmap srcBitmap, int size) public Icon ToIcon(Bitmap srcBitmap, int size)
{ {
if (srcBitmap == null) if (srcBitmap == null)
{ {

View File

@ -19,8 +19,6 @@
* 2020-01-01: V2.2.0 * 2020-01-01: V2.2.0
******************************************************************************/ ******************************************************************************/
#pragma warning disable 1591
using System.Drawing; using System.Drawing;
namespace Sunny.UI namespace Sunny.UI

View File

@ -62,7 +62,7 @@ namespace Sunny.UI
{ {
timer.Stop(); timer.Stop();
while (FontAwesomeV4Labels.Count > 0) while (!FontAwesomeV4Labels.IsEmpty)
{ {
if (FontAwesomeV4Labels.TryDequeue(out Label lbl)) if (FontAwesomeV4Labels.TryDequeue(out Label lbl))
{ {
@ -72,7 +72,7 @@ namespace Sunny.UI
} }
} }
while (ElegantIconsLabels.Count > 0) while (!ElegantIconsLabels.IsEmpty)
{ {
if (ElegantIconsLabels.TryDequeue(out Label lbl)) if (ElegantIconsLabels.TryDequeue(out Label lbl))
{ {
@ -82,7 +82,7 @@ namespace Sunny.UI
} }
} }
while (FontAwesomeV5SolidLabels.Count > 0) while (!FontAwesomeV5SolidLabels.IsEmpty)
{ {
if (FontAwesomeV5SolidLabels.TryDequeue(out Label lbl)) if (FontAwesomeV5SolidLabels.TryDequeue(out Label lbl))
{ {
@ -92,7 +92,7 @@ namespace Sunny.UI
} }
} }
while (FontAwesomeV5RegularLabels.Count > 0) while (!FontAwesomeV5RegularLabels.IsEmpty)
{ {
if (FontAwesomeV5RegularLabels.TryDequeue(out Label lbl)) if (FontAwesomeV5RegularLabels.TryDequeue(out Label lbl))
{ {
@ -102,7 +102,7 @@ namespace Sunny.UI
} }
} }
while (FontAwesomeV5BrandsLabels.Count > 0) while (!FontAwesomeV5BrandsLabels.IsEmpty)
{ {
if (FontAwesomeV5BrandsLabels.TryDequeue(out Label lbl)) if (FontAwesomeV5BrandsLabels.TryDequeue(out Label lbl))
{ {
@ -234,14 +234,17 @@ namespace Sunny.UI
private Label CreateLabel(int icon, UISymbolType symbolType) private Label CreateLabel(int icon, UISymbolType symbolType)
{ {
Label lbl = new Label(); Label lbl = new Label
lbl.AutoSize = false; {
lbl.Size = new Size(32, 32); AutoSize = false,
lbl.ForeColor = UIColor.Blue; Size = new Size(32, 32),
lbl.Image = FontImageHelper.CreateImage(icon, 28, UIFontColor.Primary, symbolType); ForeColor = UIColor.Blue,
lbl.ImageAlign = ContentAlignment.MiddleCenter; Image = FontImageHelper.CreateImage(icon, 28, UIFontColor.Primary, symbolType),
lbl.TextAlign = ContentAlignment.MiddleLeft; ImageAlign = ContentAlignment.MiddleCenter,
lbl.Margin = new Padding(2); TextAlign = ContentAlignment.MiddleLeft,
Margin = new Padding(2)
};
lbl.Click += lbl_DoubleClick; lbl.Click += lbl_DoubleClick;
lbl.MouseEnter += Lbl_MouseEnter; lbl.MouseEnter += Lbl_MouseEnter;
lbl.MouseLeave += Lbl_MouseLeave; lbl.MouseLeave += Lbl_MouseLeave;

View File

@ -30,7 +30,7 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
[DefaultEvent("Initialize")] [DefaultEvent("Initialize")]
public partial class UIPage : Form, IStyleInterface public partial class UIPage : Form, IStyleInterface, ISymbol
{ {
public readonly Guid Guid = Guid.NewGuid(); public readonly Guid Guid = Guid.NewGuid();
private Color _rectColor = UIColor.Blue; private Color _rectColor = UIColor.Blue;
@ -98,6 +98,20 @@ namespace Sunny.UI
} }
} }
private Point symbolOffset = new Point(0, 0);
[DefaultValue(typeof(Point), "0, 0")]
[Description("字体图标的偏移位置"), Category("SunnyUI")]
public Point SymbolOffset
{
get => symbolOffset;
set
{
symbolOffset = value;
Invalidate();
}
}
[DefaultValue(false), Description("在Frame框架中不被关闭"), Category("SunnyUI")] [DefaultValue(false), Description("在Frame框架中不被关闭"), Category("SunnyUI")]
public bool AlwaysOpen { get; set; } public bool AlwaysOpen { get; set; }
@ -322,7 +336,7 @@ namespace Sunny.UI
if (!AllowShowTitle) return; if (!AllowShowTitle) return;
if (Symbol > 0) if (Symbol > 0)
{ {
e.Graphics.DrawFontImage(Symbol, SymbolSize, TitleForeColor, new Rectangle(ImageInterval, 0, SymbolSize, TitleHeight)); e.Graphics.DrawFontImage(Symbol, SymbolSize, TitleForeColor, new Rectangle(ImageInterval, 0, SymbolSize, TitleHeight), SymbolOffset.X, SymbolOffset.Y);
} }
SizeF sf = e.Graphics.MeasureString(Text, Font); SizeF sf = e.Graphics.MeasureString(Text, Font);
@ -800,22 +814,22 @@ namespace Sunny.UI
public void ShowInfoNotifier(string desc, bool isDialog = false, int timeout = 2000) public void ShowInfoNotifier(string desc, bool isDialog = false, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, UINotifierType.INFO, UILocalize.InfoTitle, false, timeout); UINotifierHelper.ShowNotifier(desc, UINotifierType.INFO, UILocalize.InfoTitle, isDialog, timeout);
} }
public void ShowSuccessNotifier(string desc, bool isDialog = false, int timeout = 2000) public void ShowSuccessNotifier(string desc, bool isDialog = false, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UILocalize.SuccessTitle, false, timeout); UINotifierHelper.ShowNotifier(desc, UINotifierType.OK, UILocalize.SuccessTitle, isDialog, timeout);
} }
public void ShowWarningNotifier(string desc, bool isDialog = false, int timeout = 2000) public void ShowWarningNotifier(string desc, bool isDialog = false, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UILocalize.WarningTitle, false, timeout); UINotifierHelper.ShowNotifier(desc, UINotifierType.WARNING, UILocalize.WarningTitle, isDialog, timeout);
} }
public void ShowErrorNotifier(string desc, bool isDialog = false, int timeout = 2000) public void ShowErrorNotifier(string desc, bool isDialog = false, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, false, timeout); UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, isDialog, timeout);
} }
#endregion #endregion

View File

@ -26,7 +26,7 @@ using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
{ {
public partial class UITitlePage : UIPage public partial class UITitlePage : UIPage, ISymbol
{ {
public UITitlePage() public UITitlePage()
{ {
@ -161,12 +161,26 @@ namespace Sunny.UI
} }
} }
private Point symbolOffset = new Point(0, 0);
[DefaultValue(typeof(Point), "0, 0")]
[Description("字体图标的偏移位置"), Category("SunnyUI")]
public Point SymbolOffset
{
get => symbolOffset;
set
{
symbolOffset = value;
Invalidate();
}
}
protected override void OnPaintFore(Graphics g, GraphicsPath path) protected override void OnPaintFore(Graphics g, GraphicsPath path)
{ {
base.OnPaintFore(g, path); base.OnPaintFore(g, path);
if (Symbol > 0) if (Symbol > 0)
{ {
g.DrawFontImage(Symbol, SymbolSize, ForeColor, new Rectangle(6, 0, SymbolSize, Height)); g.DrawFontImage(Symbol, SymbolSize, ForeColor, new Rectangle(6, 0, SymbolSize, Height), SymbolOffset.X, SymbolOffset.Y);
} }
} }
} }

View File

@ -385,23 +385,18 @@ namespace Sunny.UI
} }
/// <summary> /// <summary>
/// 反注册窗体 /// 反注册窗体、页面
/// </summary> /// </summary>
/// <param name="guid">GUID</param> /// <param name="guid">GUID</param>
/// <param name="form">窗体</param> /// <param name="form">窗体</param>
public static void UnRegister(Guid guid, UIForm form) public static void UnRegister(Guid guid)
{ {
if (Forms.ContainsKey(guid))
Forms.TryRemove(guid, out _); Forms.TryRemove(guid, out _);
}
/// <summary> if (Pages.ContainsKey(guid))
/// 反注册页面
/// </summary>
/// <param name="guid">GUID</param>
/// <param name="page">页面</param>
public static void UnRegister(Guid guid, UIPage page)
{
Pages.TryRemove(guid, out _); Pages.TryRemove(guid, out _);
} }
/// <summary> /// <summary>

View File

@ -22,9 +22,6 @@
using System.Drawing; using System.Drawing;
#pragma warning disable 1591
//ButtonFillSelectedColor
namespace Sunny.UI namespace Sunny.UI
{ {
public abstract class UIBaseStyle public abstract class UIBaseStyle

View File

@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net5.0-windows;netcoreapp3.1;net40;net45</TargetFrameworks> <TargetFrameworks>net5.0-windows;netcoreapp3.1;net40;net45</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<ProjectGuid>{AB1CB247-E20B-4CBE-B269-570ADDD96C53}</ProjectGuid> <ProjectGuid>{AB1CB247-E20B-4CBE-B269-570ADDD96C53}</ProjectGuid>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<RootNamespace>Sunny.UI</RootNamespace> <RootNamespace>Sunny.UI</RootNamespace>