Tuesday, April 11, 2017

Fancy Progressbar - Ver 2 - C Sharp - 170411Tu

  Fancy Progressbar - Ver 2  
.
(Demo for Progressbar, Prime numbers, Dynamic Form.)
(Written by me in c#)
Version: 170411Tu
.
Other versions:
Version Link
3.1 FG Progressbar 03.01 - 170410Mo
.
I found a Project in working folder of C# 2010 with name 'FancyProgressbar' which was written by me a few years ago. I opened it ran it and went through it's code. That project was collection of some fancy looking Progressbars. After running that project for some time I made another project for sharing here  and named it 'FancyProgressbar-02'.
.
This project is a demo project. First it demonstrates a fancy looking Progressbar. Second it demonstrates how to find prime numbers between 2 numbers with a gap of 100000000. Third it demonstrates how to create a form programmatically and use it to show Help information.
.
A simple fancy looking progressbar:
Fancy looking progressbar is actually made of one TableLayoutPanel and two Progressbars. First Progressbar with it's Style set to ProgressBarStyle.Continuous and second Progressbar with it's Style set to ProgressBarStyle.Marquee. Resultant Progressbar is made to look fancier by playing with some Properties of these 3 controls. It's use is demonstrated  during finding of prime numbers.
.
Finding Prime numbers:
Application runs a long process for finding prime numbers between 2 randomly generated numbers with a gap of 100000000 and updates fancy progressbar based on calculated percentage of work done by that process for each number it processes. Method for finding prime number is not optimized for speed or space. It is used here for having a long process for Fancy progressbar demo.
.
Creating Form programmatically:
Help information is displayed through a form created  dynamically / programmatically on the fly. First Form is created second a control is added, Label in this case, third some  properties of Form and Label are set according to needs (like Help info to Text property of Label) and fourth form with Help information is displayed.
.

Following are the screen shots of 'Fancy Progressbar - Ver 02'  application with explanation.
.
Application looks like this when it is loaded.
.

.
Application's Help form looks like this and it is displayed when 'Show Help' button is clicked. It displays some basic information about application. Working of main Form is not blocked by display of Help form. Help window uses different color on each load which it randomly selects from "Black, Blue, Green, Purple, DarkOrange, Red and DarkCyan". I used creation date of the original project in Help info.
.

.
Application looks like this when 'Start' button is clicked and application starts finding prime numbers between 2 randomly generated numbers. 'Start' button becomes disabled and 'Stop' button becomes enabled. In status line application shows that it is 'Busy...' and percentage of job done by progressbar and percentage number. It also shows number of Primes found and Primes found percentage in form.
.

.
Application looks like this when Job is completed. 'Start' button becomes enabled again and 'Stop' button becomes disabled. In status line it shows 'Done.' and Progressbar and percentage label shows that 100% job is completed. Total Primes found and Primes found percentage are shown in  different fields of form.
.

.
Application looks like this when 'Stop' button is clicked. On doing so application stops doing it's job and shows 'Stopped.' in status line. 'Start' button gets enabled and 'Stop' button gets disabled.
.

.
[Update-2017Apr12Wed]:
Today I removed some typing mistakes from this post and user-interface of application. I also made improvement to logic of application today.
.

.
Enjoy Complete Source code of application written and compiled in visual studio 2010 Ultimate by me. Download it. Extract it. Read 'ReadMeFirst.txt' file and do as is explained in it.



No comments:

Post a Comment