示例#1
0
        public AdobeVerticalColourSlider()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            //	Initialize Colors
            _hsb   = new AdobeColours.HSB();
            _hsb.H = 1.0;
            _hsb.S = 1.0;
            _hsb.B = 1.0;
            _rgb   = AdobeColours.HSB_to_RGB(_hsb);
            _baseColourComponent = ColourComponent.HUE;
        }
示例#2
0
        private void ResetHSLRGB()
        {
            int red,
                green,
                blue;

            switch (_baseColourComponent)
            {
            case ColourComponent.HUE:
                _hsb.S = _markerX / 255.0;
                _hsb.B = 1.0 - _markerY / 255.0;
                _rgb   = AdobeColours.HSB_to_RGB(_hsb);
                break;

            case ColourComponent.SATURATION:
                _hsb.H = _markerX / 255.0;
                _hsb.B = 1.0 - _markerY / 255.0;
                _rgb   = AdobeColours.HSB_to_RGB(_hsb);
                break;

            case ColourComponent.BRIGHTESS:
                _hsb.H = _markerX / 255.0;
                _hsb.S = 1.0 - _markerY / 255.0;
                _rgb   = AdobeColours.HSB_to_RGB(_hsb);
                break;

            case ColourComponent.RED:
                blue  = _markerX;
                green = 255 - _markerY;
                _rgb  = Color.FromArgb(_rgb.R, green, blue);
                _hsb  = AdobeColours.RGB_to_HSB(_rgb);
                break;

            case ColourComponent.GREEN:
                blue = _markerX;
                red  = 255 - _markerY;
                _rgb = Color.FromArgb(red, _rgb.G, blue);
                _hsb = AdobeColours.RGB_to_HSB(_rgb);
                break;

            case ColourComponent.BLUE:
                red   = _markerX;
                green = 255 - _markerY;
                _rgb  = Color.FromArgb(red, green, _rgb.B);
                _hsb  = AdobeColours.RGB_to_HSB(_rgb);
                break;
            }
        }
示例#3
0
        private void DrawMarker(int x, int y, bool force)
        {
            x = x.LimitInRange(0, 255);
            y = y.LimitInRange(0, 255);

            if (_markerY == y && _markerX == x && !force)
            {
                return;
            }

            ClearMarker();

            _markerX = x;
            _markerY = y;

            Graphics g = this.CreateGraphics();

            //	The selected color determines the color of the marker drawn over
            //	it (black or white)
            Pen pen;

            AdobeColours.HSB _hsl = GetColour(x, y);
            if (_hsl.B < (double)200 / 255)
            {
                pen = new Pen(Color.White);                                                                     //	White marker if selected color is dark
            }
            else if (_hsl.H < (double)26 / 360 || _hsl.H > (double)200 / 360)
            {
                if (_hsl.S > (double)70 / 255)
                {
                    pen = new Pen(Color.White);
                }
                else
                {
                    pen = new Pen(Color.Black);                                                         //	Else use a black marker for lighter colors
                }
            }
            else
            {
                pen = new Pen(Color.Black);
            }

            g.DrawEllipse(pen, x - 3, y - 3, 10, 10); //	Draw the marker : 11 x 11 circle

            DrawBorder();                             //	Force the border to be redrawn, just in case the marker has been drawn over it.
        }
示例#4
0
        private AdobeColours.HSB GetColour(int x, int y)
        {
            AdobeColours.HSB _hsb = new AdobeColours.HSB();

            switch (_baseColourComponent)
            {
            case ColourComponent.HUE:
                _hsb.H = _hsb.H;
                _hsb.S = x / 255.0;
                _hsb.B = 1.0 - y / 255.0;
                break;

            case ColourComponent.SATURATION:
                _hsb.S = _hsb.S;
                _hsb.H = x / 255.0;
                _hsb.B = 1.0 - (double)y / 255;
                break;

            case ColourComponent.BRIGHTESS:
                _hsb.B = _hsb.B;
                _hsb.H = x / 255.0;
                _hsb.S = 1.0 - (double)y / 255;
                break;

            case ColourComponent.RED:
                _hsb = AdobeColours.RGB_to_HSB(Color.FromArgb(_rgb.R, 255 - y, x));
                break;

            case ColourComponent.GREEN:
                _hsb = AdobeColours.RGB_to_HSB(Color.FromArgb(255 - y, _rgb.G, x));
                break;

            case ColourComponent.BLUE:
                _hsb = AdobeColours.RGB_to_HSB(Color.FromArgb(x, 255 - y, _rgb.B));
                break;
            }

            return(_hsb);
        }
示例#5
0
        /// <summary>
        /// Resets the controls colour (both HSL and RGB variables) based on the current slider position
        /// </summary>
        private void ResetHSLRGB()
        {
            int height = this.Height - 9;

            switch (_baseColourComponent)
            {
            case ColourComponent.HUE:
                _hsb.H = 1.0 - (double)_markerStartY / height;
                _rgb   = AdobeColours.HSB_to_RGB(_hsb);
                break;

            case ColourComponent.SATURATION:
                _hsb.S = 1.0 - (double)_markerStartY / height;
                _rgb   = AdobeColours.HSB_to_RGB(_hsb);
                break;

            case ColourComponent.BRIGHTESS:
                _hsb.B = 1.0 - (double)_markerStartY / height;
                _rgb   = AdobeColours.HSB_to_RGB(_hsb);
                break;

            case ColourComponent.RED:
                _rgb = Color.FromArgb(255 - (int)Math.Round(255 * (double)_markerStartY / height), _rgb.G, _rgb.B);
                _hsb = AdobeColours.RGB_to_HSB(_rgb);
                break;

            case ColourComponent.GREEN:
                _rgb = Color.FromArgb(_rgb.R, 255 - (int)Math.Round(255 * (double)_markerStartY / height), _rgb.B);
                _hsb = AdobeColours.RGB_to_HSB(_rgb);
                break;

            case ColourComponent.BLUE:
                _rgb = Color.FromArgb(_rgb.R, _rgb.G, 255 - (int)Math.Round(255 * (double)_markerStartY / height));
                _hsb = AdobeColours.RGB_to_HSB(_rgb);
                break;
            }
        }