private void UpdateFromHSL()
        {
            double hue = (double)GetInt(hueTextBox);
            double sat = (double)GetInt(satTextBox) / satmax;
            double lum = (double)GetInt(lumTextBox) / lummax;

            hslColor = new HSColor(hue, sat, lum);
            rgbColor = hslColor.ToRGB(ColorSpace.HSL);
            SetRGBTextBoxes();
            SetGraphics();
            SetColorPanel();
        }
        private void UpdateFromRGB()
        {
            int r = GetInt(redTextBox);
            int g = GetInt(greenTextBox);
            int b = GetInt(blueTextBox);

            rgbColor = Color.FromArgb(r, g, b);
            hslColor = HSColor.RGB2HSL(rgbColor);
            SetHSLTextBoxes();
            SetGraphics();
            SetColorPanel();
        }
        /// <summary>
        ///     Set current selected color.
        /// </summary>
        /// <param name="color">Current color.</param>
        /// <returns><c>True</c>.</returns>
        public override bool SetColor(Color color)
        {
            setting++;
            alphaNud.Value = (decimal)color.A;
            setting--;

            rgbColor = Color.FromArgb(255, color);
            hslColor = HSColor.RGB2HSL(rgbColor);
            SetRGBTextBoxes();
            SetHSLTextBoxes();
            SetGraphics();
            SetColorPanel();
            return(true);
        }
        private void UpdateFromLumMouse(MouseEventArgs e)
        {
            double newLum = Math.Max(Math.Min(1.0, Y2Lum(e.Y + lumMouseOffset)), 0.0);

            hslColor = new HSColor(hslColor.Hue, hslColor.Sat, newLum);
            rgbColor = hslColor.ToRGB(ColorSpace.HSL);

            SetRGBTextBoxes();
            SetHSLTextBoxes();
            SetColorPanel();

            lumPanel.Invalidate();
            ClearLumMarker();
        }
        private void UpdateFromBitmapMouse(MouseEventArgs e)
        {
            // Calc cartesian coords
            int x   = e.X - bmMid.X;
            int y   = bmMid.Y - e.Y;
            int rad = (int)Math.Round(Math.Sqrt(x * x + y * y));

            double hue = Math.Atan2(y, x) * RadToAngle;

            if (hue < 0)
            {
                hue = 360 + hue;
            }

            // If rad is greater than bmRad, then must recalc bmX,bmY so that
            // they stay within the circle
            if (rad > bmRad)
            {
                double radRatio = (double)bmRad / (double)rad;
                bmX = (int)Math.Floor(x * radRatio) + bmMid.X;
                bmY = bmMid.Y - (int)Math.Floor(y * radRatio);
                rad = bmRad;
            }
            else
            {
                bmX = e.X;
                bmY = e.Y;
            }

            double sat = rad / (double)bmRad;

            hslColor = new HSColor(hue, sat, hslColor.Val);
            rgbColor = hslColor.ToRGB(ColorSpace.HSL);

            SetRGBTextBoxes();
            SetHSLTextBoxes();
            SetColorPanel();

            bitmapPanel.Invalidate();
            lumPanel.Invalidate();
            ClearLumMarker();
        }
 private Color GetLumColor(double lum)
 {
     return(HSColor.HSL2RGB(hslColor.Hue, hslColor.Sat, lum));
 }