Programming the ProgressBar Control


Programming the ProgressBar Control

The ProgressBar control gives your users a graphical representation of how an operation is progressing. This is useful when your application needs to perform a very time-consuming operation and you do not want the user to think the application has crashed or entered an endless loop.

The ProgressBar control is controlled by three Int32 properties: Minimum , Maximum , and Value . The Minimum and Maximum values define the minimum and maximum values of the ProgressBar control. The Value property defines the ProgressBar control's current value. The ProgressBar will be filled in from left to right as the Value property moves increasingly away from the Minimum value toward the Maximum value. The ProgressBar control is empty when the Value property is equal to the Minimum property. And once the Value property is equal to the Maximum value, the ProgressBar will be full. Immediately after the Value property is changed, the ProgressBar control will be repainted to reflect the new value.

Figures 3.11 and 3.12 show the BombSquad.exe game running in the Pocket PC 2002 emulator. The BombSquad game is a simple game that gives you a set amount of time to diffuse a dangerous bomb by clicking the Diffuse button before the ProgressBar control is filled. The Diffuse button's location continuously changes while the game is being played . Figure 3.11 shows the results of a successful diffusing , whereas Figure 3.12 shows what happens when you cannot diffuse the bomb in time. You will find the code for the BombSquad game in the source code for this book.

Figure 3.11. You win the BombSquad game by diffusing the bomb before the progress bar fills up.

graphics/03fig11.jpg

Figure 3.12. You lose the BombSquad game by failing to diffuse the bomb before the progress bar fills up.

graphics/03fig12.jpg



Microsoft.NET Compact Framework Kick Start
Microsoft .NET Compact Framework Kick Start
ISBN: 0672325705
EAN: 2147483647
Year: 2003
Pages: 206

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net