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

WYSIWYG Progress Circle for .NET Framework (C#)

By , 22 Jun 2008
 
ProgressCircle

Introduction

Would you like to add some visual enhancement to your Windows Forms application? Do you have processes that take too long? This control is for you.

Basically, it is a progress bar, but it is circular. You can fully customize its appearance. For example, you can change the ring thickness, number of segments, ring color, progress color, interval, etc.

The control can be added to the toolbox and it can be added to controls by just dragging and dropping from toolbox.

It is an open source (C#) project and compiled with .NET Framework 2.0.

Using the Code

It is pretty simple to use the control. All you need to do is to set the control's Rotate property to true to start the circle.

this.progressBar1.BackColor = System.Drawing.Color.Transparent;
this.progressBar1.ForeColor = System.Drawing.Color.Gold;
this.progressBar1.Interval = 100;
this.progressBar1.Location = new System.Drawing.Point(235, 90);
this.progressBar1.Name = "progressBar1";
this.progressBar1.RingColor = System.Drawing.Color.White;
this.progressBar1.RingThickness = 30;
this.progressBar1.Size = new System.Drawing.Size(80, 80);
this.progressBar1.Rotate = true;         

History

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

About the Author

Umut Tezduyar
Software Developer
United States United States
Member
Interests:
Operating Systems
Embedded Systems
.Net Framework
C#
Asp.net
 
Eduation:
MS Computer Science

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 4memberDevilVikas27 Jul '12 - 0:51 
Nice graphical work done.
GeneralNice but...membertim_mcgwyn20 Jul '09 - 9:49 
Hello,
 
The Zip-File ist corrupted! Please update your file Smile | :)
 
Greez
TmG
QuestionExcellent. Any planning port it to C++?memberk7774 Mar '09 - 1:32 
This is the one I've been looking for for a couple of months, since I like the way Nero Suite's circular progress control, i.e. a circular progress indicator with transparent background.
Unfortunately, I am C++ developer not C#. I will try to port it to C++ but due to my limited knowledge, I doubt I can do it. So if you plan to have porting it to MFC, I would appreciate it.
 
Thanks for your article.
GeneralGreat!memberLion_King11093 Mar '09 - 17:05 
Thanks you! Great Control Smile | :) You've got vote 5 from me Smile | :)
 
Impossible = I'm possible!

QuestionMemory LeakmemberYuyama2 Sep '08 - 16:33 
Once that the Progress Circle is displayed, memory consumption increases continually until the application is terminated.
I confirmed this trouble by the Task Manager of Win XP.
Why?
 
Yuyama
AnswerRe: Memory LeakmemberUmut Tezduyar3 Sep '08 - 6:30 
Hi Yuyama,
 
There cant be memory leak since memory is managed by garbage collector. Graphics object could be using a lot of memory but eventually it should be cleaned up by GC (Garbage Collector).
 
Thanks.
GeneralRe: Memory LeakmemberIzzet Kerem Kusmezer16 Dec '08 - 5:55 
Actually the memory leak was caused by DrawFilledArc portion of your code
Replace the section with the following code, which doesn't creates a new SolidBrush each time the DrawFilledArc gets created, solves the problem.
Also i am disposing the GraphicsPath, Region objects. The memory usage in this way stays the same.
 
 private System.Collections.Generic.Dictionary<Color, SolidBrush> _brushCache = 
            new System.Collections.Generic.Dictionary<Color,SolidBrush>();
 
		private void DrawFilledArc (Graphics grp, Color color, int startAngle)
		{
			grp.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
 
			Rectangle main = this.ClientRectangle;
			
			// If there is no region to be drawn, then this method terminates itself
			if (main.Width - (2*this._ringThickness) < 1 || main.Height -(2*this._ringThickness) <= 1)
				return;
 
			// Calculates the region that will be filled

            using (GraphicsPath outerPath = new GraphicsPath())
            {
                outerPath.AddPie(main, startAngle, this.PieAngle);
 
                Rectangle sub = new Rectangle(main.X + this._ringThickness, main.Y + this._ringThickness, main.Width - (2 * this._ringThickness), main.Height - (2 * this._ringThickness));
 
                using (GraphicsPath innerPath = new GraphicsPath())
                {
                    innerPath.AddPie(sub, startAngle - 1, this.PieAngle + 2);
 
                    using (System.Drawing.Region mainRegion = new Region(outerPath))
                    {
                        using (System.Drawing.Region subRegion = new Region(innerPath))
                        {
 
                            mainRegion.Exclude(subRegion);
                            
                            SolidBrush targetBrush;
                            
                            if (_brushCache.ContainsKey(color))
                            {
                                targetBrush = _brushCache[color];
                            }
                            else
                            {
                                targetBrush = new SolidBrush(color);
                                _brushCache.Add(color,targetBrush);
                            }
                            // Fill that region
                            grp.FillRegion(targetBrush, mainRegion);
                        }
                    }
                }
            }
		}	

GeneralRe: Memory LeakmemberUmut Tezduyar16 Dec '08 - 16:57 
Hi Kerem,
 
Thanks for the explanation. When I initially developed this windows control, .net framework 2.0 was in the market. I carefully examined the heap usage and it seemed there were no memory leaks in the control.
 
If you guys believe there is though, I hope your solution fixes it.
 
Thanks
GeneralRe: Memory Leakmemberrmcavalcante7 Sep '11 - 23:41 
Thanks Izzet Kerem Kusmezer,
 
I confirm the memory leak problem in Windows 7.
I have tried your solution and it really works.
Congratulations for both you, creator and contributor for the initiative.
GeneralVery dynamicmemberVCKicks21 Aug '08 - 19:27 
Pretty impressive, would look better anti-aliased though.
 
Still, props
 
Visit Visual C# Kicks for more free C#.Net articles, resources, and downloads at
http://vckicks.110mb.com

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 23 Jun 2008
Article Copyright 2008 by Umut Tezduyar
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid