修复了字体图标显示位置偏左的Bug
This commit is contained in:
parent
5b2be9b261
commit
939657d088
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
@ -232,6 +232,16 @@ namespace Sunny.UI
|
||||
{
|
||||
base.OnPaint(e);
|
||||
|
||||
if (Height != Width)
|
||||
{
|
||||
Height = Width;
|
||||
}
|
||||
|
||||
if (Width <= 0 || Height <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int size = Math.Min(Width, Height) - 3;
|
||||
if (Icon == UIIcon.Image)
|
||||
{
|
||||
@ -270,8 +280,7 @@ namespace Sunny.UI
|
||||
|
||||
if (Icon == UIIcon.Symbol)
|
||||
{
|
||||
SizeF sf = e.Graphics.GetFontImageSize(Symbol, SymbolSize);
|
||||
e.Graphics.DrawFontImage(Symbol, SymbolSize, foreColor, 2 + (size - 4 - sf.Width + 7) / 2.0f, 2 + (size - 4 - sf.Height + 2) / 2.0f);
|
||||
e.Graphics.DrawFontImage(symbol, symbolSize, ForeColor, new Rectangle(0, 0, Width, Height));
|
||||
}
|
||||
|
||||
if (Icon == UIIcon.Text)
|
||||
|
@ -29,7 +29,6 @@ using System.Drawing.Imaging;
|
||||
using System.Drawing.Text;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
@ -106,13 +105,7 @@ namespace Sunny.UI
|
||||
return new SizeF(0, 0);
|
||||
}
|
||||
|
||||
Label Image = new Label();
|
||||
Image.AutoSize = true;
|
||||
Image.Font = font;
|
||||
Image.Text = char.ConvertFromUtf32(symbol);
|
||||
Size ImageSize = Image.PreferredSize;
|
||||
Image.Dispose();
|
||||
return ImageSize;
|
||||
return graphics.MeasureString(char.ConvertFromUtf32(symbol), font);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -153,8 +146,8 @@ namespace Sunny.UI
|
||||
public static void DrawFontImage(this Graphics graphics, int symbol, int symbolSize, Color color, Rectangle rect, int xOffset = 0, int yOffSet = 0)
|
||||
{
|
||||
SizeF sf = graphics.GetFontImageSize(symbol, symbolSize);
|
||||
graphics.DrawFontImage(symbol, symbolSize, color, rect.Left + (rect.Width - sf.Width) / 2.0f,
|
||||
rect.Top + (rect.Height - sf.Height) / 2.0f, xOffset, yOffSet);
|
||||
graphics.DrawFontImage(symbol, symbolSize, color, rect.Left + ((rect.Width - sf.Width) / 2.0f).RoundEx(),
|
||||
rect.Top + ((rect.Height - sf.Height) / 2.0f).RoundEx(), xOffset, yOffSet);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -167,9 +160,11 @@ namespace Sunny.UI
|
||||
public static Image CreateImage(int symbol, int size, Color color)
|
||||
{
|
||||
Bitmap image = new Bitmap(size, size);
|
||||
|
||||
using (Graphics g = image.Graphics())
|
||||
{
|
||||
g.DrawFontImage(symbol, size, color, image.Bounds());
|
||||
SizeF sf = g.GetFontImageSize(symbol, size);
|
||||
g.DrawFontImage(symbol, size, color, (image.Width - sf.Width) / 2.0f, (image.Height - sf.Height) / 2.0f);
|
||||
}
|
||||
|
||||
return image;
|
||||
|
@ -554,7 +554,7 @@ namespace Sunny.UI
|
||||
e.Graphics.FillRoundRectangle(UIColor.Red, ControlBoxRect, 5);
|
||||
}
|
||||
|
||||
e.Graphics.DrawFontImage(61453, 24, Color.White, ControlBoxRect, 2);
|
||||
e.Graphics.DrawFontImage(61453, 24, Color.White, ControlBoxRect, 1);
|
||||
}
|
||||
|
||||
if (MaximizeBox)
|
||||
@ -567,7 +567,7 @@ namespace Sunny.UI
|
||||
e.Graphics.DrawFontImage(
|
||||
windowState == FormWindowState.Maximized
|
||||
? FontAwesomeIcons.fa_window_restore
|
||||
: FontAwesomeIcons.fa_window_maximize, 24, Color.White, MaximizeBoxRect, 2);
|
||||
: FontAwesomeIcons.fa_window_maximize, 24, Color.White, MaximizeBoxRect, 1);
|
||||
}
|
||||
|
||||
if (MinimizeBox)
|
||||
@ -577,7 +577,7 @@ namespace Sunny.UI
|
||||
e.Graphics.FillRoundRectangle(new SolidBrush(btn.FillHoverColor), MinimizeBoxRect, 5);
|
||||
}
|
||||
|
||||
e.Graphics.DrawFontImage(62161, 24, Color.White, MinimizeBoxRect, 2);
|
||||
e.Graphics.DrawFontImage(62161, 24, Color.White, MinimizeBoxRect, 1);
|
||||
}
|
||||
|
||||
e.Graphics.SetDefaultQuality();
|
||||
|
@ -1,5 +1,12 @@
|
||||
+ 增加; - 删除; * 修改
|
||||
|
||||
2020.05.23 V2.2.5
|
||||
* 修复字体图标一处Bug
|
||||
|
||||
2020.05.21 V2.2.5
|
||||
* 字体图标字体调整从资源文件中加载字体,不用另存为文件。
|
||||
* UIListBox 增加跟随鼠标滑过高亮
|
||||
|
||||
2020.05.05 V2.2.5
|
||||
+ 增加页面框架
|
||||
+ 增加下拉框窗体,进度提升窗体
|
||||
|
Loading…
x
Reference in New Issue
Block a user