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
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.
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.
Note
The 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.
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 [^]
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
|
In 1964, I was in the US Coast Guard when I wrote
my first program. It was written in RPG (note no suffixing numbers). Programs and data were entered using punched cards. Turnaround was about 3 hours. So much for the "good old days!"
In 1970, when assigned to Washington DC, I started my MS in Mechanical Engineering. I specialized in Transportation. Untold hours in statistical theory and practice were required, forcing me to use the university computer and learn the FORTRAN language, still using punched cards!
In 1973, I was employed by the Norfolk VA Police Department as a crime analyst for the
High Intensity Target program. There, I was still using punched cards!
In 1973, I joined Computer Sciences Corporation (CSC). There, for the first time, I was introduced to a terminal with the ability to edit, compile, link, and test my programs on-line. CSC also gave me the opportunity to discuss technical issues with some of the brightest minds I've encountered during my career.
In 1975, I moved to San Diego to head up an IR&D project,
BIODAB. I returned to school (UCSD) and took up Software Engineering at the graduate level. After BIODAB, I headed up a team that fixed a
stalled project. I then headed up one of the two most satisfying projects of my career, the
Automated Flight Operations Center at Ft. Irwin, CA.
I left Anteon Corporation (the successor to CSC on a major contract) and moved to Pensacola, FL. For a small company I built their firewall, given free to the company's customers. An opportunity to build an
air traffic controller trainer arose. This was the other most satisfying project of my career.
Today, I consider myself capable.