Example #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle rc = this.ClientRectangle;
            Graphics  g  = e.Graphics;

            ImageDrawRect.DrawRect(g, _TextBoxBackImg, rc, Rectangle.FromLTRB(10, 10, 10, 10), (int)state, 5);
            if (_Isico)
            {
                if (_Ico != null)
                {
                    g.DrawImage(_Ico, new Point(_IcoPadding.Left, _IcoPadding.Top));
                }
            }
            base.OnPaint(e);
        }
Example #2
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);
            base.OnPaintBackground(e);
            if (_BackImg == null)
            {
                base.OnPaint(e);
                return;
            }

            int i = (int)state;

            if (!this.Enabled)
            {
                i = 4;
            }
            if (this.CheckState == CheckState.Checked)
            {
                i += 4;
            }
            if (this.CheckState == CheckState.Indeterminate)
            {
                i += 8;
            }

            Rectangle rc = this.ClientRectangle;
            Rectangle r1 = rc;
            Rectangle textRect;
            Graphics  g = e.Graphics;

            if (this.CheckAlign == ContentAlignment.MiddleLeft)//对齐状态
            {
                r1       = new Rectangle(0, (rc.Height - 15) / 2, 16, 15);
                textRect = new Rectangle(16, 0, rc.Width - 16, rc.Height);
            }
            else
            {
                r1       = new Rectangle(r1.Right - 16, (rc.Height - 16) / 2, 16, 15);
                textRect = new Rectangle(0, 0, rc.Width - 16, rc.Height);
            }
            ImageDrawRect.DrawRect(g, _BackImg, r1, Rectangle.FromLTRB(0, 0, 0, 0), i, 12);
            Color textColor = Enabled ? ForeColor : SystemColors.GrayText;

            TextRenderer.DrawText(e.Graphics, this.Text, this.Font, textRect, textColor);
        }