Exemplo n.º 1
0
        protected void GetBoxColor()
        {
            switch (DrawStyle)
            {
            // HSB Color Space
            case DrawStyles.HSBHue:
                selectedColor.HSB.Saturation = (float)lastClicked.X / clientWidth;
                selectedColor.HSB.Brightness = (float)(1.0 - ((double)lastClicked.Y / clientHeight));
                selectedColor.UpdateHSB();
                break;

            case DrawStyles.HSBSaturation:
                selectedColor.HSB.Hue        = (float)lastClicked.X / clientWidth;
                selectedColor.HSB.Brightness = (float)(1.0 - ((double)lastClicked.Y / clientHeight));
                selectedColor.UpdateHSB();
                break;

            case DrawStyles.HSBBrightness:
                selectedColor.HSB.Hue        = (float)lastClicked.X / clientWidth;
                selectedColor.HSB.Saturation = (float)(1.0 - ((double)lastClicked.Y / clientHeight));
                selectedColor.UpdateHSB();
                break;

            // HSL Color Space
            case DrawStyles.HSLHue:
                selectedColor.HSL.Saturation = (float)lastClicked.X / clientWidth;
                selectedColor.HSL.Lightness  = (float)(1.0 - ((double)lastClicked.Y / clientHeight));
                selectedColor.UpdateHSL();
                break;

            case DrawStyles.HSLSaturation:
                selectedColor.HSL.Hue       = (float)lastClicked.X / clientWidth;
                selectedColor.HSL.Lightness = (float)(1.0 - ((double)lastClicked.Y / clientHeight));
                selectedColor.UpdateHSL();
                break;

            case DrawStyles.HSLLightness:
                selectedColor.HSL.Hue        = (float)lastClicked.X / clientWidth;
                selectedColor.HSL.Saturation = (float)(1.0 - ((double)lastClicked.Y / clientHeight));
                selectedColor.UpdateHSL();
                break;

            // RGB Color Space
            case DrawStyles.Red:
                selectedColor.ARGB.B = (byte)Math.Round(255 * (double)lastClicked.X / (clientWidth));
                selectedColor.ARGB.G = (byte)Math.Round(255 * (1.0 - ((double)lastClicked.Y / (clientHeight))));
                selectedColor.UpdateARGB();
                break;

            case DrawStyles.Green:
                selectedColor.ARGB.B = (byte)Math.Round(255 * (double)lastClicked.X / (clientWidth));
                selectedColor.ARGB.R = (byte)Math.Round(255 * (1.0 - ((double)lastClicked.Y / (clientHeight))));
                selectedColor.UpdateARGB();
                break;

            case DrawStyles.Blue:
                selectedColor.ARGB.R = (byte)Math.Round(255 * (double)lastClicked.X / (clientWidth));
                selectedColor.ARGB.G = (byte)Math.Round(255 * (1.0 - ((double)lastClicked.Y / (clientHeight))));
                selectedColor.UpdateARGB();
                break;
            }
        }