Code to draw the icon
private void MainForm_Load(object sender, System.EventArgs e)
{
notifyIcon1.Text = DateTime.Today.DayOfWeek.ToString() + " " + DateTime.Now.ToString();
ArrayList strMon = new ArrayList(); strMon.Add(" ");
strMon.Add("Jan"); strMon.Add("Feb"); strMon.Add("Mar"); strMon.Add("Apr");
strMon.Add("May"); strMon.Add("Jun"); strMon.Add("Jul"); strMon.Add("Aug");
strMon.Add("Sep"); strMon.Add("Oct"); strMon.Add("Nov"); strMon.Add("Dec");
string myDay = DateTime.Today.Day.ToString();
int thisMonth = (int) DateTime.Today.Month;
string myMonth = strMon[thisMonth].ToString();
// here's where the icon gets assigned; see DrawIcon for details
this.notifyIcon1.Icon = DrawIcon(myMonth, myDay);
oMenu = new System.Windows.Forms.ContextMenu();
oMenu.MenuItems.Add("About " + Application.ProductName, new EventHandler(About_Handler));
oMenu.MenuItems.Add("Exit", new EventHandler(Exit_Handler));
this.notifyIcon1.ContextMenu = oMenu;
}
// here's where I draw the icon which will appear in the system tray
private Icon DrawIcon(string iconMonth, string iconDay)
{
int dimension=16;
Bitmap myBitmap = new Bitmap(dimension,dimension);
Graphics myGraphics = Graphics.FromImage((Image)myBitmap);
myGraphics.SmoothingMode = SmoothingMode.AntiAlias;
Font myFont1 = new Font("Verdana",8,FontStyle.Regular,GraphicsUnit.Pixel);
Font myFont2 = new Font("Verdana",9,FontStyle.Regular,GraphicsUnit.Pixel);
myGraphics.FillRectangle(Brushes.Transparent, new Rectangle(0, 0, myBitmap.Width, myBitmap.Height));
// create the green square
Brush myBrush = Brushes.LimeGreen;
myGraphics.FillRectangle(myBrush,0,0,dimension, dimension);
// write the text in it
myGraphics.DrawString(iconMonth,myFont1, new SolidBrush(Color.Black),0,0);
myGraphics.DrawString(iconDay,myFont2, new SolidBrush(Color.Black),2,6);
Icon myIcon = Icon.FromHandle(myBitmap.GetHicon());
return myIcon;
}