Пример #1
0
 public void Draw(Graphics g, ColorHandler.RGB RGB)
 {
     // Given RGB values, calculate HSV and then update the screen.
     this.g   = g;
     this.HSV = ColorHandler.RGBtoHSV(RGB);
     CalcCoordsAndUpdate(this.HSV);
     UpdateDisplay();
 }
 private void HandleRGBChange(object sender, System.EventArgs e)
 {
     // If the R, G, or B values change, use this
     // code to update the HSV values and invalidate
     // the color wheel (so it updates the pointers).
     // Check the isInUpdate flag to avoid recursive events
     // when you update the NumericUpdownControls.
     if (!isInUpdate)
     {
         changeType = ChangeStyle.RGB;
         RGB        = new ColorHandler.RGB((int)numericUpDownRed.Value, (int)numericUpDownGreen.Value, (int)numericUpDownBlue.Value);
         SetHSV(ColorHandler.RGBtoHSV(RGB));
         this.OnColorChanged();
         this.Invalidate();
     }
 }
 private void textBoxHexColor_Leave(object sender, EventArgs e)
 {
     try
     {
         if (!isInUpdate)
         {
             Color c = ColorTranslator.FromHtml(textBoxHexColor.Text);
             this.Color = c;
             SetRGB(new ColorHandler.RGB(c.R, c.G, c.B));
             SetHSV(ColorHandler.RGBtoHSV(RGB));
             this.OnColorChanged();
             this.Invalidate();
         }
     }
     catch
     {
         textBoxHexColor.Text = "#" + Color.R.ToString("x").PadLeft(2, '0') + Color.G.ToString("x").PadLeft(2, '0') + Color.B.ToString("x").PadLeft(2, '0');
     }
 }