-
Notifications
You must be signed in to change notification settings - Fork 5
/
TextIcon.cs
36 lines (31 loc) · 867 Bytes
/
TextIcon.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Drawing;
namespace Pomodoro
{
class TextIcon
{
private Brush brush = new SolidBrush(Color.Black);
private Bitmap bitmap = new Bitmap(16, 16);
private Graphics graphics;
private Font font = new Font(FontFamily.GenericSansSerif, 8);
private Icon icon;
public TextIcon(string text) {
graphics = Graphics.FromImage(bitmap);
graphics.DrawString(text, font, brush, 0, 0);
IntPtr hIcon = bitmap.GetHicon();
icon = Icon.FromHandle(hIcon);
}
public Icon get()
{
return icon;
}
~TextIcon()
{
icon = null;
font = null;
graphics = null;
bitmap = null;
brush = null;
}
}
}