Esempio n. 1
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            ToolStrip     toolStrip = e.ToolStrip;
            ToolStripItem item      = e.Item;

            if (toolStrip is ToolStripDropDown)
            {
                e.TextColor = item.Selected ? this.ColorTable.HoverFore : this.ColorTable.Fore;
            }
            else
            {
                e.TextColor = item.Selected ? this.ColorTable.BaseHoverFore : this.ColorTable.BaseFore;
            }
            if ((toolStrip is ToolStripDropDown) && (e.Item is ToolStripMenuItem))
            {
                Rectangle textRectangle = e.TextRectangle;
                e.TextRectangle = textRectangle;
            }
            if ((!(toolStrip is ToolStripDropDown) && this.ColorTable.BaseForeAnamorphosis) && !string.IsNullOrEmpty(e.Item.Text))
            {
                Graphics graphics = e.Graphics;
                Image    image    = SkinTools.ImageLightEffect(e.Item.Text, e.Item.Font, e.TextColor, this.ColorTable.BaseForeAnamorphosisColor, this.ColorTable.BaseForeAnamorphosisBorder);
                graphics.DrawImage(image, (int)(e.TextRectangle.Left - (this.ColorTable.BaseForeAnamorphosisBorder / 2)), (int)(e.TextRectangle.Top - (this.ColorTable.BaseForeAnamorphosisBorder / 2)));
            }
            else
            {
                base.OnRenderItemText(e);
            }
        }
 //画标题
 private void DrawCaptionText(
     Graphics g, Rectangle textRect, string text, Font font, TitleType Effect, Color EffetBack, int EffectWidth, Color FrmColor, Point TitleOffset)
 {
     if (Effect == TitleType.EffectTitle)
     {
         Size  txtsize = TextRenderer.MeasureText(text, font);
         Image imgtext = SkinTools.ImageLightEffect(text, font, FrmColor, EffetBack, EffectWidth, new Rectangle(0, 0, textRect.Width, txtsize.Height), true);
         g.DrawImage(imgtext, textRect.X - EffectWidth / 2 + TitleOffset.X, textRect.Y - EffectWidth / 2 + TitleOffset.Y
                     );
     }
     else if (Effect == TitleType.Title)
     {
         textRect.X += TitleOffset.X;
         textRect.Y += TitleOffset.Y;
         TextRenderer.DrawText(
             g,
             text,
             font,
             textRect,
             FrmColor,
             TextFormatFlags.VerticalCenter |
             TextFormatFlags.Left |
             TextFormatFlags.SingleLine |
             TextFormatFlags.WordEllipsis);
     }
 }
Esempio n. 3
0
 private void RenderAnamorphosisText(Graphics g, PointF point, Color fc, Color bc)
 {
     using (Brush brush = new SolidBrush(base.ForeColor))
     {
         Rectangle rc  = new Rectangle(new Point(Convert.ToInt32(point.X), Convert.ToInt32(point.Y)), ClientRectangle.Size);
         Image     img = SkinTools.ImageLightEffect(Text, base.Font, fc, bc, BorderSize, rc, !AutoSize);
         g.DrawImage(img, point.X - (BorderSize / 2), point.Y - (BorderSize / 2));
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 绘制水印
 /// </summary>
 private void WmPaintWater(Graphics g)
 {
     if (this.Text.Length == 0 &&
         !string.IsNullOrEmpty(this._waterText) &&
         !this.Focused)
     {
         g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
         if (WaterText.Length != 0)
         {
             Image img  = SkinTools.ImageLightEffect(WaterText, WaterFont, WaterColor, BackColor, 0, ClientRectangle, !AutoSize);
             int   left = this.RightToLeft == RightToLeft.Yes ? Width - img.Width : 0;
             g.DrawImage(img, left, (Height - img.Height) / 2);
         }
     }
 }
Esempio n. 5
0
        //重绘时
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            base.OnPaintBackground(e);
            Graphics g = e.Graphics;
            //RadioButton的绘画范围
            Rectangle radioButtonrect;
            //文字绘画范围
            Rectangle textRect;

            //给CheckButtom与文字的绘画范围赋值
            CalculateRect(out radioButtonrect, out textRect);
            //抗锯齿的呈现
            g.SmoothingMode = SmoothingMode.AntiAlias;

            //取得当前需要绘画的图像
            Bitmap btm = null;
            //当前无图像时绘画的颜色变量
            Color borderColor;
            Color innerBorderColor;
            Color checkColor;
            bool  hover = false;

            //启用状态时
            if (Enabled)
            {
                switch (ControlState)
                {
                case ControlState.Hover:
                    borderColor      = _baseColor;
                    innerBorderColor = _baseColor;
                    checkColor       = GetColor(_baseColor, 0, 35, 24, 9);
                    btm   = Checked ? (Bitmap)SelectedMouseBack : (Bitmap)MouseBack;
                    hover = true;
                    break;

                case ControlState.Pressed:
                    borderColor      = _baseColor;
                    innerBorderColor = GetColor(_baseColor, 0, -13, -8, -3);
                    checkColor       = GetColor(_baseColor, 0, -35, -24, -9);
                    btm   = Checked ? (Bitmap)SelectedDownBack : (Bitmap)DownBack;
                    hover = true;
                    break;

                default:
                    borderColor      = _baseColor;
                    innerBorderColor = Color.Empty;
                    checkColor       = _baseColor;
                    btm = Checked ? (Bitmap)SelectedNormlBack : (Bitmap)NormlBack;
                    break;
                }
            }
            else //禁用状态时
            {
                borderColor      = SystemColors.ControlDark;
                innerBorderColor = SystemColors.ControlDark;
                checkColor       = SystemColors.ControlDark;
                btm = Checked ? (Bitmap)SelectedNormlBack : (Bitmap)NormlBack;
            }

            if (btm == null)
            {
                using (SolidBrush brush = new SolidBrush(Color.White))
                {
                    g.FillEllipse(brush, radioButtonrect);
                }

                if (hover)
                {
                    using (Pen pen = new Pen(innerBorderColor, 2F))
                    {
                        g.DrawEllipse(pen, radioButtonrect);
                    }
                }

                if (Checked)
                {
                    radioButtonrect.Inflate(-2, -2);
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddEllipse(radioButtonrect);
                        using (PathGradientBrush brush = new PathGradientBrush(path))
                        {
                            brush.CenterColor    = checkColor;
                            brush.SurroundColors = new Color[] { Color.White };
                            Blend blend = new Blend();
                            blend.Positions = new float[] { 0f, 0.4f, 1f };
                            blend.Factors   = new float[] { 0f, 0.4f, 1f };
                            brush.Blend     = blend;
                            g.FillEllipse(brush, radioButtonrect);
                        }
                    }
                    radioButtonrect.Inflate(2, 2);
                }

                using (Pen pen = new Pen(borderColor))
                {
                    g.DrawEllipse(pen, radioButtonrect);
                }
            }
            else
            {
                //画图像
                g.DrawImage(btm, radioButtonrect);
            }

            //画字体
            Color textColor = Enabled ? ForeColor : SystemColors.GrayText;

            //是否绘画发光字体
            if (LightEffect)
            {
                Image imgText = SkinTools.ImageLightEffect(Text, Font, textColor, LightEffectBack, LightEffectWidth);
                g.DrawImage(imgText, textRect);
            }
            else
            {
                TextRenderer.DrawText(
                    g,
                    Text,
                    Font,
                    textRect,
                    textColor,
                    GetTextFormatFlags(TextAlign, RightToLeft == RightToLeft.Yes));
            }
        }