diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..7714bb0d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,4 @@
+[*.cs]
+
+# IDE0090: 使用 "new(...)"
+dotnet_diagnostic.IDE0090.severity = none
diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll
index 42dfed2a..e226331e 100644
Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ
diff --git a/Bin/net45/SunnyUI.dll b/Bin/net45/SunnyUI.dll
index 754164d7..35c2dca3 100644
Binary files a/Bin/net45/SunnyUI.dll and b/Bin/net45/SunnyUI.dll differ
diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll
index 2150f96c..69eb2a09 100644
Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ
diff --git a/Bin/net5.0-windows/ref/SunnyUI.dll b/Bin/net5.0-windows/ref/SunnyUI.dll
index a84074f5..d2445567 100644
Binary files a/Bin/net5.0-windows/ref/SunnyUI.dll and b/Bin/net5.0-windows/ref/SunnyUI.dll differ
diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll
index dcd03eb7..fd99dcff 100644
Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ
diff --git a/SunnyUI.Demo/SunnyUI.Demo.csproj b/SunnyUI.Demo/SunnyUI.Demo.csproj
index 8524b695..ead28299 100644
--- a/SunnyUI.Demo/SunnyUI.Demo.csproj
+++ b/SunnyUI.Demo/SunnyUI.Demo.csproj
@@ -480,6 +480,9 @@
Resources.resx
True
+
+ .editorconfig
+
SettingsSingleFileGenerator
Settings.Designer.cs
diff --git a/SunnyUI/Controls/UIAvatar.cs b/SunnyUI/Controls/UIAvatar.cs
index 2176b7f1..283e643c 100644
--- a/SunnyUI/Controls/UIAvatar.cs
+++ b/SunnyUI/Controls/UIAvatar.cs
@@ -34,7 +34,7 @@ namespace Sunny.UI
[DefaultEvent("Click")]
[DefaultProperty("Symbol")]
[ToolboxItem(true)]
- public sealed class UIAvatar : UIControl
+ public sealed class UIAvatar : UIControl, ISymbol
{
///
/// 头像图标类型
@@ -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();
+ }
+ }
+
///
/// OnPaintFill
///
@@ -225,7 +267,6 @@ namespace Sunny.UI
/// 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);
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;
- [DefaultValue(0), Description("垂直偏移"), Category("SunnyUI")]
+ [Browsable(false), DefaultValue(0), Description("垂直偏移"), Category("SunnyUI")]
public int OffsetY { get; set; } = 0;
public event PaintEventHandler PaintAgain;
@@ -276,7 +317,7 @@ namespace Sunny.UI
(int)(Image.Height * 1.0 / Math.Min(sc1, sc2) + 0.5));
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();
scaleImage.Dispose();
e.Graphics.SetHighQuality();
@@ -285,12 +326,12 @@ namespace Sunny.UI
{
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)
{
- 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)
{
- 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)
{
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);
diff --git a/SunnyUI/Controls/UIButton.cs b/SunnyUI/Controls/UIButton.cs
index 366837a8..f79df1b5 100644
--- a/SunnyUI/Controls/UIButton.cs
+++ b/SunnyUI/Controls/UIButton.cs
@@ -30,7 +30,6 @@ using System.Drawing.Drawing2D;
using System.Windows.Forms;
// ReSharper disable All
-#pragma warning disable 1591
namespace Sunny.UI
{
diff --git a/SunnyUI/Controls/UIHeaderButton.cs b/SunnyUI/Controls/UIHeaderButton.cs
index 0a1ceb76..d448d2c5 100644
--- a/SunnyUI/Controls/UIHeaderButton.cs
+++ b/SunnyUI/Controls/UIHeaderButton.cs
@@ -34,7 +34,7 @@ namespace Sunny.UI
[DefaultEvent("Click")]
[DefaultProperty("Text")]
[ToolboxItem(true)]
- public class UIHeaderButton : UIControl, IButtonControl
+ public class UIHeaderButton : UIControl, IButtonControl, ISymbol
{
public UIHeaderButton()
{
diff --git a/SunnyUI/Controls/UINavMenuHelper.cs b/SunnyUI/Controls/UINavMenuHelper.cs
index 1c3743f4..73e092c0 100644
--- a/SunnyUI/Controls/UINavMenuHelper.cs
+++ b/SunnyUI/Controls/UINavMenuHelper.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections.Concurrent;
+using System.Drawing;
using System.Windows.Forms;
namespace Sunny.UI
@@ -355,7 +356,7 @@ namespace Sunny.UI
}
}
- public class NavMenuItem
+ public class NavMenuItem : ISymbol
{
public string Text { get; set; }
@@ -367,6 +368,8 @@ namespace Sunny.UI
public int SymbolSize { get; set; } = 24;
+ public Point SymbolOffset { get; set; } = new Point(0, 0);
+
public int PageIndex { get; set; }
public string TipsText { get; set; }
@@ -379,6 +382,7 @@ namespace Sunny.UI
public bool AlwaysOpen { get; set; } = false;
+
public NavMenuItem()
{
}
diff --git a/SunnyUI/Controls/UISymbolButton.cs b/SunnyUI/Controls/UISymbolButton.cs
index e36815eb..fab0f6a7 100644
--- a/SunnyUI/Controls/UISymbolButton.cs
+++ b/SunnyUI/Controls/UISymbolButton.cs
@@ -31,7 +31,7 @@ namespace Sunny.UI
{
[DefaultEvent("Click")]
[DefaultProperty("Text")]
- public class UISymbolButton : UIButton
+ public class UISymbolButton : UIButton, ISymbol
{
private int _symbolSize = 24;
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)
{
if (IsCircle)
@@ -153,12 +167,10 @@ namespace Sunny.UI
if (IsCircle)
{
int size = Math.Min(Width, Height) - 2 - CircleRectWidth;
- using (Pen pn = new Pen(GetRectColor(), CircleRectWidth))
- {
- g.SetHighQuality();
- g.DrawEllipse(pn, (Width - size) / 2.0f, (Height - size) / 2.0f, size, size);
- g.SetDefaultQuality();
- }
+ using var pn = new Pen(GetRectColor(), CircleRectWidth);
+ g.SetHighQuality();
+ g.DrawEllipse(pn, (Width - size) / 2.0f, (Height - size) / 2.0f, size, size);
+ g.SetDefaultQuality();
}
else
{
@@ -204,7 +216,7 @@ namespace Sunny.UI
new RectangleF(
(Width - ImageSize.Width) / 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)
@@ -223,7 +235,7 @@ namespace Sunny.UI
if (Symbol > 0 && Image == null)
{
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)
@@ -294,7 +306,7 @@ namespace Sunny.UI
if (Symbol > 0 && Image == null)
{
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)
diff --git a/SunnyUI/Controls/UISymbolLabel.cs b/SunnyUI/Controls/UISymbolLabel.cs
index ca9af759..07e327b2 100644
--- a/SunnyUI/Controls/UISymbolLabel.cs
+++ b/SunnyUI/Controls/UISymbolLabel.cs
@@ -31,7 +31,7 @@ namespace Sunny.UI
[ToolboxItem(true)]
[DefaultEvent("Click")]
[DefaultProperty("Text")]
- public sealed class UISymbolLabel : UIControl
+ public sealed class UISymbolLabel : UIControl, ISymbol
{
private int _symbolSize = 24;
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)
{
g.FillRectangle(BackColor, Bounds);
@@ -171,12 +185,10 @@ namespace Sunny.UI
if (IsCircle)
{
int size = Math.Min(Width, Height) - 2 - CircleRectWidth;
- using (Pen pn = new Pen(GetRectColor(), CircleRectWidth))
- {
- g.SetHighQuality();
- g.DrawEllipse(pn, (Width - size) / 2.0f, (Height - size) / 2.0f, size, size);
- g.SetDefaultQuality();
- }
+ using var pn = new Pen(GetRectColor(), CircleRectWidth);
+ g.SetHighQuality();
+ g.DrawEllipse(pn, (Width - size) / 2.0f, (Height - size) / 2.0f, size, size);
+ g.SetDefaultQuality();
}
else
{
@@ -247,9 +259,9 @@ namespace Sunny.UI
}
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
- e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, left, top);
+ e.Graphics.DrawFontImage(Symbol, SymbolSize, symbolColor, left, top, SymbolOffset.X, SymbolOffset.Y);
}
}
}
diff --git a/SunnyUI/Controls/UITextBox.cs b/SunnyUI/Controls/UITextBox.cs
index c594dc63..d92dee04 100644
--- a/SunnyUI/Controls/UITextBox.cs
+++ b/SunnyUI/Controls/UITextBox.cs
@@ -33,7 +33,7 @@ namespace Sunny.UI
{
[DefaultEvent("TextChanged")]
[DefaultProperty("Text")]
- public sealed partial class UITextBox : UIPanel
+ public sealed partial class UITextBox : UIPanel, ISymbol
{
private readonly UIEdit edit = new UIEdit();
private readonly UIScrollBar bar = new UIScrollBar();
@@ -377,7 +377,7 @@ namespace Sunny.UI
private void CalcEditHeight()
{
- TextBox edt = new TextBox();
+ TextBox edt = new();
edt.Font = edit.Font;
MinHeight = edt.PreferredHeight;
edt.BorderStyle = BorderStyle.None;
@@ -901,20 +901,7 @@ namespace Sunny.UI
}
else if (Symbol != 0)
{
- e.Graphics.DrawFontImage(Symbol, SymbolSize, SymbolColor, new Rectangle(4 + symbolOffset.X, (Height - SymbolSize) / 2 + 1 + symbolOffset.Y, SymbolSize, SymbolSize));
- }
- }
-
- private Point symbolOffset = new Point(0, 0);
- [DefaultValue(typeof(Point), "0, 0")]
- [Description("字体图标偏移"), Category("SunnyUI")]
- public Point SymbolOffset
- {
- get => symbolOffset;
- set
- {
- symbolOffset = value;
- Invalidate();
+ e.Graphics.DrawFontImage(Symbol, SymbolSize, SymbolColor, new Rectangle(4 + symbolOffset.X, (Height - SymbolSize) / 2 + 1 + symbolOffset.Y, SymbolSize, SymbolSize), SymbolOffset.X, SymbolOffset.Y);
}
}
@@ -963,5 +950,19 @@ namespace Sunny.UI
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();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/SunnyUI/Controls/UIToolTip.cs b/SunnyUI/Controls/UIToolTip.cs
index ae5e4114..57bae6d6 100644
--- a/SunnyUI/Controls/UIToolTip.cs
+++ b/SunnyUI/Controls/UIToolTip.cs
@@ -180,10 +180,7 @@ namespace Sunny.UI
{
var bmp = new Bitmap(e.ToolTipSize.Width, e.ToolTipSize.Height);
var g = Graphics.FromImage(bmp);
-
int symbolWidth = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
- int symbolHeight = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
-
SizeF titleSize = new SizeF(0, 0);
if (tooltip.Title.IsValid())
{
@@ -219,7 +216,6 @@ namespace Sunny.UI
}
int symbolWidth = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
- int symbolHeight = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
SizeF titleSize = new SizeF(0, 0);
if (tooltip.Title.IsValid())
{
@@ -249,7 +245,7 @@ namespace Sunny.UI
}
}
- public class ToolTipControl
+ public class ToolTipControl : ISymbol
{
public Control Control { get; set; }
public string Title { get; set; }
@@ -259,6 +255,8 @@ namespace Sunny.UI
public int SymbolSize { get; set; } = 32;
+ public Point SymbolOffset { get; set; } = new Point(0, 0);
+
public Color SymbolColor { get; set; } = UIChartStyles.Dark.ForeColor;
}
}
diff --git a/SunnyUI/Font/UIFontImage.cs b/SunnyUI/Font/UIFontImage.cs
index e082a4c9..1cee9f31 100644
--- a/SunnyUI/Font/UIFontImage.cs
+++ b/SunnyUI/Font/UIFontImage.cs
@@ -382,7 +382,7 @@ namespace Sunny.UI
return graphics.MeasureString(text, font).ToSize();
}
- private Icon ToIcon(Bitmap srcBitmap, int size)
+ public Icon ToIcon(Bitmap srcBitmap, int size)
{
if (srcBitmap == null)
{
diff --git a/SunnyUI/Font/UIFontImageDefine.cs b/SunnyUI/Font/UIFontImageDefine.cs
index 9f9c1060..27c041d4 100644
--- a/SunnyUI/Font/UIFontImageDefine.cs
+++ b/SunnyUI/Font/UIFontImageDefine.cs
@@ -19,8 +19,6 @@
* 2020-01-01: V2.2.0 增加文件说明
******************************************************************************/
-#pragma warning disable 1591
-
using System.Drawing;
namespace Sunny.UI
diff --git a/SunnyUI/Font/UIFontImages.cs b/SunnyUI/Font/UIFontImages.cs
index d3b9313d..498d3fbc 100644
--- a/SunnyUI/Font/UIFontImages.cs
+++ b/SunnyUI/Font/UIFontImages.cs
@@ -62,7 +62,7 @@ namespace Sunny.UI
{
timer.Stop();
- while (FontAwesomeV4Labels.Count > 0)
+ while (!FontAwesomeV4Labels.IsEmpty)
{
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))
{
@@ -82,7 +82,7 @@ namespace Sunny.UI
}
}
- while (FontAwesomeV5SolidLabels.Count > 0)
+ while (!FontAwesomeV5SolidLabels.IsEmpty)
{
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))
{
@@ -102,7 +102,7 @@ namespace Sunny.UI
}
}
- while (FontAwesomeV5BrandsLabels.Count > 0)
+ while (!FontAwesomeV5BrandsLabels.IsEmpty)
{
if (FontAwesomeV5BrandsLabels.TryDequeue(out Label lbl))
{
@@ -234,14 +234,17 @@ namespace Sunny.UI
private Label CreateLabel(int icon, UISymbolType symbolType)
{
- Label lbl = new Label();
- lbl.AutoSize = false;
- lbl.Size = new Size(32, 32);
- lbl.ForeColor = UIColor.Blue;
- lbl.Image = FontImageHelper.CreateImage(icon, 28, UIFontColor.Primary, symbolType);
- lbl.ImageAlign = ContentAlignment.MiddleCenter;
- lbl.TextAlign = ContentAlignment.MiddleLeft;
- lbl.Margin = new Padding(2);
+ Label lbl = new Label
+ {
+ AutoSize = false,
+ Size = new Size(32, 32),
+ ForeColor = UIColor.Blue,
+ Image = FontImageHelper.CreateImage(icon, 28, UIFontColor.Primary, symbolType),
+ ImageAlign = ContentAlignment.MiddleCenter,
+ TextAlign = ContentAlignment.MiddleLeft,
+ Margin = new Padding(2)
+ };
+
lbl.Click += lbl_DoubleClick;
lbl.MouseEnter += Lbl_MouseEnter;
lbl.MouseLeave += Lbl_MouseLeave;
diff --git a/SunnyUI/Pages/UIPage.cs b/SunnyUI/Pages/UIPage.cs
index a21e4df7..6b3cc610 100644
--- a/SunnyUI/Pages/UIPage.cs
+++ b/SunnyUI/Pages/UIPage.cs
@@ -30,7 +30,7 @@ using System.Windows.Forms;
namespace Sunny.UI
{
[DefaultEvent("Initialize")]
- public partial class UIPage : Form, IStyleInterface
+ public partial class UIPage : Form, IStyleInterface, ISymbol
{
public readonly Guid Guid = Guid.NewGuid();
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")]
public bool AlwaysOpen { get; set; }
@@ -322,7 +336,7 @@ namespace Sunny.UI
if (!AllowShowTitle) return;
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);
@@ -800,22 +814,22 @@ namespace Sunny.UI
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)
{
- 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)
{
- 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)
{
- UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, false, timeout);
+ UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UILocalize.ErrorTitle, isDialog, timeout);
}
#endregion
diff --git a/SunnyUI/Pages/UITitlePage.cs b/SunnyUI/Pages/UITitlePage.cs
index dc5d5eae..c3b51b2b 100644
--- a/SunnyUI/Pages/UITitlePage.cs
+++ b/SunnyUI/Pages/UITitlePage.cs
@@ -26,7 +26,7 @@ using System.Windows.Forms;
namespace Sunny.UI
{
- public partial class UITitlePage : UIPage
+ public partial class UITitlePage : UIPage, ISymbol
{
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)
{
base.OnPaintFore(g, path);
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);
}
}
}
diff --git a/SunnyUI/Style/UIStyle.cs b/SunnyUI/Style/UIStyle.cs
index f9d9ab0e..260d3cf2 100644
--- a/SunnyUI/Style/UIStyle.cs
+++ b/SunnyUI/Style/UIStyle.cs
@@ -385,23 +385,18 @@ namespace Sunny.UI
}
///
- /// 反注册窗体
+ /// 反注册窗体、页面
///
/// GUID
/// 窗体
- public static void UnRegister(Guid guid, UIForm form)
+ public static void UnRegister(Guid guid)
{
- Forms.TryRemove(guid, out _);
- }
+ if (Forms.ContainsKey(guid))
+ Forms.TryRemove(guid, out _);
+
+ if (Pages.ContainsKey(guid))
+ Pages.TryRemove(guid, out _);
- ///
- /// 反注册页面
- ///
- /// GUID
- /// 页面
- public static void UnRegister(Guid guid, UIPage page)
- {
- Pages.TryRemove(guid, out _);
}
///
diff --git a/SunnyUI/Style/UIStyleColor.cs b/SunnyUI/Style/UIStyleColor.cs
index 7bb83851..d1b6d808 100644
--- a/SunnyUI/Style/UIStyleColor.cs
+++ b/SunnyUI/Style/UIStyleColor.cs
@@ -22,9 +22,6 @@
using System.Drawing;
-#pragma warning disable 1591
-//ButtonFillSelectedColor
-
namespace Sunny.UI
{
public abstract class UIBaseStyle
diff --git a/SunnyUI/SunnyUI.csproj b/SunnyUI/SunnyUI.csproj
index fe609dfa..073d48a4 100644
--- a/SunnyUI/SunnyUI.csproj
+++ b/SunnyUI/SunnyUI.csproj
@@ -2,6 +2,7 @@
net5.0-windows;netcoreapp3.1;net40;net45
+ 9.0
{AB1CB247-E20B-4CBE-B269-570ADDD96C53}
true
Sunny.UI