ConsoleColor Demo - 2
|
. |
(Displays all foreground colors on all background colors in c#) |
Version: 170703Mo |
. |
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 |
|
Next Color |
UpArrow |
PageUp |
LeftArrow |
Backspace |
E |
NumPad8 |
NumPad9 |
NumPad4 |
|
S |
|
Previous Color |
DownArrow |
PageDown |
RightArrow |
Spacebar |
D |
NumPad2 |
NumPad3 |
NumPad6 |
|
F |
|
First Color |
|
Last Color |
|
|
. |
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 |
Following are screenshots of the application I took at different stages of application. |
. |
(When Application is loaded.) |
|
. |
(When Background color is Black) |
|
. |
(When Background color is Blue) |
|
. |
(When Background color is Cyan) |
|
. |
(When Background color is DarkBlue) |
|
. |
(When Background color is DarkCyan) |
|
. |
(When Background color is DarkGray) |
|
. |
(When Background color is DarkGreen) |
|
. |
(When Background color is DarkMagenta) |
|
. |
(When Background color is DarkRed) |
|
. |
(When Background color is DarkYellow) |
|
. |
(When Background color is Gray) |
|
. |
(When Background color is Green) |
|
. |
(When Background color is Magenta) |
|
. |
(When Background color is Red) |
|
. |
(When Background color is White) |
|
. |
(When Background color is Yellow) |
|
. |
|
. |
[2024 July 29 Thu] Note:-
Previously I had shared three sample screen shots of the application and today I
removed those images and shared 17 new screen-shots of application in it's all
possible stages.. |
. |
|
. |
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.
|
No comments:
Post a Comment