Color Selector from RGBA Color Model

Description:
About Classes used –
#1: An object of Color class, stores a 32-bit value that represents a color.
       The color value contains four, 8-bit components: Alpha, Red, Green, and Blue.
Namespace Required – System.Drawing
Here I implemented the Code for enlisting the properties of running processes of the local system.
Controls used:
1.    TextBox Control (txtRed, txtGreen, txtBlue, txtAlpha)
2.    TrackBar Control (RedValue, GreenValue, BlueValue, AlphaValue)
           
The Code: (do necessary changes)
1. Create a function with return type Color, which returns a color from RGBA Model.
            Color SelectColor()
            {
                  int r = Convert.ToInt16(RedValue.Value);        //Red Color
                  int g = Convert.ToInt16(GreenValue.Value);      //Green Color
                  int b = Convert.ToInt16(BlueValue.Value);       //Blue Color
                  int a = Convert.ToInt16(AlphaValue.Value);      //Alpha Color
                 
                  return Color.FromArgb(a, r, g, b); //Returns a RGBA Color
            }
Listing 1
2. Now you can pass the Color value from this Function to any control.
(Here I used it for a PictureBox Control)(Note: – Default Color for PictureBox Control is Transparent)
3. Now execute the Application and see the result (Figure 1).
         
Intended Result:
Figure 1
Summary:
          In this piece of writing, using C# environment, we have seen a method to select a color from RGBA Color model.

Regards,
Mayur Dighe
http://ImmortalDotNet.blogspot.com
http://MayurDighe.wordpress.com