protected Pen GetExpandPen(NodeExpandPartRendererEventArgs e) { if (e.ExpandLineColor.IsEmpty) { TreeExpandColorTable ct = GetExpandColorTable(e); if (ct != null) { bool expanded = e.Node.Expanded; if (expanded) { // Collapse node colors if (!e.IsMouseOver && ct.CollapseForeground != null) return ct.CollapseForeground.CreatePen(1); else if (e.IsMouseOver && ct.CollapseMouseOverForeground != null) return ct.CollapseMouseOverForeground.CreatePen(1); } else { // Collapse node colors if (!e.IsMouseOver && ct.ExpandForeground != null) return ct.ExpandForeground.CreatePen(1); else if (e.IsMouseOver && ct.ExpandMouseOverForeground != null) return ct.ExpandMouseOverForeground.CreatePen(1); } } return GetBorderPen(e); } return new Pen(e.ExpandLineColor,1); }
protected Pen GetBorderPen(NodeExpandPartRendererEventArgs e) { if(!e.BorderColor.IsEmpty) return new Pen(e.BorderColor,1); if (_ColorTable != null) { bool expanded = e.Node.Expanded; TreeExpandColorTable ct = GetExpandColorTable(e); if (ct == null) return null; if (expanded) { // Collapse node colors if (!e.IsMouseOver && ct.CollapseBorder != null) return ct.CollapseBorder.CreatePen(); else if (e.IsMouseOver && ct.CollapseMouseOverBorder != null) return ct.CollapseMouseOverBorder.CreatePen(); } else { // Expand node colors if (!e.IsMouseOver && ct.ExpandBorder != null) return ct.ExpandBorder.CreatePen(); else if (e.IsMouseOver && ct.ExpandMouseOverBorder != null) return ct.ExpandMouseOverBorder.CreatePen(); } } return null; }
/// <summary> /// Draws image type expand button. /// </summary> /// <param name="e">Expand context information</param> public override void DrawExpandButton(NodeExpandPartRendererEventArgs e) { if(e.Node.Expanded) { if(e.ExpandImageCollapse!=null) e.Graphics.DrawImage(e.ExpandImageCollapse,e.ExpandPartBounds); } else if(e.ExpandImage!=null) e.Graphics.DrawImage(e.ExpandImage,e.ExpandPartBounds); }
private TreeExpandColorTable GetExpandColorTable(NodeExpandPartRendererEventArgs e) { TreeExpandColorTable ct = null; if (e.ExpandButtonType == eExpandButtonType.Rectangle) ct = _ColorTable.ExpandRectangle; else if (e.ExpandButtonType == eExpandButtonType.Triangle) ct = _ColorTable.ExpandTriangle; else if (e.ExpandButtonType == eExpandButtonType.Ellipse) ct = _ColorTable.ExpandEllipse; return ct; }
protected Brush GetBackgroundBrush(NodeExpandPartRendererEventArgs e) { if(e.BackColor.IsEmpty && e.BackColor2.IsEmpty) return null; if(e.BackColor2.IsEmpty) return new SolidBrush(e.BackColor); System.Drawing.Drawing2D.LinearGradientBrush brush=DisplayHelp.CreateLinearGradientBrush(e.ExpandPartBounds,e.BackColor,e.BackColor2,e.BackColorGradientAngle); //brush.SetSigmaBellShape(0.8f); return brush; }
/// <summary>Draws ellipse type expand button.</summary> /// <param name="e">Expand context drawing information.</param> public override void DrawExpandButton(NodeExpandPartRendererEventArgs e) { if(e.ExpandPartBounds.IsEmpty) return; Brush brush=GetBackgroundBrush(e); if(brush!=null) { e.Graphics.FillEllipse(brush,e.ExpandPartBounds); brush.Dispose(); } Pen pen=GetBorderPen(e); if (pen != null) { SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.DrawEllipse(pen, e.ExpandPartBounds); e.Graphics.SmoothingMode = sm; pen.Dispose(); pen = null; } if(e.Node.Expanded) { pen = GetExpandPen(e); if (pen != null) { e.Graphics.DrawLine(pen, e.ExpandPartBounds.X + 2, e.ExpandPartBounds.Y + e.ExpandPartBounds.Height / 2, e.ExpandPartBounds.Right - 2, e.ExpandPartBounds.Y + e.ExpandPartBounds.Height / 2); pen.Dispose(); } } else { pen = GetExpandPen(e); if (pen != null) { e.Graphics.DrawLine(pen,e.ExpandPartBounds.X+2,e.ExpandPartBounds.Y+e.ExpandPartBounds.Height/2,e.ExpandPartBounds.Right-2,e.ExpandPartBounds.Y+e.ExpandPartBounds.Height/2); e.Graphics.DrawLine(pen,e.ExpandPartBounds.X+e.ExpandPartBounds.Width/2,e.ExpandPartBounds.Y+2,e.ExpandPartBounds.X+e.ExpandPartBounds.Width/2,e.ExpandPartBounds.Bottom-2); pen.Dispose(); } } }
/// <summary> /// Draw triangular type expand button. /// </summary> /// <param name="e">Expand button context information.</param> public override void DrawExpandButton(NodeExpandPartRendererEventArgs e) { if (e.ExpandPartBounds.IsEmpty) return; SmoothingMode sm = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; Rectangle r = new Rectangle(e.ExpandPartBounds.X , e.ExpandPartBounds.Y + (e.ExpandPartBounds.Height - 8) / 2, 5, 8); GraphicsPath path = null; if (e.Node.Expanded) { path = new GraphicsPath(); path.AddLine(r.X, r.Y + 5, r.X + 5, r.Y); path.AddLine(r.X + 5, r.Y, r.X + 5, r.Y + 5); path.CloseAllFigures(); } else { path = new GraphicsPath(); path.AddLine(r.X, r.Y, r.X, r.Bottom); path.AddLine(r.X, r.Bottom, r.X + 4, r.Y + r.Height / 2); path.CloseAllFigures(); } Brush brush = GetBackgroundBrush(e); if (brush != null) { e.Graphics.FillPath(brush, path); brush.Dispose(); } Pen pen = GetBorderPen(e); if(pen!=null) { e.Graphics.DrawPath(pen, path); pen.Dispose(); } e.Graphics.SmoothingMode = sm; if(path!=null) path.Dispose(); }
/// <summary>Draws ellipse type expand button.</summary> /// <param name="e">Expand context drawing information.</param> public override void DrawExpandButton(NodeExpandPartRendererEventArgs e) { Rectangle expandPartBounds = e.ExpandPartBounds; if (expandPartBounds.IsEmpty) return; Brush brush = GetBackgroundBrush(e); expandPartBounds.Width--; expandPartBounds.Height--; if (brush != null) { e.Graphics.FillEllipse(brush, expandPartBounds); brush.Dispose(); } using (Pen pen = GetBorderPen(e)) { e.Graphics.DrawEllipse(pen, expandPartBounds); } if (e.Node.Expanded) { using (Pen pen = GetExpandPen(e)) { e.Graphics.DrawLine(pen, expandPartBounds.X + 2, expandPartBounds.Y + expandPartBounds.Height / 2, expandPartBounds.Right - 2, expandPartBounds.Y + expandPartBounds.Height / 2); } } else { using (Pen pen = GetExpandPen(e)) { e.Graphics.DrawLine(pen, expandPartBounds.X + 2, expandPartBounds.Y + expandPartBounds.Height / 2, expandPartBounds.Right - 2, expandPartBounds.Y + expandPartBounds.Height / 2); e.Graphics.DrawLine(pen, expandPartBounds.X + expandPartBounds.Width / 2, expandPartBounds.Y + 2, expandPartBounds.X + expandPartBounds.Width / 2, expandPartBounds.Bottom - 2); } } }
protected Pen GetExpandPen(NodeExpandPartRendererEventArgs e) { return new Pen(e.ExpandLineColor,1); }
protected Pen GetBorderPen(NodeExpandPartRendererEventArgs e) { return new Pen(e.BorderColor,1); }
/// <summary>Draws expand button.</summary> /// <param name="e">Context parameters for drawing expand button.</param> public abstract void DrawExpandButton(NodeExpandPartRendererEventArgs e);
/// <summary> /// Raises RenderNodeExpandPart event. /// </summary> /// <param name="e"></param> protected virtual void OnRenderNodeExpandPart(NodeExpandPartRendererEventArgs e) { if(RenderNodeExpandPart!=null) RenderNodeExpandPart(this,e); }
/// <summary> /// Draws node expand part. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you /// do not want default rendering to occur do not call the base implementation. You can call OnRenderNodeExpandPart method so events can occur. /// </summary> /// <param name="e">Information provided for rendering.</param> public virtual void DrawNodeExpandPart(NodeExpandPartRendererEventArgs e) { OnRenderNodeExpandPart(e); }
/// <summary> /// Draws node expand part. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you /// do not want default rendering to occur do not call the base implementation. You can call OnRenderNodeExpandPart method so events can occur. /// </summary> /// <param name="e">Information provided for rendering.</param> public override void DrawNodeExpandPart(NodeExpandPartRendererEventArgs e) { GetExpandDisplay(e.ExpandButtonType).DrawExpandButton(e); base.DrawNodeExpandPart(e); }
protected Brush GetBackgroundBrush(NodeExpandPartRendererEventArgs e) { if (e.BackColor.IsEmpty && e.BackColor2.IsEmpty) { bool expanded = e.Node.Expanded; TreeExpandColorTable ct = GetExpandColorTable(e); if (ct == null) return null; if (expanded) { // Collapse node colors if (!e.IsMouseOver && ct.CollapseFill != null) return ct.CollapseFill.CreateBrush(e.ExpandPartBounds); else if (e.IsMouseOver && ct.CollapseMouseOverFill != null) return ct.CollapseMouseOverFill.CreateBrush(e.ExpandPartBounds); } else { // Expand node colors if (!e.IsMouseOver && ct.ExpandFill != null) return ct.ExpandFill.CreateBrush(e.ExpandPartBounds); else if (e.IsMouseOver && ct.ExpandMouseOverFill != null) return ct.ExpandMouseOverFill.CreateBrush(e.ExpandPartBounds); } return null; } if(e.BackColor2.IsEmpty) return new SolidBrush(e.BackColor); System.Drawing.Drawing2D.LinearGradientBrush brush=DisplayHelp.CreateLinearGradientBrush(e.ExpandPartBounds,e.BackColor,e.BackColor2,e.BackColorGradientAngle); //brush.SetSigmaBellShape(0.8f); return brush; }