Monday, July 31, 2017

Happy 5000 PageViews - (2017 Jul 31 Mon)


. . . . .
. . . . .
. .
C O N G R A T U L A T I O N S
Today
On 2017 Jul 31 Mon
my this Blog reached 5000 page views mark.
A lot of THANKS to
Visitors, Viewers, Readers and Wanderers.
Please keep visiting this blog
and
Tell others about it.
Congratulations to me also.
. .
. . . . .
. . . . .

Saturday, July 15, 2017

Console BarMenu - 3 - C Sharp

Console BarMenu - 3
(DOS era text-mode style Colorful Bar-Menu in c#)
.
A few decades ago during time of DOS 3 days making bar-menu in text or graphic mode was an advance cum fancy topic. What I remember now I then wrote a .prg program for making 'bar-menu' in 'dBase III Plus' on PC of institute and also impressed my friends, lab assistants and teachers. That .prg was first program I wrote for making bar-menu. Now it's print-out is still available in my archive of old print-outs or not I do not know. I am not trying to know either. So in memory of that 'Bar-Menu' program, I made for the first time in 'dBase III Plus' then, I made a Console project in C Sharp now.
Salient  features of above mentioned c# project are as follows:
(A) Display bar-menu.
(B) Provide menu-item selection mechanism through navigation keys like Up-arrow, Down-arrow, Home, End and Enter keys.
(C) Process menu-item selection and perform action accordingly.
(D) Return back to menu at end of action processed.
(E) Provide mechanism for exiting from 'bar-menu' and application.
.
Then I tried and made the above required project. Code for achieving above task is simple and is described as follows.
(1) First menu processing method is called. There must be one such method per menu.
(2) Then from menu processing method menu-driver method is called with information like menu-item-list etc.
(3) Then in menu-driver things happen in following sequence:
(3a) First menu is displayed.
(3b) Then user-input is taken.
(3c) Then user-input is processed based on input key as follows:
(3c1) Navigation key: Selected menuitem index is updated.
(3c2) Enter key: Current menuitem index is selected for returning.
(3c3) Escape key: Menu exit code is selected for returning.
(3c4) If user input is not Escape-Key or Enter-Key go back to step 3a.
(3c5) Menu-driver exits when user-input is Escape-Key or Enter-Key.
(4) Back in menu processing method returned value is processed as follows:
(4a) Respective methods are called according to returned value. On return control goes back to step 2.
(4b) Else menu exits when selection code is Escape-Key.
.
Keys used by menu are displayed in menu footer and are described in the following:
Navigation:
Down-arrow key for next menuitem.
Up-arrow key for previous menuitem.
Home key for First menuitem.
End key for last menuitem.
Selection:
Ente key for selecting current menuitem.
Exit:
Escape key for exiting menu.
.
Following is the C# code of the project I described above. It is not so simple or easy to understand. But it is full of helpful comments throughout it.
.

.
Visual C# 2010 Code
.

.
Application Output
(When selection bar is on first menu-item)
.
(When selection bar is on last menu-item)
.
(When selection bar is on some other menu-item)
.
(When 'Grains and cereals' menu-item is selected and respective method is run)
.
(When 'Vegetables' menu-item is selected and respective method is run)
.
(When 'Bakery & Confectionery Products' menu-item is selected and respective method is run)
.
Method which displays message based on menu selection,  randomly selects background for console screen from a few dark ConsoleColors making display a little colorful.
If there are any mistakes then I will surely remove them whenever found.

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.
.


Monday, July 3, 2017

ConsoleColor Demo - 2 - C Sharp

ConsoleColor Demo - 2
(All foreground colors on all background colors in c#)
.
To check how text in any possible foreground ConsoleColor on any possible background ConsoleColor looks like I made a Console project in C Sharp. I also made basic requirement for the project as this:
(A) Display line of text in all ConsoleColors in its default sequence using one line for one color.
(B) Use navigation keys to change console background color in ConsoleColor default sequence, in any direction.
(C) Provide mechanism for exiting from application.
.
Then I tried and made the above required project. Code for achieving above task is simple and is described as follows.
(1) First all ConsoleColors are saved in an array in their default sequence.
(2) Then a do-while loop starts.
(3) In start of this loop console background color is set to first color in ConsoleColor array and console is cleared.
(*) Application also displays useful information near top and bottom of screen on black bars. At top current background color is also displayed. Both info-bars are displayd from inside of do-while loop at different places.
(4) Then in a for loop all alphabets in upper case then all digits then all alphabets in lower case are displayed  in all colors from ConsoleColor array, using one line for text in one color.
(5) Then user input is taken and according to input:
(5a) Console background color index is changed as follows:
(*) Up-arrow, Backspace, Left-arrow, Page-Up, E, S, NumPad8, NumPad4 and NumPad9 keys are used for selecting previous  color in ConsoleColor array. 
(*) Down-arrow, Spacebar, Right-arrow, Page-Down, D, F, NumPad2, NumPad6 and NumPad3 keys are used for selecting next color in ConsoleColor array.
(*) Home and NumPad7 key is used for selecting first color in ConsoleColor array
(*) End and NumPad1 key is used for selecting last color in ConsoleColor array.
(5b) In step 2 started do-while loop either continues or Exit. X and Escape keys are used for exiting loop.
(6) After loop exit application also ends after restoring defaults.
.
In the following table keys which can be used for performing different tasks are listed.
Navigation Keys
Action Keys
Exit
X Escape
Next Color
UpArrow PageUp LeftArrow Backspace E
NumPad8 NumPad9 NumPad4 S
Previous Color
DownArrow PageDown RightArrow Spacebar D
NumPad2 NumPad3 NumPad6 F
First Color
Home NumPad7
Last Color
End NumPad1
.
Exit is for exiting application. Remaining tasks are for selecting background console color. No matter 'Num Lok' key is on or off its buttons will work in same way for navigation.
Following is the C# code of the project I described above. It is simple and easy to understand. Plus it is full of helpful comments throughout it.
.

.
Visual C# 2010 Code
.

.
Application Output
(When Background color is Gray)
.
(When Background color is Yellow)
.
(When Background color is Cyan)
.
If there are any mistakes then I will surely remove them whenever found.

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.
.