Skip to main content
Email Password   helpLost your password?

Sample Image

Introduction

This is a simple progress bar control that imitates the XP visual style. The control inherits Windows.Forms.Control and the reason to add another progress bar here is that there was no XP style progress bar with the ability to change its colour. I needed a red coloured progress bar to indicate error but the normal XP progress bar does not allow colour change. Also, I needed that nice XP style because my program was using the XP visual styles. The bars are drawn just like the XP progress bar. The whole bars are drawn, not parts from them, depending on the value.

Background

For the progress bar, I used the very nice progress bar control developed by Alan Zhao. Basically, the main functionality is provided by him, I improved the painting of the control to make it XP like.

Control Properties

Control Methods

Painting code

// The region of the progress bar!

int leftbar = 1;
int topbar = 1;
int X = this.Width-1;
int Y = this.Height-1;
Point[] points = {   new Point(leftbar + 2, topbar), 
         new Point(X-2, topbar), 
         new Point(X-1, topbar + 1), 
         new Point(X, topbar + 2), 
         new Point(X, Y-3), 
         new Point(X-1, Y-2), 
         new Point(X-2, Y-1), 
         new Point(leftbar + 2, Y), 
         new Point(leftbar + 1, Y-2), 
         new Point(leftbar, Y-3), 
         new Point(leftbar, topbar + 2),
         new Point(leftbar + 1, topbar + 1),
        };    
GraphicsPath path = new GraphicsPath();
path.AddLines(points);
Region reg = new Region(path);
e.Graphics.FillRegion(Brushes.White, reg);

This is the definition of the region of the progress bar.

Points of Interest

The project is interesting if you want to learn how to simulate and to draw controls like they are drawn in Windows XP.

History

No history yet.

Thanks

Thanks again to Alan Zhao for his great work. You can check out his work here.

Feedbacks

Please vote for this article.

And email me or leave your messages if you have:

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralNice Pin
abno
6:23 2 Oct '07  
GeneralHow to use the code Pin
craude
1:07 1 Jan '07  


Last Updated 30 Mar 2005 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009