System.Windows.Forms.ColorPicker.OnPaint C# (CSharp) Method

OnPaint() protected method

protected OnPaint ( PaintEventArgs e ) : void
e PaintEventArgs
return void
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, Color)), 0, 0, Width, Height - 3);

            float alphaWidth = (float)Width * ((float)Color.A / 255);
            e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, Height - 3, Width, 3);
            e.Graphics.FillRectangle(new SolidBrush(Color.White), 0, Height - 3, alphaWidth, 3);

            var borderColor = BorderColor;
            if (Hovered) borderColor = BorderHoverColor;
            e.Graphics.DrawRectangle(new Pen(borderColor), 0, 0, Width, Height);
        }