Win8MarqueeProgressIndicator Control






4.93/5 (13 votes)
This article presents a user-drawn control, named Win8MarqueeProgressIndicator.
Introduction [^]

This short article presents a control, named Win8MarqueeProgressIndicator, that was requested by a reader of Win8ProgressRing Control. Basically, this control flattens the Win8ProgressRing control.
Only a brief discussion of its implementation will be provided. In the following discussions, properties that are specified by the developer are displayed in BoldMixedCase text. Variables, used internally by the software are displayed in italicized_lowercase text.
Table of Contents
- Introduction
- Table of Contents
- Visual Properties
- Control Properties
- Implementation
- Graphics Buffer
- Conclusion
- References
- Development Environment
- History
The symbol [^] returns the reader to the top of the Table of Contents.
Visual Properties [^]

The Win8MarqueeProgressIndicator control has two properties that form the user's visual image.
The developer specifies the control's top-left corner by dragging the control from the ToolBox to a position on the form. This position becomes ( 0, 0 ) in the control's graphic environment. The developer specifies the control_width by either dragging the control's resizing handles or by specifying the Control_Width property. After some computations, the control_height is set equal to the indicator_diameter.
The indicator color defaults to white. To change the indicator color, the developer specifies the new color through the Indicator_Color property.
The control's background color is transparent and cannot be changed.
Control Properties [^]
The Win8MarqueeProgressIndicator control has the following properties available to the developer:
Name | Description | |
Animate | Gets or sets a value indicating whether the control moves the indicators automatically. If true, the control moves the indicators without further intervention; if false, the control moves the indicators only when the Pulse method is invoked. The default value is true. | |
Control_Width |
Gets or sets the width of the control. When changed, this
property also causes other internal values for the control to be
changed. The value supplied for
Control_Width must be a
multiple of 33 that is greater than or equal to 99 and less than
or equal to 462. The default value is 462 pixels. When
Control_Width changes,
the following method is invoked.
// ********************** adjust_control_dimensions_from_width
void adjust_control_dimensions_from_width ( int new_width )
{
indicator_diameter = round (
( double ) new_width /
( double ) MAXIMUM_POSITIONS );
control_width = indicator_diameter * MAXIMUM_POSITIONS;
control_height = indicator_diameter;
this.Width=control_width;
this.Height = control_height;
}
|
|
Indicator_Color | Gets or sets the color of the indicators in the Win8MarqueeProgressIndicator control. The default value is Color.White. | |
Refresh_Rate | Gets or sets the time, in milliseconds, between movements of the indicators. The value must be greater than or equal to ten, and less than or equal to 200. The default is 100 milliseconds. |
The Pulse method is used to rotate the indicators once each time it is invoked. Its signature is:
public void Pulse ( )
Implementation [^]

The Win8MarqueeProgressIndicator control is a User-Drawn Control. Parts of the control are drawn when the control's OnPaint method is invoked.
The control's graphic is made up of two distinct graphic images: the background graphic and the indicator graphic.
Once drawn, the background graphic does not need to be redrawn unless Control_Width is changed. The indicator graphic must be redrawn when the background graphic is redrawn; when the animation changes the indicators' positions; or when the indicator color changes.
The control is made up of six circular indicators that travel rightward along the width of the control. At the far right, the indicators wrap around to the far left. Initially the indicators are centered within the control width.
NoteThe control uses Windows coordinates with the x-axis values increasing to the right; y-axis values increasing downward; and angles measured counterclockwise from the x-axis.
Starting with the most rightward indicator, it is moved to the next allowed indicator position (i.e., the indicator in position 18 is moved to position 20). To the right of control center are positions that will cause the indicators to appear to be accelerating. When an indicator is moved to position 32, its next position will be 0. Now as the indicator moves rightward it should appear to decelerate.
draw_indicator_graphic is invoked each time the interval timer raises the elapsed event.
// ************************************ draw_indicator_graphic
void draw_indicator_graphic ( Graphics graphics )
{
Brush brush = new SolidBrush ( Indicator_Color );
Rectangle rectangle = new Rectangle ( );
for ( int i = ( MAXIMUM_INDICATORS - 1 );
( i >= 0 );
i-- )
{
int index;
double position;
int x;
int y;
index = position_indices [ i ];
if ( index >= POSITIONS )
{
index = 0;
}
position = positions [ index ];
x = round ( position *
( double ) indicator_diameter );
y = 0;
rectangle.Location = new Point ( x, y );
rectangle.Size = new Size ( indicator_diameter,
indicator_diameter );
graphics.FillEllipse ( brush, rectangle );
index++;
position_indices [ i ] = index;
}
brush.Dispose ( );
}
Graphics Buffer [^]
The GraphicsBuffer class contains an off-screen bitmap used to draw graphic objects without flicker. Although .Net provides a Double Buffered Graphics capability, it is overkill for the Win8MarqueeProgressIndicator control.
GraphicsBuffer has been included within the control.
Conclusion [^]
This article has presented a control that provides a Windows 8 style marquee progress indicator.
References [^]
- Add Items to the Toolbox
- Double Buffered Graphics
- Graphics
- Implementing Events
- Raising an Event
- Rounding
- User-Drawn Controls
Development Environment [^]
Win8MarqueeProgressIndicator control was developed in the following environment:
Microsoft Windows 7 Professional Service Pack 1 | |
Microsoft Visual Studio 2008 Professional | |
Microsoft .Net Framework Version 3.5 SP1 | |
Microsoft Visual C# 2008 |
History [^]
09/05/2013 | Original Article |