diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll index 13310649..023b39ad 100644 Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ diff --git a/Bin/SunnyUI.pdb b/Bin/SunnyUI.pdb index a4b42c65..eb755d92 100644 Binary files a/Bin/SunnyUI.pdb and b/Bin/SunnyUI.pdb differ diff --git a/SunnyUI.Demo/Bin/SunnyUI.dll b/SunnyUI.Demo/Bin/SunnyUI.dll index 13310649..023b39ad 100644 Binary files a/SunnyUI.Demo/Bin/SunnyUI.dll and b/SunnyUI.Demo/Bin/SunnyUI.dll differ diff --git a/SunnyUI/Controls/UIAvatar.cs b/SunnyUI/Controls/UIAvatar.cs index 368c78aa..b79b0116 100644 --- a/SunnyUI/Controls/UIAvatar.cs +++ b/SunnyUI/Controls/UIAvatar.cs @@ -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) diff --git a/SunnyUI/Font/UIFontImage.cs b/SunnyUI/Font/UIFontImage.cs index 732e81d1..d6ffe3a6 100644 --- a/SunnyUI/Font/UIFontImage.cs +++ b/SunnyUI/Font/UIFontImage.cs @@ -18,7 +18,7 @@ * * 2020-01-01: V2.2.0 增加文件说明 * 2020-05-21: V2.2.5 调整从资源文件中加载字体,不用另存为文件。 - * 感谢:麦壳饼 https://gitee.com/maikebing + * 感谢:麦壳饼 https://gitee.com/maikebing ******************************************************************************/ using System; @@ -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); } /// @@ -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); } /// @@ -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; diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs index 4de452a4..563db7b5 100644 --- a/SunnyUI/Forms/UIForm.cs +++ b/SunnyUI/Forms/UIForm.cs @@ -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(); diff --git a/Updates.txt b/Updates.txt index 9c128cde..8e3a4b1c 100644 --- a/Updates.txt +++ b/Updates.txt @@ -1,5 +1,12 @@ + 增加; - 删除; * 修改 +2020.05.23 V2.2.5 +* 修复字体图标一处Bug + +2020.05.21 V2.2.5 +* 字体图标字体调整从资源文件中加载字体,不用另存为文件。 +* UIListBox 增加跟随鼠标滑过高亮 + 2020.05.05 V2.2.5 + 增加页面框架 + 增加下拉框窗体,进度提升窗体