Beispiel #1
0
        private void colorSquare_MouseMove(object sender, MouseEventArgs e)
        {
            if (_squareSelected)
            {
                int x = Math.Min(Math.Max(e.X, 0), colorSquare.Width);
                int y = Math.Min(Math.Max(e.Y, 0), colorSquare.Height);
                if (!huePanel.Enabled)
                {
                    y = colorSquare.Height;
                }

                if ((x != _squareX) || (y != _squareY))
                {
                    _hsv.V = (byte)((float)x / colorSquare.Width * 100);
                    _hsv.S = (byte)((float)(colorSquare.Height - y) / colorSquare.Height * 100);

                    OnColorChanged(true);

                    if (!huePanel.Enabled)
                    {
                        Alpha = _color.R;
                        alphaPanel.Invalidate();
                    }
                }
            }
        }
Beispiel #2
0
        protected virtual void OnColorChanged(bool hsvToRgb)
        {
            colorSquare.Invalidate();
            huePanel.Invalidate();

            if (hsvToRgb)
            {
                _color = _hsv.ToRGBA();
            }
            else
            {
                _hsv = HSVPixel.FromRGBA(_color);
            }

            if (ColorChanged != null)
            {
                ColorChanged(this, null);
            }
        }