Beispiel #1
0
 /// <summary>
 /// 绘制指定区域路径的边框.
 /// 注意:若要设置边框宽度,需要自己调整区域,它是向外绘制的
 /// </summary>
 /// <param name="g">The Graphics.</param>
 /// <param name="roundRect">The RoundRectangle.</param>
 /// <param name="color">The color.</param>
 /// <param name="borderWidth">Width of the border.</param>
 /// User:Ryan  CreateTime:2011-07-28 16:11.
 public static void DrawPathBorder(Graphics g, RoundRectangle roundRect, Color color, int borderWidth)
 {
     using (GraphicsPath path = roundRect.ToGraphicsBezierPath())
     {
         using (Pen pen = new Pen(color, borderWidth))
         {
             g.DrawPath(pen, path);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 渲染一个圆角矩形区域(单色)
        /// Fills the rectangle.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="roundRect">The round rect.</param>
        /// <param name="color">The color.</param>
        /// User:Ryan  CreateTime:2012-8-3 21:45.
        public static void FillRectangle(Graphics g, RoundRectangle roundRect, Color color)
        {
            if (roundRect.Rect.Width <= 0 || roundRect.Rect.Height <= 0)
            {
                return;
            }

            using (GraphicsPath path = roundRect.ToGraphicsBezierPath())
            {
                using (Brush brush = new SolidBrush(color))
                {
                    g.FillPath(brush, path);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 使用渐变色填充区域
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="roundRect">The round rect.</param>
        /// <param name="color1">The color1.</param>
        /// <param name="color2">The color2.</param>
        /// User:Ryan  CreateTime:2012-8-4 19:15.
        public static void FillPath(Graphics g, RoundRectangle roundRect, Color color1, Color color2)
        {
            if (roundRect.Rect.Width <= 0 || roundRect.Rect.Height <= 0)
            {
                return;
            }

            using (GraphicsPath path = roundRect.ToGraphicsBezierPath())
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(roundRect.Rect, color1, color2, LinearGradientMode.Vertical))
                {
                    g.FillPath(brush, path);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 渲染一个圆角矩形区域(渐变色)
        /// Fills the rectangle.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="roundRect">The round rect.</param>
        /// <param name="color">The color.</param>
        /// User:Ryan  CreateTime:2012-8-3 21:45.
        public static void FillRectangle(Graphics g, RoundRectangle roundRect, GradientColor color)
        {
            if (roundRect.Rect.Width <= 0 || roundRect.Rect.Height <= 0)
            {
                return;
            }

            using (GraphicsPath path = roundRect.ToGraphicsBezierPath())
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(roundRect.Rect, color.First, color.Second, LinearGradientMode.Vertical))
                {
                    brush.Blend.Factors   = color.Factors;
                    brush.Blend.Positions = color.Positions;
                    g.FillPath(brush, path);
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// 绘制checkbox的边框和背景
        /// </summary>
        /// User:Ryan  CreateTime:2011-07-25 18:00.
        public static void DrawCheckBox(Graphics g, RoundRectangle roundRect)
        {
            using (GraphicsPath path = roundRect.ToGraphicsBezierPath())
            {
                using (PathGradientBrush brush = new PathGradientBrush(path))
                {
                    brush.CenterColor    = SkinManager.CurrentSkin.BaseColor;
                    brush.SurroundColors = new Color[] { SkinManager.CurrentSkin.BorderColor };
                    Blend blend = new Blend();
                    blend.Positions = new float[] { 0f, 0.18f, 1f };
                    blend.Factors   = new float[] { 0f, 0.89f, 1f };
                    brush.Blend     = blend;
                    g.FillPath(brush, path);
                }

                DrawPathBorder(g, roundRect);
            }
        }