Click here to Skip to main content
15,896,118 members
Articles / Desktop Programming / Windows Forms

Progress-O-Doom

Rate me:
Please Sign up or sign in to vote.
4.97/5 (251 votes)
21 Jan 2009CPOL15 min read 367.3K   13.5K   549  
A set of pluggable progress bar components
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;

namespace ProgressODoom {
	/// <summary></summary>
	[ToolboxBitmapAttribute(typeof(ProgressODoom.PlainProgressPainter), "Icons.PlainProgressPainter.ico")]
	public class PlainProgressPainter : AbstractProgressPainter, IProgressPainter, IDisposable {
		private Color color;
		private Brush brush;
		private Color edge = Color.Transparent;

		/// <summary></summary>
		public PlainProgressPainter() {
			this.Color = Color.FromArgb(151, 151, 234);
		}

		/// <summary></summary>
		/// <param name="color"></param>
		public PlainProgressPainter(Color color) {
			this.Color = color;
		}

		/// <summary></summary>
		[Category("Appearance"), Description("Gets or sets the color to draw the leading edge of the progress with"), Browsable(true)]
		public Color LeadingEdge {
			get { return this.edge; }
			set { this.edge = value; FireChange(); }
		}

		/// <summary></summary>
		[Category("Appearance"), Description("Gets or sets the base progress color"), Browsable(true)]
		public Color Color {
			get { return color; }
			set {
				color = value;
				brush = new SolidBrush(color);
				FireChange();
			}
		}

		/// <summary></summary>
		/// <param name="box"></param>
		/// <param name="g"></param>
		protected override void PaintThisProgress(Rectangle box, Graphics g) {
			if (box.Width <= 1) {
				return;
			}

			g.FillRectangle(brush, box);
			if (gloss != null) {
				gloss.PaintGloss(box, g);
			}
			if (!edge.Equals(Color.Transparent)) {
				g.DrawLine(new Pen(new SolidBrush(edge), 1f), box.Right, box.Y, box.Right, box.Bottom - 1);
			}
		}

		/// <summary></summary>
		protected override void DisposeThis(bool disposing) {
			brush.Dispose();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) BoneSoft Software
United States United States
I've been in software development for more than a decade now. Originally with ASP 2.0 and VB6. I worked in Japan for a year doing Java. And have been with C# ever since.

In 2005 I founded BoneSoft Software where I sell a small number of developer tools.
This is a Organisation (No members)


Comments and Discussions