public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { if (this.bExpand == false) { this.MyText.Paint(pe, nBaseX, nBaseY, paintMember); } else { base.Paint(pe, nBaseX, nBaseY, paintMember); } }
public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { Rectangle rectPaint = new Rectangle(nBaseX + this.Rect.X, nBaseY + this.Rect.Y, this.Rect.Width, this.Rect.Height); Color backColor = this.BackColor; using (Brush brush = new SolidBrush(this.BackColor)) { pe.Graphics.FillRectangle(brush, rectPaint); } Item item = this.GetItem(); XmlEditor editor = null; if (item != null) { editor = item.m_document; } if (editor != null && editor.VisualCfg == null) { } else { //调DrawLines画边框 this.DrawLines(rectPaint, this.TopBorderHeight, this.BottomBorderHeight, this.LeftBorderWidth, this.RightBorderWidth, this.BorderColor); } int nWidth = (this.Rect.Width - this.LeftBlank - this.RightBlank); PaintButton(pe.Graphics, rectPaint.X + this.LeftBlank, rectPaint.Y, nWidth, this.expandIconStyle); }
public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { if (this.Rect.Width == 0 || this.Rect.Height == 0) { return; } Rectangle rectPaint = new Rectangle(nBaseX + this.Rect.X, nBaseY + this.Rect.Y, this.Rect.Width, this.Rect.Height); //背景色 Item item = this.GetItem(); Object colorDefault = null; XmlEditor editor = item.m_document; if (editor != null && editor.VisualCfg != null) { colorDefault = editor.VisualCfg.transparenceColor; } if (colorDefault != null) { if (((Color)colorDefault).Equals(BackColor) == true) { goto SKIPDRAWBACK; } } Color backColor = this.BackColor; // 如果对象的父亲 是 活动的Item 加亮显示 if (editor != null) { if (item == editor.m_selectedItem) { backColor = ControlPaint.Light(backColor); } } using (Brush brush = new SolidBrush(backColor)) { pe.Graphics.FillRectangle(brush, rectPaint); } SKIPDRAWBACK: //调DrawLines画边框 if (editor != null && editor.VisualCfg == null) { } else { this.DrawLines(rectPaint, this.TopBorderHeight, this.BottomBorderHeight, this.LeftBorderWidth, this.RightBorderWidth, this.BorderColor); } //内容区域 rectPaint = new Rectangle(nBaseX + this.Rect.X + this.LeftResWidth /*LeftBlank*/, nBaseY + this.Rect.Y + this.TopResHeight /*this.TopBlank*/, this.Rect.Width - this.TotalRestWidth /*this.LeftBlank - this.RightBlank*/, this.Rect.Height - this.TotalRestHeight /*this.TopBlank - this.BottomBlank*/); Font font1 = this.GetFont(); using (Font font = new Font(font1.Name, font1.Size)) using (Brush brush = new SolidBrush(TextColor)) { pe.Graphics.DrawString(Text, font, brush, rectPaint, new StringFormat()); } }
public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { if (this.Rect.Width == 0 || this.Rect.Height == 0) return; Rectangle rectPaint = new Rectangle (nBaseX + this.Rect.X , nBaseY + this.Rect.Y, this.Rect.Width, this.Rect.Height); Brush brush = null; //背景色 Item item = this.GetItem (); Object colorDefault = null; XmlEditor editor = item.m_document; if (editor != null && editor.VisualCfg != null) colorDefault = editor.VisualCfg.transparenceColor ; if (colorDefault != null) { if (((Color)colorDefault).Equals (BackColor) == true) goto SKIPDRAWBACK; } brush = new SolidBrush(this.BackColor); pe.Graphics .FillRectangle (brush,rectPaint); SKIPDRAWBACK: //调DrawLines画边框 if (editor != null && editor.VisualCfg == null) { } else { this.DrawLines(rectPaint, this.TopBorderHeight, this.BottomBorderHeight, this.LeftBorderWidth, this.RightBorderWidth, this.BorderColor); } //内容区域 rectPaint = new Rectangle (nBaseX + this.Rect.X + this.LeftResWidth/*LeftBlank*/, nBaseY + this.Rect.Y + this.TopResHeight/*this.TopBlank*/, this.Rect.Width - this.TotalRestWidth/*this.LeftBlank - this.RightBlank*/, this.Rect.Height - this.TotalRestHeight/*this.TopBlank - this.BottomBlank*/); brush = new SolidBrush(TextColor); Font font1 = this.GetFont(); Font font = new Font(font1.Name,font1.Size); pe.Graphics.DrawString(Text, font, brush, rectPaint, new StringFormat()); font.Dispose(); brush.Dispose (); font.Dispose (); }
public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { if (this.bExpand == false) { this.MyText.Paint (pe,nBaseX,nBaseY,paintMember); } else { base.Paint(pe,nBaseX,nBaseY,paintMember); } }
public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { Rectangle rectPaintThis = new Rectangle (0,0,0,0); rectPaintThis = new Rectangle (nBaseX + this.Rect.X, nBaseY + this.Rect.Y, this.Rect.Width, this.Rect.Height); if (rectPaintThis.IntersectsWith (pe.ClipRectangle )== false) return; Brush brush = null; Item item = this.GetItem (); if (item == null) return; //? Object colorDefault = null; XmlEditor editor = item.m_document; if (editor != null && editor.VisualCfg != null) colorDefault = editor.VisualCfg.transparenceColor ; if (colorDefault != null) { if (((Color)colorDefault).Equals (BackColor) == true) goto SKIPDRAWBACK; } brush = new SolidBrush(this.BackColor); pe.Graphics .FillRectangle (brush,rectPaintThis); SKIPDRAWBACK: if (editor != null && editor.VisualCfg == null) { } else { //调DrawLines画边框 this.DrawLines(rectPaintThis, this.TopBorderHeight, this.BottomBorderHeight, this.LeftBorderWidth, this.RightBorderWidth, this.BorderColor); } if (childrenVisual == null) return; for(int i=0;i<this.childrenVisual.Count;i++) { Visual visual = (Visual)(this.childrenVisual[i]); Rectangle rectPaintChild = new Rectangle( nBaseX + this.Rect.X + visual.Rect.X, nBaseY + this.Rect.Y + visual.Rect.Y, visual.Rect.Width, visual.Rect.Height); if (rectPaintChild.IntersectsWith(pe.ClipRectangle ) == true) { visual.Paint(pe, nBaseX + this.Rect.X, nBaseY + this.Rect.Y, paintMember); } if (editor != null && editor.VisualCfg == null) { if (i == this.childrenVisual.Count-1) { int nDelta = this.RectAbs.Y + this.Rect.Height - visual.RectAbs.Y - visual.Rect.Height - Visual.BOTTOMBORDERHEIGHT; if (nDelta > 0) { // 画下方线条 this.DrawLines(new Rectangle(rectPaintChild.X, rectPaintChild.Y, rectPaintChild.Width, rectPaintChild.Height + Visual.BOTTOMBORDERHEIGHT), 0, Visual.BOTTOMBORDERHEIGHT, 0, 0, visual.BorderColor); } } if (i <= 0) continue; if (this.LayoutStyle == LayoutStyle.Vertical) { // 只画上方线条 this.DrawLines(rectPaintChild, visual.TopBorderHeight, 0, 0, 0, visual.BorderColor); } else if (this.LayoutStyle == LayoutStyle.Horizontal) { this.DrawLines(rectPaintChild, 0, 0, visual.LeftBorderWidth, 0, visual.BorderColor); } } } }
// 绘图 // parameters: // pe PaintEventArgs对象 // nBaseX x基坐标 // nBaseY y基坐标 // paintMember 绘制成员:content,border,both // return: // void public virtual void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { }
// 为什么要重写虚属性,item是从visual派生,而visual派生类并没有具体实现这个函数 public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { // 1.计算出本对象的实际区域 Rectangle rectPaintThis = new Rectangle (0,0,0,0); rectPaintThis = new Rectangle (nBaseX + this.Rect.X, nBaseY + this.Rect.Y, this.Rect.Width , this.Rect.Height); if (rectPaintThis.IntersectsWith(pe.ClipRectangle )== false) return; // 2.画背景色 // 如有缺省透明色,当前颜色与透明色相同则不画了 Object colorDefault = null; XmlEditor editor = this.m_document; if (editor != null && editor.VisualCfg != null) colorDefault = editor.VisualCfg.transparenceColor; if (colorDefault != null) //缺省颜色 { if (((Color)colorDefault).Equals(BackColor) == true) goto SkipDrawBack; } using (Brush brush = new SolidBrush(this.BackColor)) { pe.Graphics.FillRectangle(brush, rectPaintThis); } // 跳过画背景色 SkipDrawBack: // 3.画线条 // 当单线条时,自己不画,靠儿子来画 if (editor != null && editor.VisualCfg == null) { } else { // 配置文件定了的时候 this.DrawLines(rectPaintThis, this.TopBorderHeight, this.BottomBorderHeight, this.LeftBorderWidth, this.RightBorderWidth, this.BorderColor); } // 4.画儿子 if (childrenVisual == null) return; for(int i=0;i<this.childrenVisual.Count;i++) { Visual visual = (Visual)(this.childrenVisual[i]); Rectangle rectPaintChild = new Rectangle( nBaseX + this.Rect.X + visual.Rect.X, nBaseY + this.Rect.Y + visual.Rect.Y, visual.Rect.Width, visual.Rect.Height); if (rectPaintChild.IntersectsWith(pe.ClipRectangle ) == true) { visual.Paint(pe, nBaseX + this.Rect.X, nBaseY + this.Rect.Y, paintMember); } if (i <= 0) continue; if (editor != null && editor.VisualCfg == null) { this.DrawLines(rectPaintChild, 0, 0, visual.LeftBorderWidth, 0, visual.BorderColor); } } }
public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { Rectangle rectPaint = new Rectangle (nBaseX + this.Rect.X, nBaseY + this.Rect.Y, this.Rect.Width, this.Rect.Height); Color backColor = this.BackColor ; using (Brush brush = new SolidBrush(this.BackColor)) { pe.Graphics.FillRectangle(brush, rectPaint); } Item item = this.GetItem(); XmlEditor editor = null; if (item != null) { editor = item.m_document; } if (editor != null && editor.VisualCfg == null) { } else { //调DrawLines画边框 this.DrawLines (rectPaint, this.TopBorderHeight, this.BottomBorderHeight, this.LeftBorderWidth, this.RightBorderWidth, this.BorderColor); } int nWidth =(this.Rect.Width - this.LeftBlank - this.RightBlank); PaintButton(pe.Graphics, rectPaint.X + this.LeftBlank, rectPaint.Y, nWidth, this.expandIconStyle); }
// 为什么要重写这个函数 // 因为只画单线条时,只有根才画四线,其它父亲不画线条 public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { // 1.计算出区域 Rectangle rectPaintThis = new Rectangle(0, 0, 0, 0); rectPaintThis = new Rectangle(nBaseX + this.Rect.X, nBaseY + this.Rect.Y, this.Rect.Width, this.Rect.Height); if (rectPaintThis.IntersectsWith(pe.ClipRectangle) == false) { return; } // 2.画背景色 // 如有缺省透明色,当前颜色与透明色相同则不画了 //? Object colorDefault = null; XmlEditor editor = this.m_document; if (editor != null && editor.VisualCfg != null) { colorDefault = editor.VisualCfg.transparenceColor; } if (colorDefault != null) //缺省颜色 { if (((Color)colorDefault).Equals(BackColor) == true) { goto SKIPDRAWBACK; } } using (Brush brush = new SolidBrush(BackColor)) { pe.Graphics.FillRectangle(brush, rectPaintThis); } SKIPDRAWBACK: // 4.画儿子 if (childrenVisual == null) { goto END1; } for (int i = 0; i < this.childrenVisual.Count; i++) { Visual visual = (Visual)(this.childrenVisual[i]); Rectangle rectPaintChild = new Rectangle( nBaseX + this.Rect.X + visual.Rect.X, nBaseY + this.Rect.Y + visual.Rect.Y, visual.Rect.Width, visual.Rect.Height); if (rectPaintChild.IntersectsWith(pe.ClipRectangle) == true) { visual.Paint(pe, nBaseX + this.Rect.X, nBaseY + this.Rect.Y, paintMember); } if (i <= 0) { continue; } if (editor != null && editor.VisualCfg == null) { if (this.layoutStyle == LayoutStyle.Horizontal) { this.DrawLines(rectPaintChild, 0, 0, visual.LeftBorderWidth, 0, visual.BorderColor); } else { this.DrawLines(rectPaintChild, visual.TopBorderHeight, 0, 0, 0, visual.BorderColor); } } } END1: // 3.画根元素的外边框线条 this.DrawLines(rectPaintThis, this.TopBorderHeight, this.BottomBorderHeight, this.LeftBorderWidth, this.RightBorderWidth, this.BorderColor); }
// 为什么要重写这个函数 // 因为只画单线条时,只有根才画四线,其它父亲不画线条 public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { // 1.计算出区域 Rectangle rectPaintThis = new Rectangle (0,0,0,0); rectPaintThis = new Rectangle (nBaseX + this.Rect.X, nBaseY + this.Rect.Y, this.Rect.Width, this.Rect.Height); if (rectPaintThis.IntersectsWith(pe.ClipRectangle )== false) return; Brush brush = null; // 2.画背景色 // 如有缺省透明色,当前颜色与透明色相同则不画了 //? Object colorDefault = null; XmlEditor editor = this.m_document; if (editor != null && editor.VisualCfg != null) colorDefault = editor.VisualCfg.transparenceColor; if (colorDefault != null) //缺省颜色 { if (((Color)colorDefault).Equals (BackColor) == true) goto SKIPDRAWBACK; } brush = new SolidBrush(BackColor); pe.Graphics .FillRectangle (brush,rectPaintThis); SKIPDRAWBACK: // 4.画儿子 if (childrenVisual == null) goto END1; for(int i=0;i<this.childrenVisual.Count;i++) { Visual visual = (Visual)(this.childrenVisual[i]); Rectangle rectPaintChild = new Rectangle( nBaseX + this.Rect.X + visual.Rect.X, nBaseY + this.Rect.Y + visual.Rect.Y, visual.Rect.Width, visual.Rect.Height ); if(rectPaintChild.IntersectsWith (pe.ClipRectangle ) == true) { visual.Paint(pe, nBaseX + this.Rect.X, nBaseY + this.Rect.Y, paintMember); } if (i <= 0) continue; if (editor != null && editor.VisualCfg == null) { if (this.layoutStyle == LayoutStyle.Horizontal) { this.DrawLines(rectPaintChild, 0, 0, visual.LeftBorderWidth, 0, visual.BorderColor); } else { this.DrawLines(rectPaintChild, visual.TopBorderHeight, 0, 0, 0, visual.BorderColor); } } } END1: // 3.画根元素的外边框线条 this.DrawLines(rectPaintThis, this.TopBorderHeight, this.BottomBorderHeight, this.LeftBorderWidth, this.RightBorderWidth, this.BorderColor); }
// 绘图 // parameters: // pe PaintEventArgs对象 // nBaseX x基坐标 // nBaseY y基坐标 // paintMember 绘制成员:content,border,both // return: // void public virtual void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { }
public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { Rectangle rectPaintThis = new Rectangle(0, 0, 0, 0); rectPaintThis = new Rectangle(nBaseX + this.Rect.X, nBaseY + this.Rect.Y, this.Rect.Width, this.Rect.Height); if (rectPaintThis.IntersectsWith(pe.ClipRectangle) == false) { return; } Item item = this.GetItem(); if (item == null) { return; } //? Object colorDefault = null; XmlEditor editor = item.m_document; if (editor != null && editor.VisualCfg != null) { colorDefault = editor.VisualCfg.transparenceColor; } if (colorDefault != null) { if (((Color)colorDefault).Equals(BackColor) == true) { goto SKIPDRAWBACK; } } using (Brush brush = new SolidBrush(this.BackColor)) { pe.Graphics.FillRectangle(brush, rectPaintThis); } SKIPDRAWBACK: if (editor != null && editor.VisualCfg == null) { } else { //调DrawLines画边框 this.DrawLines(rectPaintThis, this.TopBorderHeight, this.BottomBorderHeight, this.LeftBorderWidth, this.RightBorderWidth, this.BorderColor); } if (childrenVisual == null) { return; } for (int i = 0; i < this.childrenVisual.Count; i++) { Visual visual = (Visual)(this.childrenVisual[i]); Rectangle rectPaintChild = new Rectangle( nBaseX + this.Rect.X + visual.Rect.X, nBaseY + this.Rect.Y + visual.Rect.Y, visual.Rect.Width, visual.Rect.Height); if (rectPaintChild.IntersectsWith(pe.ClipRectangle) == true) { visual.Paint(pe, nBaseX + this.Rect.X, nBaseY + this.Rect.Y, paintMember); } if (editor != null && editor.VisualCfg == null) { if (i == this.childrenVisual.Count - 1) { int nDelta = this.RectAbs.Y + this.Rect.Height - visual.RectAbs.Y - visual.Rect.Height - Visual.BOTTOMBORDERHEIGHT; if (nDelta > 0) { // 画下方线条 this.DrawLines(new Rectangle(rectPaintChild.X, rectPaintChild.Y, rectPaintChild.Width, rectPaintChild.Height + Visual.BOTTOMBORDERHEIGHT), 0, Visual.BOTTOMBORDERHEIGHT, 0, 0, visual.BorderColor); } } if (i <= 0) { continue; } if (this.LayoutStyle == LayoutStyle.Vertical) { // 只画上方线条 this.DrawLines(rectPaintChild, visual.TopBorderHeight, 0, 0, 0, visual.BorderColor); } else if (this.LayoutStyle == LayoutStyle.Horizontal) { this.DrawLines(rectPaintChild, 0, 0, visual.LeftBorderWidth, 0, visual.BorderColor); } } } }
// 为什么要重写虚属性,item是从visual派生,而visual派生类并没有具体实现这个函数 public override void Paint(PaintEventArgs pe, int nBaseX, int nBaseY, PaintMember paintMember) { // 1.计算出本对象的实际区域 Rectangle rectPaintThis = new Rectangle(0, 0, 0, 0); rectPaintThis = new Rectangle(nBaseX + this.Rect.X, nBaseY + this.Rect.Y, this.Rect.Width, this.Rect.Height); if (rectPaintThis.IntersectsWith(pe.ClipRectangle) == false) { return; } // 2.画背景色 // 如有缺省透明色,当前颜色与透明色相同则不画了 Object colorDefault = null; XmlEditor editor = this.m_document; if (editor != null && editor.VisualCfg != null) { colorDefault = editor.VisualCfg.transparenceColor; } if (colorDefault != null) //缺省颜色 { if (((Color)colorDefault).Equals(BackColor) == true) { goto SkipDrawBack; } } using (Brush brush = new SolidBrush(this.BackColor)) { pe.Graphics.FillRectangle(brush, rectPaintThis); } // 跳过画背景色 SkipDrawBack: // 3.画线条 // 当单线条时,自己不画,靠儿子来画 if (editor != null && editor.VisualCfg == null) { } else { // 配置文件定了的时候 this.DrawLines(rectPaintThis, this.TopBorderHeight, this.BottomBorderHeight, this.LeftBorderWidth, this.RightBorderWidth, this.BorderColor); } // 4.画儿子 if (childrenVisual == null) { return; } for (int i = 0; i < this.childrenVisual.Count; i++) { Visual visual = (Visual)(this.childrenVisual[i]); Rectangle rectPaintChild = new Rectangle( nBaseX + this.Rect.X + visual.Rect.X, nBaseY + this.Rect.Y + visual.Rect.Y, visual.Rect.Width, visual.Rect.Height); if (rectPaintChild.IntersectsWith(pe.ClipRectangle) == true) { visual.Paint(pe, nBaseX + this.Rect.X, nBaseY + this.Rect.Y, paintMember); } if (i <= 0) { continue; } if (editor != null && editor.VisualCfg == null) { this.DrawLines(rectPaintChild, 0, 0, visual.LeftBorderWidth, 0, visual.BorderColor); } } }