/// <summary> /// 渲染标签样式分组控件背景色 /// </summary> /// <param name="rect">渲染区域</param> /// <param name="tabSize">左上角标签大小</param> /// <param name="tabRound">标签右上角是否发圆角</param> /// <param name="tabRadius">标签右上角圆角半径</param> public void RenderBackColorGroupBoxTab(Rectangle rect, Size tabSize, bool tabRound, float tabRadius) { this.m_BackColorRect = rect; if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BackColorRect)) { return; } using (Brush brush = RenderEngine.CreateBrush(this.CurrentBackColorBrushRect, this.CurrentBackColor, this.m_BackColorPos1, this.m_BackColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_BackColorBlendStyle)) { //校正背景区域 if (this.m_InnerBorderVisibleStyle != BorderVisibleStyle.None) { tabSize.Width -= 4; } else if (this.m_BorderVisibleStyle != BorderVisibleStyle.None) { tabSize.Width -= 2; } using (GraphicsPath path = RenderEngine.CreateGroupBoxTabGraphicsPath(this.CurrentBackColorPathRect, this.m_RoundStyle, this.m_RoundRadius, tabSize, tabRound, tabRadius, false)) { this.m_Graphics.SetClip(path, CombineMode.Intersect); this.m_Graphics.FillPath(brush, path); } } }
/// <summary> /// 渲染线段 /// </summary> /// <param name="pt1">起点</param> /// <param name="pt2">终点</param> public void RenderLine(Point pt1, Point pt2) { if (this.m_State == State.Hidden || pt1 == pt2) { return; } //使用边框颜色 using (Brush brush = RenderEngine.CreateBrush(pt1, pt2, this.CurrentLineColor, this.m_LineBlendStyle)) { using (Pen pen = RenderEngine.CreatePen(brush, this.m_LineWidth, this.m_LineDashStyle, this.m_LineDashPattern, this.m_LineDashCap, this.m_LineDashOffset)) { this.m_Graphics.DrawLine(pen, pt1, pt2); } } }
/// <summary> /// 渲染标签样式分组控件边框色 /// </summary> /// <param name="rect">渲染区域</param> /// <param name="tabSize">左上角标签大小</param> /// <param name="tabRound">标签右上角是否发圆角</param> /// <param name="tabRadius">标签右上角圆角半径</param> public void RenderBorderColorGroupBoxTab(Rectangle rect, Size tabSize, bool tabRound, float tabRadius) { this.m_BorderColorRect = rect; if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BorderColorRect)) { return; } //重置剪切区 this.m_Graphics.SetClip(this.m_GraphicsClip, CombineMode.Replace); //绘制内边框 if (this.m_InnerBorderVisibleStyle != BorderVisibleStyle.None) { using (Brush brush = RenderEngine.CreateBrush(this.CurrentInnerBorderBrushRect, this.CurrentInnerBorderColor, this.m_InnerBorderColorPos1, this.m_InnerBorderColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_InnerBorderBlendStyle)) { using (Pen pen = RenderEngine.CreatePen(brush, 1, this.m_InnerBorderDashStyle, this.m_InnerBorderDashPattern, this.m_InnerBorderDashCap, this.m_InnerBorderDashOffset)) { Size innerBorderTabSize = new Size(tabSize.Width - 3, tabSize.Height); using (GraphicsPath path = RenderEngine.CreateGroupBoxTabGraphicsPath(this.CurrentInnerBorderPathRect, this.m_RoundStyle, this.m_RoundRadius, innerBorderTabSize, tabRound, tabRadius, false)) { this.m_Graphics.DrawPath(pen, path); } } } } //绘制边框 if (this.m_BorderVisibleStyle != BorderVisibleStyle.None) { using (Brush brush = RenderEngine.CreateBrush(this.CurrentBorderBrushRect, this.CurrentBorderColor, this.m_BorderColorPos1, this.m_BorderColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_BorderBlendStyle)) { using (Pen pen = RenderEngine.CreatePen(brush, 1, this.m_BorderDashStyle, this.m_BorderDashPattern, this.m_BorderDashCap, this.m_BorderDashOffset)) { Size borderTabSize = new Size(tabSize.Width - 1, tabSize.Height); using (GraphicsPath path = RenderEngine.CreateGroupBoxTabGraphicsPath(this.CurrentBorderPathRect, this.m_RoundStyle, this.m_RoundRadius, borderTabSize, tabRound, tabRadius, false)) { this.m_Graphics.DrawPath(pen, path); } } } } }
/// <summary> /// 渲染背景色 /// </summary> /// <param name="rect">渲染区域</param> public void RenderBackColor(Rectangle rect) { this.m_BackColorRect = rect; if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BackColorRect)) { return; } using (Brush brush = RenderEngine.CreateBrush(this.CurrentBackColorBrushRect, this.CurrentBackColor, this.m_BackColorPos1, this.m_BackColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_BackColorBlendStyle)) { if (float.IsNaN(this.m_RoundRadius) || this.m_RoundRadius <= 0f) { this.m_Graphics.FillRectangle(brush, this.CurrentBackColorPathRect); } else { this.m_Graphics.FillPath(brush, this.CurrentBackColorPath); } } }
/// <summary> /// 渲染边框颜色(RoundStyle圆角样式,BorderStyle确定绘制哪个边,BlendStyle混合方式) /// </summary> /// <param name="rect">渲染区域</param> public void RenderBorder(Rectangle rect) { this.m_BorderColorRect = rect; if (this.m_State == State.Hidden || !RectangleEx.IsVisible(this.m_BorderColorRect)) { return; } //重置剪切区 this.m_Graphics.SetClip(this.m_GraphicsClip, CombineMode.Replace); //绘制内边框 if (this.m_InnerBorderVisibleStyle != BorderVisibleStyle.None) { using (Brush brush = RenderEngine.CreateBrush(this.CurrentInnerBorderBrushRect, this.CurrentInnerBorderColor, this.m_InnerBorderColorPos1, this.m_InnerBorderColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_InnerBorderBlendStyle)) { using (Pen pen = RenderEngine.CreatePen(brush, 1, this.m_InnerBorderDashStyle, this.m_InnerBorderDashPattern, this.m_InnerBorderDashCap, this.m_InnerBorderDashOffset)) { RenderEngine.DrawBorder(this.m_Graphics, pen, this.CurrentInnerBorderPathRect, this.m_InnerBorderVisibleStyle, this.m_RoundCornerStyle, this.m_RoundStyle, this.m_RoundRadius, false); } } } //绘制边框 if (this.m_BorderVisibleStyle != BorderVisibleStyle.None) { using (Brush brush = RenderEngine.CreateBrush(this.CurrentBorderBrushRect, this.CurrentBorderColor, this.m_BorderColorPos1, this.m_BorderColorPos2, this.CurrentBackColorReverse, this.CurrentBackColorMode, this.m_BorderBlendStyle)) { using (Pen pen = RenderEngine.CreatePen(brush, 1, this.m_BorderDashStyle, this.m_BorderDashPattern, this.m_BorderDashCap, this.m_BorderDashOffset)) { RenderEngine.DrawBorder(this.m_Graphics, pen, this.CurrentBorderPathRect, this.m_BorderVisibleStyle, this.m_RoundCornerStyle, this.m_RoundStyle, this.m_RoundRadius, false); } } } }