.net - How to add text to icon in c#? -
i want display icon [a .ico file] in system tray text added @ runtime. there native wpf way it? or snippet gdi+ grateful.
thank you.
here code worked me,
public static icon geticon(string text) { //create bitmap, kind of canvas bitmap bitmap = new bitmap(32, 32); icon icon = new icon(@"images\pomodomo.ico"); system.drawing.font drawfont = new system.drawing.font("calibri", 16, fontstyle.bold); system.drawing.solidbrush drawbrush = new system.drawing.solidbrush(system.drawing.color.white); 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, 1, 2); //to save icon disk bitmap.save("icon.ico", system.drawing.imaging.imageformat.icon); icon createdicon = icon.fromhandle(bitmap.gethicon()); drawfont.dispose(); drawbrush.dispose(); graphics.dispose(); bitmap.dispose(); return createdicon; }
Comments
Post a Comment