Click here to Skip to main content
Click here to Skip to main content

XP like colour progress bar

, 30 Mar 2005
Rate this:
Please Sign up or sign in to vote.
A WinForms progress bar control.

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

  • BarColor

    The primary color of ColorProgressBar.

  • BorderColor

    The border color of ColorProgressBar.

  • FillStyle

    Bar styles, "Solid" or "Dashed".

  • Maximum

    The maximum value of ColorProgressBar.

  • Minimum

    The minimum value or the initial value of ColorProgressBar.

  • Value

    The current value of ColorProgressBar.

  • Step

    The value of each increment or decrement when you call methods PerformStep() and PerformStepBack().

Control Methods

  • PerformStep()

    Call the PerformStep() method to increase the value set in the Step property.

  • PerformStepBack()

    Call the PerformStepBack() method to decrease the value set in the Step property.

  • Increment(int value)

    Call the Increment() method to increase the integer value you specify.

  • Decrement(int value)

    Call the Decrement() method to decrease the integer value you specify.

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:

  • bug reports
  • code improvements
  • any comments or suggestions.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Ivan Mihaylov

Bulgaria Bulgaria
Software engineer for TeamR3 Bulgaria.

Comments and Discussions

 
GeneralNice Pinmemberabno2-Oct-07 5:23 
QuestionHow to use the code Pinmembercraude1-Jan-07 0:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 30 Mar 2005
Article Copyright 2005 by Ivan Mihaylov
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid