예제 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            g.SmoothingMode     = SmoothingMode.HighQuality;
            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            Rectangle bounds    = base.ClientRectangle;
            PointF    textPoint = new PointF();
            SizeF     textSize  = TextRenderer.MeasureText(this.multiText, this.mutiFont);

            textPoint.X
                = bounds.X + (bounds.Width - textSize.Width) / 2 - _multitextLeft;
            textPoint.Y
                = (bounds.Bottom - textSize.Height) / 2 - _multitextTop;

            // Draw highlights
            float highlight_x = textPoint.X + Del_X;
            float highlight_y = textPoint.Y + Del_Y;
            //g.DrawString(
            //    this.multiText,
            //    this.mutiFont,
            //    new SolidBrush(HighLight),    // 高光颜色
            //    highlight_x,
            //    highlight_y);

            TextShadow tShadow = new TextShadow();

            tShadow.Draw(g, this.multiText, this.mutiFont, new PointF(textPoint.X, textPoint.Y));//文字阴影

            // 绘制正常文字
            //textPoint.X -= _del_X;
            //textPoint.Y -= _del_Y;
            g.DrawString(
                this.multiText,
                this.mutiFont,
                new SolidBrush(TextColor),    // 正常颜色
                textPoint.X,
                textPoint.Y);
        }
예제 #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode     = SmoothingMode.HighQuality;
            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            //g.Clear(base.BackColor);

            switch (State)
            {
            case PushButtonState.Default:
                if (_normalImg != null)
                {
                    if (_toogle && _checked)
                    {
                        if (_downImg != null)
                        {
                            g.DrawImage(_downImg, base.ClientRectangle, new Rectangle(0, 0, _downImg.Width, _downImg.Height), GraphicsUnit.Pixel);
                        }
                    }
                    else
                    {
                        g.DrawImage(_normalImg, base.ClientRectangle, new Rectangle(0, 0, _normalImg.Width, _normalImg.Height), GraphicsUnit.Pixel);
                    }
                }
                break;

            case PushButtonState.Normal:
                if (_hoverImg != null)
                {
                    if (_toogle && _checked)
                    {
                        if (_downImg != null)
                        {
                            g.DrawImage(_downImg, base.ClientRectangle, new Rectangle(0, 0, _downImg.Width, _downImg.Height), GraphicsUnit.Pixel);
                        }
                    }
                    else
                    {
                        g.DrawImage(_hoverImg, base.ClientRectangle, new Rectangle(0, 0, _hoverImg.Width, _hoverImg.Height), GraphicsUnit.Pixel);
                    }
                }
                else
                {
                    if (_normalImg != null)
                    {
                        if (_toogle && _checked)
                        {
                            if (_downImg != null)
                            {
                                g.DrawImage(_downImg, base.ClientRectangle, new Rectangle(0, 0, _downImg.Width, _downImg.Height), GraphicsUnit.Pixel);
                            }
                        }
                        else
                        {
                            g.DrawImage(_normalImg, base.ClientRectangle, new Rectangle(0, 0, _normalImg.Width, _normalImg.Height), GraphicsUnit.Pixel);
                        }
                    }
                }
                break;

            case PushButtonState.Pressed:
                if (_downImg != null)
                {
                    g.DrawImage(_downImg, base.ClientRectangle, new Rectangle(0, 0, _downImg.Width, _downImg.Height), GraphicsUnit.Pixel);
                }
                else
                {
                    if (_normalImg != null)
                    {
                        g.DrawImage(_normalImg, base.ClientRectangle, new Rectangle(0, 0, _normalImg.Width, _normalImg.Height), GraphicsUnit.Pixel);
                    }
                }
                break;
            }

            Rectangle bounds    = base.ClientRectangle;
            PointF    textPoint = new PointF();
            SizeF     textSize  = TextRenderer.MeasureText(this.Text, this.Font);

            textPoint.X
                = bounds.X + (bounds.Width - textSize.Width) / 2 - _textLeft;
            textPoint.Y
                = (bounds.Bottom - textSize.Height) / 2 - _textTop;

            // Draw highlights
            float highlight_x = textPoint.X + _del_X;
            float highlight_y = textPoint.Y + _del_Y;
            //g.DrawString(
            //    this.Text,
            //    this.Font,
            //    new SolidBrush(_highLight),    // 高光颜色
            //    highlight_x,
            //    highlight_y);
            TextShadow tShadow = new TextShadow();

            tShadow.Draw(g, this.Text, this.Font, new PointF(textPoint.X, textPoint.Y));//文字阴影

            // 绘制正常文字
            //textPoint.X -= _del_X;
            //textPoint.Y -= _del_Y;
            g.DrawString(
                this.Text,
                this.Font,
                new SolidBrush(_textColor),    // 正常颜色
                textPoint.X,
                textPoint.Y);
        }