Example #1
0
        private void CalcCoordsAndUpdate(ColorHandler.HSV HSV)
        {
            // Convert color to real-world coordinates and then calculate
            // the various points. HSV.Hue represents the degrees (0 to 360),
            // HSV.Saturation represents the radius.
            // This procedure doesn't draw anything--it simply
            // updates class-level variables. The UpdateDisplay
            // procedure uses these values to update the screen.

            // Given the angle (HSV.Hue), and distance from
            // the center (HSV.Saturation), and the center,
            // calculate the point corresponding to
            // the selected color, on the color wheel.
            colorPoint = GetPoint((double)HSV.Hue / 255 * 360,
                                  (double)HSV.Saturation / 255 * radius,
                                  centerPoint);

            // Given the brightness (HSV.value), calculate the
            // point corresponding to the brightness indicator.
            brightnessPoint = CalcBrightnessPoint(HSV.value);

            // Store information about the selected color.
            brightness    = HSV.value;
            selectedColor = ColorHandler.HSVtoColor(HSV);
            RGB           = ColorHandler.HSVtoRGB(HSV);

            // The full color is the same as HSV, except that the
            // brightness is set to full (255). This is the top-most
            // color in the brightness gradient.
            fullColor = ColorHandler.HSVtoColor(HSV.Hue, HSV.Saturation, 255);
        }
Example #2
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();
 }
Example #3
0
 public void Draw(Graphics g, ColorHandler.HSV HSV)
 {
     // Given HSV values, update the screen.
     this.g   = g;
     this.HSV = HSV;
     CalcCoordsAndUpdate(this.HSV);
     UpdateDisplay();
 }
Example #4
0
 private void SetHSV(ColorHandler.HSV HSV)
 {
     // Update the HSV values on the form, but don't trigger
     // the ValueChanged event of the form. The isInUpdate
     // variable ensures that the event procedures
     // exit without doing anything.
     isInUpdate = true;
     RefreshValue(nudHue, HSV.Hue);
     RefreshValue(nudSaturation, HSV.Saturation);
     RefreshValue(nudBrightness, HSV.value);
     isInUpdate = false;
 }
Example #5
0
 private void HandleHSVChange(object sender, EventArgs e)
 {
     // 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.
     if (!isInUpdate)
     {
         changeType = ChangeStyle.HSV;
         HSV        = new ColorHandler.HSV((int)(nudHue.Value), (int)(nudSaturation.Value), (int)(nudBrightness.Value));
         SetRGB(ColorHandler.HSVtoRGB(HSV));
         this.Invalidate();
     }
 }
Example #6
0
        protected void OnColorChanged(ColorHandler.RGB RGB, ColorHandler.HSV HSV)
        {
            ColorChangedEventArgs e = new ColorChangedEventArgs(RGB, HSV);

            ColorChanged(this, e);
        }
Example #7
0
 public ColorChangedEventArgs(ColorHandler.RGB RGB, ColorHandler.HSV HSV)
 {
     mRGB = RGB;
     mHSV = HSV;
 }