好久没写博客了,今天就先转一篇,随后可以再写些~~~

直接把原文粘过来,就不再进行翻译和个人说明了,因为效果很COOL~


The Amazing ProgressBar Control

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

Introduction

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

The AmazingProgressBar class is a drop-in replacement for the .NET 2.0 ProgressBar control, which displays progress as passage through a simple maze.

All public and protected classes, methods, and properties are fully documented using standard C# XML documentation comments. The project includes an HTML help file. Refer to the Overview section in the help file for more details on using the class.

The library download includes:

AmazingProgressBar.dll Class library
AmazingProgressBar.chm Help file

The demo download includes the above files, as well as:

AmazingExplorer.exe Sample program for experimenting with the various properties of the control.
AmazingExamples.exe Sample program displaying a variety of AmazingProgressBar examples.

The source download includes 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 across 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, the AmazingProgressBar control.

The AmazingProgressBar is 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 use the AmazingProgressBar class, simply add it on an existing form:

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

You can also replace any existing ProgressBar with AmazingProgressBar.

The progress direction and general style of the maze is determined by the MazeStyle property:

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 if RowCount is 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 on the RowCount parameter. 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 values of RowCount, WallSize, and BorderSize, and the rule that all cells in the maze must be square.

The ProgressBar.Style property can still be set. The Marquee style works as expected, but if the maze length is excessive, it may not work as fast as expected. The Blocks style is generally not as visually appealing as Continuous, though an interesting effect is to be had combining Blocks with a zero WallSize.

The following code segment shows how to set the Style, MazeStyle, and the number of rows.

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

If the control cannot generate a maze, then the control is filled with a pink - on - black ripple pattern. This is usually the result of RowCount being 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 by the Gradient property:

None No gradient coloring. All filled cells are ForeColor.
Rows Each row in the maze is a different color, spanning a gradient with the first row being GradientStartColor, and the last row being GradientEndColor.
Columns Each column in the maze is a different color, spanning a gradient with the first column being GradientStartColor, and the last column being GradientEndColor.
Flow Each cell in the maze is a different color, spanning a gradient with the first cell being GradientStartColor, and the last cell being GradientEndColor.

All unfilled cells are always BackColor.

The maze walls are visible if WallSize is greater than zero. The walls can only be one fixed color, as indicated by the WallColor property.

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 initialized
amaze.Gradient = GradientType.Rows;
amaze.GradientStartColor = Color.LightBlue;
amaze.GradientEndColor = Color.DarkBlue; amaze.BorderSize = ;
amaze.BorderColor = Color.LightGreen;
amaze.BorderGradient = false;
amaze.BorderRoundCorners = true; amaze.BackColor = Color.White;

How the Maze is Generated

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

The SimpleMap class 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 values of RowCount greater 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 on the direction parameter. For example, if direction is Dir.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 are blocked.

  1. If only one direction is possible, go in that direction.
  2. If you can go backwards, go that direction.
  3. If there is only one empty cell in a sideways direction, go in that direction.
  4. If there is more than one empty cell in both of the sideways directions, randomly pick one of those directions.
  5. Pick a random direction from the ones available; but you are only allowed to go forward if:
    1. at a sideways edge, and
    2. more than two steps from the forward most end, and
    3. back most filled column is not more than three steps backward.

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 7, 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
    • Added Split... maze styles.
    • Added AmazingProgressBar.BorderRoundCorners member.
  • April 17, 2011 - First release
<a href="http://ad.doubleclick.net/N6839/jump/lqm.codeproject.site/Desktop-Development/Progress-Controls/General;sz=300x250;ord=635459314389670601?"><img src="http://ad.doubleclick.net/N6839/ad/lqm.codeproject.site/Desktop-Development/Progress-Controls/General;sz=300x250;ord=635459314389670601?" width="300px" height="250px" /></a>

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 Amazing ProgressBar Control 
 

感谢原作者的无私分享~~~
多与人交流,与人分享^_^

The Amazing ProgressBar Control(转)的更多相关文章

  1. A CIRCULAR PROGRESSBAR STYLE USING AN ATTACHED VIEWMODEL

    This blog post describes how to re-template the Silverlight ProgressBar control to render a circular ...

  2. WPF多线程下载文件,有进度条

    //打开对话框选择文件         private void OpenDialogBox_Click(object sender, RoutedEventArgs e)         {     ...

  3. IE中的activex控件

    1.tree控件 DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HE ...

  4. C#中的线程三 (结合ProgressBar学习Control.BeginInvoke)

    C#中的线程三(结合ProgressBar学习Control.BeginInvoke) 本篇继上篇转载的关于Control.BeginInvoke的论述之后,再结合一个实例来说明Cotrol.Begi ...

  5. 背水一战 Windows 10 (34) - 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing

    [源码下载] 背水一战 Windows 10 (34) - 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing 作者:webabcd 介绍背水一 ...

  6. C# 多线程详解 Part.02(UI 线程和子线程的互动、ProgressBar 的异步调用)

           我们先来看一段运行时会抛出 InvalidOperationException 异常的代码段: private void btnThreadA_Click(object sender, ...

  7. 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing

    1.RangeBase(基类) 的示例Controls/ProgressControl/RangeBaseDemo.xaml <Page x:Class="Windows10.Cont ...

  8. div滚动条弹出层效果 (所需要的css文件和js文件,都已经上传到文件里面了progressbar.rar)

    <%--总的弹出层--%> <div class="tcck" id="joinclub" style="display:none& ...

  9. 多线程/进度条应用(progressbar)

    使用Control Sets 下的 ProgressBar - Responsive Loop控件 ProcessBar 或者 CancelBar 都可以被设置为 invisible 代码如下(分享自 ...

随机推荐

  1. 移动 Web 触摸与运动解决方案 AlloyTouch 开源啦

    传送门 Github地址:https://github.com/AlloyTeam/AlloyTouch 简介 AlloyTouch的本质是运动一个数字,把数字的物理变化映射到你想映射的任何属性上.所 ...

  2. 几款开源的图形化Redis客户端管理软件

    转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/98.html?1455870209 Redis是一个超精简的基于内存的键值 ...

  3. Eclipse 工程迁移到 Android Studio

    目标:迁移成功,并成功正常运行! 附加:同步视频在文章后面! 两种方式: 1. 用Gradle导出,在Android Studio中用Gradle导入 (不推荐) 2. 用Android Studio ...

  4. Java基础-接口中国特色社会主义的体制中有这样的现象:地方省政府要坚持党的领导和按 照国务院的指示进行安全生产。请编写一个java应用程序描述上述的体制现象。 要求如下: (1)该应用程序中有一个“党中央”接口:CentralPartyCommittee,该接口中 有个“坚持党的领导”方法:void partyLeader() (2)该应用程序中有一个“国务院”抽象类:StateCouncil,

    36.中国特色社会主义的体制中有这样的现象:地方省政府要坚持党的领导和按 照国务院的指示进行安全生产.请编写一个java应用程序描述上述的体制现象. 要求如下: (1)该应用程序中有一个“党中央”接口 ...

  5. JSP网站开发基础总结《十四》

    对于JSP的知识总结,已经为大家分享的差不多了,本篇就为大家做一下最后总结,本篇总结的主题是文件上传和下载,在之前的随笔中也有为大家分享过文件上传和下载的知识,不过都是通过JAVA提供的上传下载类实现 ...

  6. EntityFramework系列:MySql的RowVersion

    无需修改实体和配置,在MySql中使用和SqlServer一致的并发控制.修改RowVersion类型不可取,修改为Timestamp更不可行.Sql Server的RowVersion生成一串唯一的 ...

  7. Prim算法(一)之 C语言详解

    本章介绍普里姆算法.和以往一样,本文会先对普里姆算法的理论论知识进行介绍,然后给出C语言的实现.后续再分别给出C++和Java版本的实现. 目录 1. 普里姆算法介绍 2. 普里姆算法图解 3. 普里 ...

  8. c#编码规范

    1  规范目的 --------------------- 3 2  适用范围 --------------------- 3 3  代码注释 --------------------- 3 3.1  ...

  9. Javascript定时器(三)——setTimeout(func, 0)

    setTimeout(func, 0)可以使用在很多地方,拆分循环.模拟事件捕获.页面渲染等 一.setTimeout中的delay参数为0,并不是指马上执行 <script type=&quo ...

  10. Redis安装配置与Jedis访问数据库

    一.NOSQL概要 NoSQL(NoSQL = Not Only SQL ),意即“不仅仅是SQL”,泛指非关系型的数据库.NoSQL数据库的四大分类 键值(Key-Value)存储数据库 这一类数据 ...