Mercurial > repos > IBBoard.Windows.Forms
view Windows/Forms/ColorableStatusBar.cs @ 0:d860e2c49f43
Initial commit of IBBoard libraries
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 19 Dec 2008 11:13:48 +0000 |
parents | |
children | 1acdb0aff4a7 |
line wrap: on
line source
using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; namespace IBBoard.Windows.Forms { /// <summary> /// Summary description for ColorableStatusBar. /// </summary> public class ColorableStatusBar : StatusBar { private Brush defaultBrush; public ColorableStatusBar() { defaultBrush = new SolidBrush(SystemColors.WindowText); } //Code taken from MS Knowledge base - http://support.microsoft.com/kb/319311 public void ColorableStatusBarDrawItem(object sender, StatusBarDrawItemEventArgs sbdevent) { if (sender is StatusBar) { System.Drawing.Graphics g = sbdevent.Graphics; StatusBar sb = (StatusBar)sender; RectangleF rectf = new RectangleF(sbdevent.Bounds.X, sbdevent.Bounds.Y, sbdevent.Bounds.Width, sbdevent.Bounds.Height); if (sbdevent.Panel is ColorableStatusBarPanel) { g.DrawString(sbdevent.Panel.Text, sb.Font, ((ColorableStatusBarPanel)sbdevent.Panel).Brush, rectf); } else { g.DrawString(sbdevent.Panel.Text, sb.Font, defaultBrush, rectf); } } } } }