FC3Editor.UI.NomadCheckButton.OnPaint C# (CSharp) Method

OnPaint() protected method

protected OnPaint ( PaintEventArgs pevent ) : void
pevent PaintEventArgs
return void
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics graphics = pevent.Graphics;
            ButtonShader buttonShader = ButtonShader.normalShader;
            if (this.mouseOver)
            {
                buttonShader = ButtonShader.hoverShader;
            }
            if (this.pushed)
            {
                buttonShader = ButtonShader.pushShader;
            }
            if (base.Checked)
            {
                buttonShader = NomadCheckButton.checkShader;
            }
            if (!base.Enabled)
            {
                buttonShader = ButtonShader.disableShader;
            }
            Rectangle clientRectangle = base.ClientRectangle;
            using (Pen pen = new Pen(this.BackColor))
            {
                graphics.DrawRectangle(pen, clientRectangle.X, clientRectangle.Y, clientRectangle.Width - 1, clientRectangle.Height - 1);
            }
            clientRectangle.Inflate(-1, -1);
            buttonShader.DrawButton(graphics, clientRectangle, this.BackColor);
            if (base.Image != null)
            {
                ImageAttributes imageAttributes = new ImageAttributes();
                if (!base.Enabled)
                {
                    imageAttributes.SetColorMatrix(NomadButton.disableMatrix);
                }
                Rectangle destRect = new Rectangle(clientRectangle.X + (clientRectangle.Width - base.Image.Width) / 2, clientRectangle.Y + (clientRectangle.Height - base.Image.Height) / 2, base.Image.Width, base.Image.Height);
                graphics.DrawImage(base.Image, destRect, 0, 0, base.Image.Width, base.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                return;
            }
            Rectangle rect = clientRectangle;
            Color controlText = SystemColors.ControlText;
            if (!base.Enabled)
            {
                controlText = NomadCheckButton.disableText;
            }
            buttonShader.DrawText(graphics, rect, this.Text, this.Font, controlText);
        }