* UIForm:修改一处Icon图片显示的问题

This commit is contained in:
Sunny 2021-02-09 10:47:09 +08:00
parent 359513a5d5
commit ec54bfd398
6 changed files with 13 additions and 1 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -30,6 +30,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.IO;
using System.Windows.Forms;
namespace Sunny.UI
@ -1005,7 +1006,10 @@ namespace Sunny.UI
if (ShowTitleIcon && Icon != null)
{
e.Graphics.DrawImage(Icon.ToBitmap(), 6, (TitleHeight - 24) / 2, 24, 24);
using (Image image = IconToImage(Icon))
{
e.Graphics.DrawImage(image, 6, (TitleHeight - 24) / 2, 24, 24);
}
}
SizeF sf = e.Graphics.MeasureString(Text, Font);
@ -1019,6 +1023,14 @@ namespace Sunny.UI
}
}
private Image IconToImage(Icon icon)
{
MemoryStream mStream = new MemoryStream();
icon.Save(mStream);
Image image = Image.FromStream(mStream);
return image;
}
private bool showTitleIcon;
[Description("显示标题栏图标"), Category("SunnyUI")]