在我的WinForms应用程序中,我可以使用
以下是我目前编辑图标的方式:
直到需求变更,现在只需要更改任务栏图标而不更改标题栏(应用程序窗口左上角)图标,这就成为了一个问题。
经过一些搜索,我找到了这个答案,基本上说明不同的分辨率被用于在不同的位置显示图标。该答案中提到的“Greenfish Icon Editor Pro”效果很好,但我的编辑需要在运行时进行,因为它被用作通知方法,以通知用户未读通知的数量,所以这不是一次性编辑。
我意识到我需要更改图标的64x64像素才能实现我的目标,但到目前为止,我只能整体更改图标。
有没有办法编辑< strong > GetIcon() 函数以编辑特定的图标分辨率?(或者至少建议另一种替代方法将不胜感激)
this.Icon
更改任务栏图标,但这也会更改标题栏中的应用程序图标。以下是我目前编辑图标的方式:
public static Icon GetIcon(string text)
{
//Create bitmap, kind of canvas
Bitmap bitmap = new Bitmap(32, 32);
Icon icon = new Icon(@"<icon-location>");
System.Drawing.Font drawFont = new System.Drawing.Font("Calibri", 12, FontStyle.Bold);
System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Orange);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
graphics.DrawIcon(icon, 0, 0);
graphics.DrawString(text, drawFont, drawBrush, 20, 15);
Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());
drawFont.Dispose();
drawBrush.Dispose();
graphics.Dispose();
bitmap.Dispose();
return createdIcon;
}
直到需求变更,现在只需要更改任务栏图标而不更改标题栏(应用程序窗口左上角)图标,这就成为了一个问题。
经过一些搜索,我找到了这个答案,基本上说明不同的分辨率被用于在不同的位置显示图标。该答案中提到的“Greenfish Icon Editor Pro”效果很好,但我的编辑需要在运行时进行,因为它被用作通知方法,以通知用户未读通知的数量,所以这不是一次性编辑。
我意识到我需要更改图标的64x64像素才能实现我的目标,但到目前为止,我只能整体更改图标。
有没有办法编辑< strong > GetIcon() 函数以编辑特定的图标分辨率?(或者至少建议另一种替代方法将不胜感激)