Introduction
ColorCoder2
is the second version of my HEX & HTML Color wizard.
It is particularly useful in the Web and graphics design industry because it makes light work of RGB, HEX and HTML color codes. It also features an integrated clipboard manager that can store and monitor your clipboard entries as well as convert the color entry on-the-fly.
ColorCoder2
makes use of the Desktop Color Picker Application by Code Project User nd1279.
Using the Code
The code is formatted into different blocks of functions.
The following block converts the RGB colour values to hex and sets the control values:
private void changeColor(string hexValue)
{
colorLabel.Text = "";
try
{
int tmpRed = 0;
int tmpGreen = 0;
int tmpBlue = 0;
tmpRed = Convert.ToInt32(hexValue.Substring(0, 2), 16);
if (hexValue.Length >= 4)
{
tmpGreen = Convert.ToInt32(hexValue.Substring(2, 2), 16);
if (hexValue.Length >= 6)
{
tmpBlue = Convert.ToInt32(hexValue.Substring(4, 2), 16);
}
}
colorLabel.BackColor = Color.FromArgb(255, tmpRed, tmpGreen, tmpBlue);
redSelector.Value = tmpRed;
redLbl.Text = tmpRed.ToString();
redValue = tmpRed;
greenSelector.Value = tmpGreen;
greenLbl.Text = tmpGreen.ToString();
greenValue = tmpGreen;
blueSelector.Value = tmpBlue;
blueLbl.Text = tmpBlue.ToString();
blueValue = tmpBlue;
hexTxt.Text = hexValue;
htmlTxt.Text = "#" + hexValue;
rgbTxt.Text = "" + tmpRed + "," + tmpGreen + "," + tmpBlue;
colorLabel.Text = hexTxt.Text;
}
catch (Exception ex)
{
colorLabel.BackColor = Color.White;
colorLabel.Text = "Invalid Format";
Console.WriteLine(ex.Message);
}
}
Points of Interest
This application also makes use of the process class that monitors an external application and sets some values if the application is terminated.
History
- 3rd March, 2008: Initial post
Since this is version 2 and I never posted version 1, it is as up-to-date as it can be.
Any suggestions and addons are welcome.