Showing posts with label Happy coding. Show all posts
Showing posts with label Happy coding. Show all posts

Wednesday, March 3, 2021

Color mixer in c-Sharp - 210304Th

  Color mixer in c-Sharp  
.
Version: 210304Th
.
Other versions
Version Link
None No other versions available yet
.
.
Few months ago, one evening, I was sitting in TV lounge of our home and watching some TV program. My niece came to me and asked in her soft voice "How to know what color is made by mixing any two colors?". I said "mix any two colors and you will know". She said "No! Without mixing any colors". I tried to find and give some answer to my niece but had no idea.
.
Therefore instead of answering, somehow, I went into thoughts and started thinking how to give a useful answer to my niece. During same thinking session I wondered why not I make an application for my niece for solving this problem. An application in which my niece can mix any two colors to get the resulting color.
.
After getting this idea I started making the above mentioned application in c#. I made more than one version of the application to test the look and feel of different type of user-interface and code-logic. The version of the above mentioned application I am sharing/discussing here is n-layer based.
.
Following are some screen-shots of the above mentioned application I made in c# for my niece.
.

.
[Application Preview]
Application's preview.
.
.
.
[Application How to Use]
For selecting new color click "Choose color A" and/or "Choose color B" in menu "Action/Select colors/[Choose color A | Choose color B] or in toolbar "Choose color A | Choose color B" or in form right of "Select color" and under "Color A" and/or "Color B" boxes.
For randomly select new "Color A" and/or "Color B" click in menu "Action/Random colors/[Method 1 | Method 2]" or in toolbar's "Random color" part "Method 1" and/or "Method 2".
"Method 1" generates randomly new values for "Color A" and "Color B" and constant value "50%" for 'Color blend %" for "Color A" and "Color B". "Method 2" generates randomly new values for "Color A", "Color B" and "Color blen %" values for "Color A" and "Color B".
.

.
[Application at start]
Application in it's initializing phase. At this phase application initializes itself based on default settings and  settings saved in previous session .
.
.
.
.
[Application started]
Application's main form loaded and is ready for use.
.
.
.
[Application's menu File]
Application's menu option "File" expanded.
.
.
.
[Application's menu Action]
Application's menu option "Action" expanded.
.
.
.
[Application's mulenu Action/Select colors]
Application's menu option "Action/Select colors" expanded.
.
.
.
[Application's menu Action/Random colors]
Application's menu option "Action/Random colors" expanded.
.
.
.
[Application's menu Help]
Application's menu option "Help" expanded.
.
.
.
[Application's menu option Help/About]
Application's menu option "Help/About" clicket.
.
.
.
[Application's menu option Help/Purpose]
Application's menu option "Help/Purpose" clicked.
.
.
.
[Application's menu Help/Main form]
Application's menu option "Help/Main form" expanded.
.
.
.
[Application's menu Help/Color picker
Application's menu option "Help/Color picker" expanded.
.
.
.
[Application's menu Help/Copyright]
Application's menu "Help/Coplyright" clicked.
.
.
.
[Application's Color selecter form]
Application's Color selector/picker form displayed. In this form user can select color via Named-color, Color-picker or Comon-colors..
.
.
.
[Color selected ]
Some samples of main form after color is selected via Color selector form
.
.
.
.
.
.
.
[Application at End]
Application's in it's closing phase. At this phase application saves it's different settings and status..
.
.
.

.
Colors used for Border and Background of this post
Color HSL RGB Hex
 
306, 94%, 45% 224, 007, 203 #e007cb
 
306, 38%, 79% 222, 182, 218 #deb6da
.

.
If there are any mistakes in this post then I will remove them whenever I will know about them.
.


Thursday, October 15, 2020

GreyScale adventure with cSharp - 201015Th

  Scale adventure with c#  
.
Version: 201015Th
.
Although I had some knowledge about Grey scale colors for decades but was not very sure about them. For example following questions were comming in my mind for sometime:
  1. What is exact definition of Grey scale colors?
  2. How they are produced on digital computers?
  3. What is count of Grey scale colors?
.
For getting answer for my above mentioned questions, a few days ago, I searched on net about Grey scale colors. To see all colors which fell in Grey scale category I decided to generate all colors which fell in Grey scale category. After some planning I started to write an application in C# for generating all Grey scale colors and on completion of application I also enjoyed it's output.
.
"All Grey scale colors were in one place."
.
All colors were either Tints of Black color or Shades of White color. On the start of Grey scale color list was Black color and on the end of Grey scale list was White color and in between were shades/tints of White/Black color. In other words all colors were Shades or Tints of Grey, starting from Black and ending on White.
.
There were total of 256 colors in Grey scale colors. Each of them was produced with mixing all three primary colors (Red, Green and Blue) in same value of their intensity. For example first color (black) was produced by mixing red=0, green=0, blue=0 and last color (white) was produced by mixing red=255, green=255, blue=255 Colors. Colors in between were produced by mixing primary colors together with their intensities ranging from 1 to 254.
.
Application's UI (User Interface) is simple and easy to understand. Colors in Grey scale category are displayed in a grid of size 16*16. User can see information about color displayed in any cell/box in grid by moving mouse pointer over them. Information of cell under mouse is displayed on bottom of application form.
.
Information displayed about Grid cell under mouse pointer are:
  1. Cell (Cell number. It starts with 0).
  2. Row (Row number. It starts with 0).
  3. Col (Column number. It starts with 0).
  4. Color (Color preview).
  5. Hex (Hex of color previewed).
  6. RGB (RGB of color previewed).
.
Following are the srreen shots of the application I discused above.
.

.
Application on start looks like in the following image:
.
.
.
Application looks like in the following image when mouse is positioned over color cell of the grid:
.
.
.

.
Colors used in this post:
Border color rgb(80, 80, 80) #505050
Background color rgb(220, 220, 220) #dcdcdc
.

.
If there are any mistakes in this post then I will remove them whenever I will know about them.
.


Saturday, July 15, 2017

console barmenu -3- c sharp - 170714Fr

  Console BarMenu - 3  
.
(DOS era text-mode style Colorful Bar-Menu in c#)
Version: 170714Fr
.
During the era of DOS 3, creating a bar menu in text or graphic mode was a cutting-edge topic in programming. I vividly remember writing a ".prg" program in dBase III Plus on my institute's PC, which impressed my friends, lab assistants, and teachers. That program was my first attempt at creating a bar menu, and I'm proud to say it was a success. Although I'm not sure if the printout of that program still exists in my archives, I'm not eager to find out also. In memory of that bar menu, I've now recreated that bar menu as a Console project in C#.
.
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.
.

.
Code of "Console BarMenu - 3" in Visual C# 2010
.

.
Application Output
Following are some screen-shots of the application I took at different state of application to explain the application's look and feel.
.
Application is loaded
(When Application is loaded.)
.
.
Application Menu bar navigation
(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)
.
.
Application Menu item selected
When menu's any selection bar is selected by pressing ENTER key and application is moved to the respective section.
.
(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.
.

.
A brief overview of Console application:
In the context of C#, a Console Application is a type of program that interacts with users through the command-line interface. This type of application reads input from the user through the standard input stream (STDIN), processes the input, and then displays output to the user through the standard output stream (STDOUT). Additionally, any error messages or exceptions are directed to the standard error stream (STDERR). Console Applications are commonly used for tasks that require user input, such as command-line tools, utilities, and interactive programs. They provide a simple and efficient way to interact with the user, making them a fundamental part of the C# programming landscape.
.

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