private void ColorChooser_Load(object sender, System.EventArgs e) { DRColor.HSV default_color = new DRColor.HSV(127, 256, 82); // Turn on double-buffering, so the form looks better. this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.DoubleBuffer, true); // These properties are set in design view, as well, but they // have to be set to false in order for the Paint // event to be able to display their contents. // Never hurts to make sure they're invisible. pnlSelectedColor.Visible = false; pnlBrightness.Visible = false; pnlColor.Visible = false; // Calculate the coordinates of the three // required regions on the form. Rectangle SelectedColorRectangle = new Rectangle(pnlSelectedColor.Location, pnlSelectedColor.Size); Rectangle BrightnessRectangle = new Rectangle(pnlBrightness.Location, pnlBrightness.Size); Rectangle ColorRectangle = new Rectangle(pnlColor.Location, pnlColor.Size); // Create the new ColorWheel class, indicating // the locations of the color wheel itself, the // brightness area, and the position of the selected color. myColorWheel = new ColorWheel(ColorRectangle, BrightnessRectangle, SelectedColorRectangle, default_color); myColorWheel.ColorChanged += new ColorWheel.ColorChangedEventHandler(this.colorWheel_Changed); // Set the RGB and HSV values // of the NumericUpDown controls. SetRGB(new DRColor.RGB(default_color)); SetHSV(default_color); }
// If the H, S, or V values change, use this // code to update the RGB values and invalidate // the color wheel (so it updates the pointers). // Check the isInUpdate flag to avoid recursive events // when you update the NumericUpdownControls. private void HandleHSVScroll(object sender, ScrollEventArgs e) { _changeType = ChangeStyle.HSV; HSV = new DRColor.HSV(hsbHue.Value, hsbSaturation.Value, hsbBrightness.Value); SetRGB(new DRColor.RGB(HSV)); SetHSVLabels(HSV); this.Invalidate(); RainbowUtils.fillBoth(RGB); }
private void SetHSV(DRColor.HSV HSV) { if (HSV == null) { return; } // Update the HSV values on the form. RefreshValue(hsbHue, HSV.Hue); RefreshValue(hsbSaturation, HSV.Saturation); RefreshValue(hsbBrightness, HSV.Value); SetHSVLabels(HSV); }
private void SetHSVLabels(DRColor.HSV HSV) { RefreshText(lblHue, HSV.Hue); RefreshText(lblSaturation, HSV.Saturation); RefreshText(lblBrightness, HSV.Value); }