private void ApplyColor()
{
// Retrieve the current hexadecimal colors from their Edit controls
HexBG = this.txtBackground.Text;
HexText = this.txtText.Text;
HexLink = this.txtLink.Text;
HexALink = this.txtActiveLink.Text;
HexVLink = this.txtVisitedLink.Text;
// Get the integral position of each ScrollBar control
String strRed = Convert.ToString(255 - this.scrRed.Value);
String strGreen = Convert.ToString(255 - this.scrGreen.Value);
String strBlue = Convert.ToString(255 - this.scrBlue.Value);
// Display the position of each ScrollBar
// in its corresponding Edit control
this.txtRed.Text = strRed;
this.txtGreen.Text = strGreen;
this.txtBlue.Text = strBlue;
// Change the color of the Preview panel
// according to the values of the ScrollBar positions
pnlPreview.BackColor = System.Drawing.Color.FromArgb(scrRed.Value, scrGreen.Value, scrBlue.Value);
String FmtRed = (255 - scrRed.Value).ToString("X");
if( FmtRed.Length == 1 )
FmtRed = String.Concat("0", FmtRed);
String FmtGreen = (255 - scrGreen.Value).ToString("X");
if( FmtGreen.Length == 1 )
FmtGreen = String.Concat("0", FmtGreen);
String FmtBlue = (255 - scrBlue.Value).ToString("X");
if( FmtBlue.Length == 1 )
FmtBlue = String.Concat("0", FmtBlue);
// Get the position of each ScrollBar control
// Create a hexadecimal color starting with #
// And display the color in the appropriate Edit control
if( rdoBackground.Checked == true )
{
String BG = "#";
BG = String.Concat(BG, FmtRed);
BG = String.Concat(BG, FmtGreen);
BG = String.Concat(BG, FmtBlue);
txtBackground.Text = BG;
pnlBody.BackColor = pnlPreview.BackColor;
txtTextPreview.BackColor = pnlPreview.BackColor;
txtLinkPreview.BackColor = pnlPreview.BackColor;
txtALinkPreview.BackColor = pnlPreview.BackColor;
txtVLinkPreview.BackColor = pnlPreview.BackColor;
HexBG = txtBackground.Text;
}
else if( rdoText.Checked == true )
{
String Txt = "#";
Txt = String.Concat(Txt, FmtRed);
Txt = String.Concat(Txt, FmtGreen);
Txt = String.Concat(Txt, FmtBlue);
txtText.Text = Txt;
txtTextPreview.ForeColor = System.Drawing.Color.FromArgb(scrRed.Value, scrGreen.Value, scrBlue.Value);
HexText = txtText.Text;
}
else if( rdoLink.Checked == true )
{
String TL = "#";
TL = String.Concat(TL, FmtRed);
TL = String.Concat(TL, FmtGreen);
TL = String.Concat(TL, FmtBlue);
txtLink.Text = TL;
txtLinkPreview.ForeColor = System.Drawing.Color.FromArgb(scrRed.Value, scrGreen.Value, scrBlue.Value);
HexLink = txtLink.Text;
}
else if( rdoActiveLink.Checked == true )
{
String AL = "#";
AL = String.Concat(AL, FmtRed);
AL = String.Concat(AL, FmtGreen);
AL = String.Concat(AL, FmtBlue);
txtActiveLink.Text = AL;
txtALinkPreview.ForeColor = System.Drawing.Color.FromArgb(scrRed.Value, scrGreen.Value, scrBlue.Value);
HexALink = txtActiveLink.Text;
}
else if( rdoVisitedLink.Checked == true )
{
String VL = "#";
VL = String.Concat(VL, FmtRed);
VL = String.Concat(VL, FmtGreen);
VL = String.Concat(VL, FmtBlue);
txtVisitedLink.Text = VL;
txtVLinkPreview.ForeColor = System.Drawing.Color.FromArgb(scrRed.Value, scrGreen.Value, scrBlue.Value);
HexVLink = txtVisitedLink.Text;
}
// Update the contents of the bottom Edit control
String BD = "<body bgcolor=\"";
BD = String.Concat(BD, HexBG);
BD = String.Concat(BD, "\" text=\"");
BD = String.Concat(BD, HexText);
BD = String.Concat(BD, "\" link=\"");
BD = String.Concat(BD, HexLink);
BD = String.Concat(BD, "\" alink=\"");
BD = String.Concat(BD, HexALink);
BD = String.Concat(BD, "\" vlink=\"");
BD = String.Concat(BD, HexVLink);
BD = String.Concat(BD, "\">");
txtResult.Text = BD;
}
|