Accord.Controls.ColorSlider.ColorSlider_Paint C# (CSharp) Метод

ColorSlider_Paint() приватный Метод

private ColorSlider_Paint ( object sender, PaintEventArgs e ) : void
sender object
e PaintEventArgs
Результат void
        private void ColorSlider_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Rectangle rc = this.ClientRectangle;
            Brush brush;
            int x = (rc.Right - width) / 2;
            int y = 2;

            // draw rectangle around the control
            g.DrawRectangle(blackPen, x - 1, y - 1, width + 1, height + 1);

            switch (type)
            {
                case ColorSliderType.Gradient:
                case ColorSliderType.InnerGradient:
                case ColorSliderType.OuterGradient:

                    // create gradient brush
                    brush = new LinearGradientBrush(new Point(x, 0), new Point(x + width, 0), startColor, endColor);
                    g.FillRectangle(brush, x, y, width, height);
                    brush.Dispose();

                    // check type
                    if (type == ColorSliderType.InnerGradient)
                    {
                        // inner gradient
                        brush = new SolidBrush(fillColor);

                        if (min != 0)
                        {
                            g.FillRectangle(brush, x, y, min, height);
                        }
                        if (max != 255)
                        {
                            g.FillRectangle(brush, x + max + 1, y, 255 - max, height);
                        }
                        brush.Dispose();
                    }
                    else if (type == ColorSliderType.OuterGradient)
                    {
                        // outer gradient
                        brush = new SolidBrush(fillColor);
                        // fill space between min & max with color 3
                        g.FillRectangle(brush, x + min, y, max - min + 1, height);
                        brush.Dispose();
                    }
                    break;
                case ColorSliderType.Threshold:
                    // 1 - fill with color 1
                    brush = new SolidBrush(startColor);
                    g.FillRectangle(brush, x, y, width, height);
                    brush.Dispose();
                    // 2 - fill space between min & max with color 2
                    brush = new SolidBrush(endColor);
                    g.FillRectangle(brush, x + min, y, max - min + 1, height);
                    brush.Dispose();
                    break;
            }


            // draw arrows
            x -= 4;
            y += 1 + height;

            g.DrawImage(arrow, x + min, y, 9, 6);
            if (doubleArrow)
                g.DrawImage(arrow, x + max, y, 9, 6);
        }