void SetIconX()
{
//by 2022/12/18 ChatGPT
// 创建一个绘图对象
Graphics g = Graphics.FromHwnd(IntPtr.Zero);
// 设置字体
Font font = new Font("Arial", 14, FontStyle.Regular);
// 绘制文字
string text = "I'mAPPICON".Length>2?"I'mAPPICON".Substring(0,2):"I'mAPPICON";
SizeF size = g.MeasureString(text, font);
// 创建图像
Bitmap bmp = new Bitmap((int)size.Width, (int)size.Height);
// 创建绘图对象
Graphics g2 = Graphics.FromImage(bmp);
// 使用 DrawString 方法将文字绘制到图像上
g2.DrawString(text, font, Brushes.Black, new PointF(0, 0));
// 创建图标
Icon icon = Icon.FromHandle(bmp.GetHicon());
// 使用 SetIcon 方法更改图标
this.Icon = (icon);
}
07-28
4727
