The Amazing ProgressBar Control, amazingprogressbar

Source: Internet
Author: User

The Amazing ProgressBar Control (), amazingprogressbar

I haven't written a blog for a long time. I will first write an article today, and then I can write some more ~~~

Directly paste the original text, and no translation or personal explanation will be conducted, because the effect is COOL ~

 

The Amazing ProgressBar Control

A progress bar which displays progress as passage through a simple maze.

  • Download AmazingProgressBar_111_Demo.zip
  • Download AmazingProgressBar_111_Library.zip
  • Download AmazingProgressBar_111_Source.zip
Introduction

This is release 1.1.1 of the library. The. csproj files wereConverted for use in Visual Studio 2013, and the help filesWere updated to work with the latest release of Sandcastle Help File Builder (2014.5.31.0 ).

TheAmazingProgressBarClass is a drop-in replacement for the. NET 2.0ProgressBarControl, which displays progress as passage through a simple maze.

Allpublic Andprotected Classes, methods, and properties are fully encoded ented using standard C # XML documentation comments. the project has des an HTML help file. refer to the Overview section in the help file for more details on using the class.

The library download nodes des:

AmazingProgressBar. dll Class library
AmazingProgressBar. chm Help file

The demo download nodes des the above files, as well:

Amazingassumer.exe Sample program for experimenting with the various properties of the control.
AmazingExamples.exe Sample program displaying a varietyAmazingProgressBarExamples.

The source download nodes the source for all of the above programs, as well as the necessary files for building the help file.

Compatibility with Other. NET Framework Versions

The AmazingProgressBar library is compiled using. NET Framework version 2.0. to confirm that there were no issues with other framework versions, the compiled library was used by an application which was compiled, in turn, under. NET Framework versions 3.0, 3.5, 4.0, and 4.5. the AmazingProgressBar functioned properly with all of them.

Background

One day, while waiting for a long computational task to complete, I realized just how uninteresting the standard progress bar is. there had to be something more entertaining than a colored bar creeping slowly loading ss the screen. after thinking about the problem for a while, I hit upon the idea of a progress bar which winds through a maze. and hence was born,AmazingProgressBarControl.

TheAmazingProgressBarIs pure eye candy. It won't make the task run any faster, but it might make the wait a bit less boring!

Using the Code

To useAmazingProgressBarClass, simply add it on an existing form:

AmazingProgressBar amaze = new AmazingProgressBar();amaze.Location = new System.Drawing.Point(0, 0);amaze.Size = new System.Drawing.Size(200, 50);form.Controls.Add(amaze);

You can also replace any existingProgressBarWithAmazingProgressBar.

The progress direction and general style of the maze is determined byMazeStyleProperty:

SingleRight Maze with a single path progressing left to right.
SingleLeft Maze with a single path progressing right to left.
SingleUp Maze with a single path progressing up.
SingleDown Maze with a single path progressing down.
SplitConvergeHorizontal Maze with two paths starting at the left and right ends, converging in the middle.
SplitConvergeVertical Maze with two paths starting at the top and bottom, converging in the middle.
SplitDivergeHorizontal Maze with two paths starting in the middle, ending at the left and right ends.
SplitDivergeVertical Maze with two paths starting in the middle, ending at the top and bottom.

The mazes generally have one route over which they can be traversed, but a small amount of branching may occur ifRowCountIs greater than 3. The maze direction (s) is/are the general direction (s), though there will always be twists and turns and some doubling back.

The size and complexity of the maze generally depends onRowCountParameter. set this parameter to fix the number of rows in the maze. A value of 1 results in a maze which looks just like a standard progress bar. A value of 2 results in a distinctly uninteresting maze. A value of 3 or more is strongly recommended.

The number of columns in the maze is the largest value given the size of the control, the current valuesRowCount,WallSize, AndBorderSize, And the rule that all cells in the maze must be square.

TheProgressBar.StyleProperty can still be set.MarqueeStyle works as expected, but if the maze length is excessive, it may not work as fast as expected.BlocksStyle is generally not as visually appealingContinuous, Though an interesting effect is to be had combiningBlocksWith a zeroWallSize.

The following code segment shows how to setStyle,MazeStyle, And the number of rows.

// Assumes "AmazingProgressBar amaze" already declared and initializedamaze.Style = ProgressBarStyle.Continous;amaze.MazeStyle = MazeStyleType.SingleLeft;amaze.RowCount = 4;

If the control cannot generate a maze, then the control is filled with a pink-on-black ripple pattern. This is usually the resultRowCountBeing too high or too low.

The filled cells inside the maze can either all be the same fixed color, or follow a color gradient. This is determined byGradientProperty:

None No gradient coloring. All filled cells areForeColor.
Rows Each row in the maze is a different color, spanning a gradient with the first row beingGradientStartColor, And the last row beingGradientEndColor.
Columns Each column in the maze is a different color, spanning a gradient with the first column beingGradientStartColor, And the last column beingGradientEndColor.
Flow Each cell in the maze is a different color, spanning a gradient with the first cell beingGradientStartColor, And the last cell beingGradientEndColor.

All unfilled cells are alwaysBackColor.

The maze Wils are visible ifWallSizeIs greater than zero. The wallcan only be one fixed color, as indicated byWallColorProperty.

The maze border can either be one fixed color, or a gradient from that fixed color to the default control color. The maze border can also have round corners.

The following code segment shows how to set the various color properties.

// Assumes "AmazingProgressBar amaze" already declared and initializedamaze.Gradient = GradientType.Rows;amaze.GradientStartColor = Color.LightBlue;amaze.GradientEndColor = Color.DarkBlue;amaze.BorderSize = 2;amaze.BorderColor = Color.LightGreen;amaze.BorderGradient = false;amaze.BorderRoundCorners = true;amaze.BackColor = Color.White;
How the Maze is Generated

There are always ways to generate a maze. This control required an algorithm to generate a maze which flowed in a particle ction with minimal branching, and to do so quickly and with limited memory overhead.

TheSimpleMapClass does the job. It is a static class for generating mazes with but one route in a specified direction. It works well most of the time, but for valuesRowCountGreater than 3, it occasionally does miss some cells, resulting in branches in the maze.

Following are the instructions for generating a single path maze. The directions used-forward, backward, and sideways-depend ondirectionParameter. For example, ifdirectionIsDir.E, Then forward is East, backward is West, and sideways is North or South.

Start at one of the most backward corner cells. Repeatedly follow these rules (in order) to determine the next cell. Stop when all directions ctions are blocked.

Rules #2 and #5 are there to ensure that the maze does not get too far ahead before winding back.

Once a cell is reached where all the directions are blocked, the above rules no longer work. at this point, for each unused cell: randomly pick one direction and make the direction passable. this will result in branches within the maze, but it ensures that there are no skipped or unused cells.

History
  • September 6, 2014-Release 1.1.1
    • Converted. csproj files to Visual Studio 2013 format.
    • Converted help files to work with SandCastle Help File Builder 2014.5.31.0.
  • May 3, 2011-Release 1.1
    • AddedSplit...Maze styles.
    • AddedAmazingProgressBar.BorderRoundCornersMember.
  • April 17,201 1-First release
& Amp; lt; a href = "http://ad.doubleclick.net/N6839/jump/lqm.codeproject.site/Desktop-Development/Progress-Controls/General;sz=300x250;ord=635459314389670601? "& Amp; gt; & amp; lt; img src =" http://ad.doubleclick.net/N6839/ad/lqm.codeproject.site/Desktop-Development/Progress-Controls/General;sz=300x250;ord=635459314389670601? "Width =" 300px "height =" 250px "/& amp; gt; & amp; lt;/a & amp; gt; License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Graham Wilson

Software Developer (Senior)
Canada   The above content

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.