/// <summary> /// 绘制指定区域路径的边框 /// </summary> public static void DrawPathOuterBorder(Graphics g, RoundRectangle roundRect, Color color, int borderWidth) { Rectangle rect = roundRect.Rect; rect.X--; rect.Y--; rect.Width += 2; rect.Height += 2; DrawPathBorder(g, new RoundRectangle(rect, roundRect.CornerRadius), color, borderWidth); }
/// <summary> /// 绘制指定区域路径的边框 /// </summary> public static void DrawPathInnerBorder(Graphics g, RoundRectangle roundRect) { Color c = SkinManager.CurrentSkin.InnerBorderColor; ////c = Color.Green; DrawPathInnerBorder(g, roundRect, c); }
/// <summary> /// 绘制指定区域路径的边框 /// </summary> public static void DrawPathInnerBorder(Graphics g, RoundRectangle roundRect, Color color) { Rectangle rect = roundRect.Rect; rect.X++; rect.Y++; rect.Width -= 2; rect.Height -= 2; DrawPathBorder(g, new RoundRectangle(rect, roundRect.CornerRadius), color); }
/// <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); } } }
/// <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); } } }
/// <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); } } }
/// <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); } } }
/// <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); } }
/// <summary> /// 绘制指定区域路径的边框 /// </summary> public static void DrawPathOuterBorder(Graphics g, RoundRectangle roundRect) { DrawPathOuterBorder(g, roundRect, SkinManager.CurrentSkin.OuterBorderColor); }
/// <summary> /// 绘制指定区域路径的边框 /// </summary> /// User:Ryan CreateTime:2011-07-28 16:11. public static void DrawPathBorder(Graphics g, RoundRectangle roundRect, Color color) { DrawPathBorder(g, roundRect, color, 1); }
/// <summary> /// 渲染圆角矩形区域(级渲染) /// </summary> /// <param name="g">The Graphics.</param> /// <param name="roundRect">The RoundRectangle.</param> /// <param name="color1">The color1.</param> /// <param name="color2">The color2.</param> /// <param name="blend">色彩混合渲染方案</param> /// User:K.Anding CreateTime:2011-7-20 23:27. public static void FillPath(Graphics g, RoundRectangle roundRect, Color color1, Color color2, Blend blend) { GradientColor color = new GradientColor(color1, color2, blend.Factors, blend.Positions); GDIHelper.FillRectangle(g, roundRect, color); }