view Windows/Forms/ColorableStatusBar.cs @ 21:031354c2a34c default tip

* Add Hyperlink that does sensible stuff by default
author IBBoard <dev@ibboard.co.uk>
date Sat, 19 May 2012 16:45:19 +0100
parents 02a7c7aaf2c1
children
line wrap: on
line source

// This file (ColorableStatusBar.cs) is a part of the IBBoard.Windows.Forms library and is copyright 2009 IBBoard.
//
// The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.

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);
				}
			}
		} 
	}
}