private void PaintNodeSelection(Node node, NodeDisplayContext context) { if (!node.IsSelectionVisible) return; context.SelectionDisplayInfo.Node = node; Rectangle r; if (this.Tree.SelectionBoxStyle == eSelectionStyle.FullRowSelect) { if (context.CellSelection) { Cell cell = context.SelectionDisplayInfo.Node.SelectedCell != null ? context.SelectionDisplayInfo.Node.SelectedCell : context.SelectionDisplayInfo.Node.Cells[0]; r = NodeDisplay.GetCellRectangle(eCellRectanglePart.CellBounds, cell, context.Offset); } else { r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, context.SelectionDisplayInfo.Node, context.Offset); r.X = context.ClientRectangle.X; r.Width = context.ClientRectangle.Width; } if(context.GridRowLines) r.Inflate(0, (int)Math.Floor((float)Tree.NodeSpacing / 2)); else r.Inflate(0, (int)Math.Ceiling((float)Tree.NodeSpacing / 2)); } else if (this.Tree.SelectionBoxStyle == eSelectionStyle.HighlightCells) { if (context.CellSelection) { Cell cell = context.SelectionDisplayInfo.Node.SelectedCell != null ? context.SelectionDisplayInfo.Node.SelectedCell : context.SelectionDisplayInfo.Node.Cells[0]; r = NodeDisplay.GetCellRectangle(eCellRectanglePart.CellBounds, cell, context.Offset); } else { r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.CellsBounds, context.SelectionDisplayInfo.Node, context.Offset); } r.Inflate(2, 2); if (r.Right > context.ClientRectangle.Right) r.Width -= (r.Right - context.ClientRectangle.Right); } else { if (context.CellSelection) { Cell cell = context.SelectionDisplayInfo.Node.SelectedCell != null ? context.SelectionDisplayInfo.Node.SelectedCell : context.SelectionDisplayInfo.Node.Cells[0]; r = NodeDisplay.GetCellRectangle(eCellRectanglePart.CellBounds, cell, context.Offset); } else { r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, context.SelectionDisplayInfo.Node, context.Offset); } } context.SelectionDisplayInfo.Bounds = r; context.NodeRenderer.DrawSelection(context.SelectionDisplayInfo); }
private void PaintHotTracking(NodeDisplayContext context) { Node node = this.Tree.MouseOverNode; if (node != null && !node.IsSelected && node.Selectable) { Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.CellsBounds, node, context.Offset); r.Inflate(2, 2); context.SelectionDisplayInfo.Node = node; context.SelectionDisplayInfo.Bounds = r; context.NodeRenderer.DrawHotTracking(context.SelectionDisplayInfo); } }
private void PaintNodes(NodeCollection nodes,NodeDisplayContext context) { foreach(Node node in nodes) { PaintNode(node, context); } }
private void PaintSelection(NodeDisplayContext context) { if (!this.Tree.MultiSelect && this.Tree.SelectedNode != null && this.Tree.SelectedNode.Visible && this.Tree.SelectionBox && !(this.Tree.HideSelection && !this.Tree.Focused)) { PaintNodeSelection(this.Tree.SelectedNode, context); } else if (this.Tree.MultiSelect && this.Tree.SelectedNodes.Count>0 && this.Tree.SelectionBox && !(this.Tree.HideSelection && !this.Tree.Focused)) { foreach (Node node in Tree.SelectedNodes) { if(node.IsVisible) PaintNodeSelection(node, context); } } }
private void PaintSingleNode(Node node, NodeDisplayContext context) { _PaintedNodes.Add(node); Rectangle r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds,node,context.Offset); TreeRenderer renderer=context.NodeRenderer; if(node.NodeRenderer!=null && node.RenderMode==eNodeRenderMode.Custom) renderer = node.NodeRenderer; bool isSelected = node.IsSelectionVisible && node.IsSelected; // Paint node background ElementStyle style = GetEffectiveNodeBackgroundStyle(node, context); Region backRegion=null; if(style!=null) { context.NodeRendererEventArgs.Graphics=context.Graphics; context.NodeRendererEventArgs.Node = node; context.NodeRendererEventArgs.NodeBounds = r; context.NodeRendererEventArgs.Style = style; if (!node.FullRowBackground) // Node full row backgrounds are drawn first... renderer.DrawNodeBackground(context.NodeRendererEventArgs); ElementStyleDisplayInfo di = new ElementStyleDisplayInfo(style, context.Graphics, context.NodeRendererEventArgs.NodeBounds); di.Bounds.Inflate(1, 1); backRegion=ElementStyleDisplay.GetStyleRegion(di); di.Bounds = r; } if (NodeDisplay.DrawExpandPart(node) && context.ExpandDisplayInfo != null) { r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ExpandBounds, node, context.Offset); context.ExpandDisplayInfo.Node = node; context.ExpandDisplayInfo.ExpandPartBounds = r; context.ExpandDisplayInfo.IsMouseOver = node.MouseOverNodePart == eMouseOverNodePart.Expand; renderer.DrawNodeExpandPart(context.ExpandDisplayInfo); } if (NodeDisplay.HasColumnsVisible(node)) { PaintColumnHeaders(node.NodesColumns, context.Graphics, false); } Region oldRegion=null; if(backRegion!=null) { oldRegion=context.Graphics.Clip; context.Graphics.SetClip(backRegion,CombineMode.Intersect); } ElementStyle cellStyle = null; if (context.CellStyleDefault == null) { cellStyle = new ElementStyle(); cellStyle.TextColor = style.TextColor; cellStyle.TextShadowColor = style.TextShadowColor; cellStyle.TextShadowOffset = style.TextShadowOffset; cellStyle.TextAlignment = style.TextAlignment; cellStyle.TextLineAlignment = style.TextLineAlignment; cellStyle.TextTrimming = style.TextTrimming; cellStyle.WordWrap = style.WordWrap; cellStyle.Font = style.Font; cellStyle.UseMnemonic = style.UseMnemonic; } foreach(Cell cell in node.Cells) { if (!cell.IsVisible) continue; if (cell.StyleNormal != null) { if (context.CellStyleDefault != null) style = context.CellStyleDefault.Copy(); else style = cellStyle.Copy(); style.ApplyStyle(cell.StyleNormal); } else if (context.CellStyleDefault != null) style = context.CellStyleDefault.Copy(); else { if (!cell.Enabled || cell.IsMouseDown && (cell.StyleMouseDown != null || context.CellStyleMouseDown != null) || cell.IsSelected && (cell.StyleSelected != null || context.CellStyleSelected != null) || cell.IsMouseOver && (cell.StyleMouseOver != null || context.CellStyleMouseOver != null)) style = cellStyle.Copy(); else style = cellStyle; } if(!cell.Enabled && cell.StyleDisabled!=null) style.ApplyStyle(cell.StyleDisabled); else if(!cell.Enabled && context.CellStyleDisabled!=null) style.ApplyStyle(context.CellStyleDisabled); else if(cell.IsMouseDown && cell.StyleMouseDown!=null) style.ApplyStyle(cell.StyleMouseDown); else if(cell.IsMouseDown && context.CellStyleMouseDown!=null) style.ApplyStyle(context.CellStyleMouseDown); else { if(cell.IsSelected && cell.StyleSelected!=null) style.ApplyStyle(cell.StyleSelected); else if (cell.IsSelected && context.CellStyleSelected != null && context.CellStyleSelected.Custom) style.ApplyStyle(context.CellStyleSelected); if(cell.IsMouseOver && cell.StyleMouseOver!=null) style.ApplyStyle(cell.StyleMouseOver); else if(cell.IsMouseOver && context.CellStyleMouseOver!=null) style.ApplyStyle(context.CellStyleMouseOver); } r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds,node,context.Offset); if(style!=null) { if(style.Font==null) style.Font=context.DefaultFont; if (isSelected) { style.BackColor = Color.Empty; style.BackColorSchemePart = eColorSchemePart.None; style.BackColor2 = Color.Empty; style.BackColor2SchemePart = eColorSchemePart.None; } Rectangle rCell=cell.BoundsRelative; Rectangle rText=cell.TextContentBounds; rCell.Offset(r.Location); rText.Offset(r.Location); ElementStyleDisplayInfo di=GetElementStyleDisplayInfo(style,context.Graphics,rCell); ElementStyleDisplay.Paint(di); NodeCellRendererEventArgs ci=GetCellDisplayInfo(style,context.Graphics,cell,r.Location, context.ColorScheme); if(ci.Cell.CheckBoxVisible) renderer.DrawCellCheckBox(ci); if(!ci.Cell.Images.LargestImageSize.IsEmpty) renderer.DrawCellImage(ci); renderer.DrawCellText(ci); if (context.View == eView.Tile && node.HasChildNodes && !context.TileGroupLineColor.IsEmpty) renderer.DrawTileGroupLine(new NodeRendererEventArgs(context.Graphics, node, r, style, context.TileGroupLineColor)); } } if (backRegion != null) { context.Graphics.SetClip(oldRegion, CombineMode.Replace); backRegion.Dispose(); } if(oldRegion!=null) oldRegion.Dispose(); }
private void PaintConnector(Node fromNode, Node toNode, NodeDisplayContext context,bool linkConnector, ConnectorPointsCollection connectorPoints) { bool isRootNode = fromNode != null ? IsRootNode(fromNode) : IsRootNode(toNode); if (context.View == eView.Tile || isRootNode && fromNode == null && toNode.Nodes.Count == 0 && toNode.ExpandVisibility != eNodeExpandVisibility.Visible || context.ConnectorDisplayInfo == null) return; context.ConnectorDisplayInfo.FromNode=fromNode; context.ConnectorDisplayInfo.ToNode=toNode; context.ConnectorDisplayInfo.IsRootNode=isRootNode; context.ConnectorDisplayInfo.LinkConnector=linkConnector; if (fromNode != null && fromNode.Style != null) context.ConnectorDisplayInfo.StyleFromNode = fromNode.Style; else context.ConnectorDisplayInfo.StyleFromNode = context.DefaultNodeStyle; if(toNode.Style!=null) context.ConnectorDisplayInfo.StyleToNode=toNode.Style; else context.ConnectorDisplayInfo.StyleToNode=context.DefaultNodeStyle; context.ConnectorDisplayInfo.Offset=context.Offset; /*if(linkConnector) { context.ConnectorDisplayInfo.NodeConnector=this.Tree.LinkConnector; } else*/ if(toNode.SelectedConnectorMarker) { context.ConnectorDisplayInfo.NodeConnector=this.Tree.SelectedPathConnector; } else if(toNode.ParentConnector!=null) { context.ConnectorDisplayInfo.NodeConnector=toNode.ParentConnector; } //else if(isRootNode) //{ // context.ConnectorDisplayInfo.NodeConnector=this.Tree.RootConnector; //} else { context.ConnectorDisplayInfo.NodeConnector=this.Tree.NodesConnector; } if(linkConnector) { context.ConnectorDisplayInfo.ConnectorPoints=connectorPoints; } else { if(connectorPoints!=null) context.ConnectorDisplayInfo.ConnectorPoints=connectorPoints; else context.ConnectorDisplayInfo.ConnectorPoints=null; } context.NodeRenderer.DrawConnector(context.ConnectorDisplayInfo); }
private void PaintAlternateRowBackground(NodeDisplayContext context, NodeCollection nodeCollection) { foreach (Node node in nodeCollection) { if (!node.Visible) continue; Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, context.Offset); if (r.Y > context.ClientRectangle.Bottom) break; if (r.Y >= context.ClientRectangle.Y) { if (context.AlternateRowFlag) { Rectangle backRect = new Rectangle(context.ClientRectangle.X, r.Y - 1, context.ClientRectangle.Width, r.Height + 1); context.Graphics.FillRectangle(context.AlternateRowBrush, backRect); } } context.AlternateRowFlag = !context.AlternateRowFlag; if (node.Expanded && node.HasChildNodes) PaintAlternateRowBackground(context, node.Nodes); } }
private bool PaintNode(Node node, NodeDisplayContext context) { if(!node.Visible) { node.SelectedConnectorMarker = false; return false; } Rectangle r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds,node,context.Offset); if(r.IsEmpty) { node.SelectedConnectorMarker = false; return false; } if (context.GridRowLines && !node.IsDragNode) { DisplayHelp.DrawLine(context.Graphics, context.ClientRectangle.X, r.Bottom+1, context.ClientRectangle.Right, r.Bottom+1, context.GridRowLineColor, 1); } bool paintChildNodes = (node.Expanded && node.Nodes.Count > 0); if (!node.IsDragNode && (node.Parent != null || node.ExpandVisibility != eNodeExpandVisibility.Hidden)) this.PaintConnector(null, node, context, false); if (paintChildNodes) { Node lastChildNode = NodeOperations.GetLastVisibleChildNode(node); if (lastChildNode != null) this.PaintConnector(node, lastChildNode, context, false); } node.SelectedConnectorMarker = false; if (NodeDisplay.HasColumnsVisible(node)) { r.Height += node.ColumnHeaderHeight; r.Width = Math.Max(r.Width, node.NodesColumns.Bounds.Width); } if (r.IntersectsWith(context.ClipRectangle) || context.ClipRectangle.IsEmpty) PaintSingleNode(node, context); if (paintChildNodes) { PaintNodes(node.Nodes, context); } return true; }
private void PaintConnector(Node fromNode, Node toNode, NodeDisplayContext context,bool linkConnector, ConnectorPointsCollection connectorPoints) { bool isRootNode=IsRootNode(fromNode); // if(context.RootConnectorDisplay==null && isRootNode || context.NodesConnectorDisplay==null && !isRootNode || linkConnector && context.LinkConnectorDisplay==null) // return; context.ConnectorDisplayInfo.FromNode=fromNode; context.ConnectorDisplayInfo.ToNode=toNode; context.ConnectorDisplayInfo.IsRootNode=isRootNode; context.ConnectorDisplayInfo.LinkConnector=linkConnector; if(fromNode.Style!=null) context.ConnectorDisplayInfo.StyleFromNode=fromNode.Style; else context.ConnectorDisplayInfo.StyleFromNode=context.DefaultNodeStyle; if(toNode.Style!=null) context.ConnectorDisplayInfo.StyleToNode=toNode.Style; else context.ConnectorDisplayInfo.StyleToNode=context.DefaultNodeStyle; context.ConnectorDisplayInfo.Offset=context.Offset; //NodeConnectorDisplay display=null; if(linkConnector) { context.ConnectorDisplayInfo.NodeConnector=this.Tree.LinkConnector; } else if(toNode.SelectedConnectorMarker) { //display = context.SelectedPathConnectorDisplay; context.ConnectorDisplayInfo.NodeConnector=this.Tree.SelectedPathConnector; } else if(toNode.ParentConnector!=null) { //display=this.GetConnectorDisplay(toNode.ParentConnector); context.ConnectorDisplayInfo.NodeConnector=toNode.ParentConnector; } else if(isRootNode) { //display=context.RootConnectorDisplay; context.ConnectorDisplayInfo.NodeConnector=this.Tree.RootConnector; } else { //display=context.NodesConnectorDisplay; context.ConnectorDisplayInfo.NodeConnector=this.Tree.NodesConnector; } if(linkConnector) { if (connectorPoints != null && connectorPoints.Count > 0) context.ConnectorDisplayInfo.ConnectorPoints=connectorPoints; } else { if(connectorPoints!=null) context.ConnectorDisplayInfo.ConnectorPoints=connectorPoints; else if(toNode.ParentConnectorPoints.Count>0) context.ConnectorDisplayInfo.ConnectorPoints=toNode.ParentConnectorPoints; else context.ConnectorDisplayInfo.ConnectorPoints=null; } context.NodeRenderer.DrawConnector(context.ConnectorDisplayInfo); //if(display!=null) // display.DrawConnector(context.ConnectorDisplayInfo); }
private void PaintAlternateRowBackground(NodeDisplayContext context) { if (this.Tree.DisplayRootNode != null) { context.AlternateRowFlag = true; PaintAlternateRowBackground(context, this.Tree.DisplayRootNode.Nodes); } else { PaintAlternateRowBackground(context, this.Tree.Nodes); } }
/// <summary> /// Paints the treee on canvas. /// </summary> public override void Paint(Graphics g, Rectangle clipRectangle) { base.Paint(g,clipRectangle); // Paint header // Paint Nodes... NodeDisplayContext context=new NodeDisplayContext(); context.Graphics=g; context.DefaultFont=this.Tree.Font; context.ClipRectangle=clipRectangle; context.Offset=this.Offset; context.Styles=this.Tree.Styles; // Setup rendering context.NodeRenderer = m_SystemRenderer; if(this.Tree.NodeRenderer!=null && this.Tree.RenderMode==eNodeRenderMode.Custom) context.NodeRenderer=this.Tree.NodeRenderer; else if(this.Tree.RenderMode==eNodeRenderMode.Professional) context.NodeRenderer = m_ProfRenderer; context.NodeRendererEventArgs=new NodeRendererEventArgs(); if(this.Tree.NodeStyle!=null) context.DefaultNodeStyle=this.Tree.NodeStyle; else context.DefaultNodeStyle=GetDefaultNodeStyle(); if(this.Tree.NodeStyleExpanded!=null) context.ExpandedNodeStyle=this.Tree.NodeStyleExpanded; if(this.Tree.NodeStyleSelected!=null) context.SelectedNodeStyle=this.Tree.NodeStyleSelected; if(this.Tree.NodeStyleMouseOver!=null) context.MouseOverNodeStyle=this.Tree.NodeStyleMouseOver; if(this.Tree.CellStyleDefault!=null) context.CellStyleDefault=this.Tree.CellStyleDefault; // else // context.CellStyleDefault=ElementStyle.GetDefaultCellStyle(context.DefaultNodeStyle); if(this.Tree.CellStyleDisabled!=null) context.CellStyleDisabled=this.Tree.CellStyleDisabled; else context.CellStyleDisabled=ElementStyle.GetDefaultDisabledCellStyle(); if(this.Tree.CellStyleMouseDown!=null) context.CellStyleMouseDown=this.Tree.CellStyleMouseDown; if(this.Tree.CellStyleMouseOver!=null) context.CellStyleMouseOver=this.Tree.CellStyleMouseOver; if(this.Tree.CellStyleSelected!=null) context.CellStyleSelected=this.Tree.CellStyleSelected; else context.CellStyleSelected=ElementStyle.GetDefaultSelectedCellStyle(); // Setup connector //context.RootConnectorDisplay=GetConnectorDisplay(this.Tree.RootConnector); //context.NodesConnectorDisplay=GetConnectorDisplay(this.Tree.NodesConnector); //context.LinkConnectorDisplay=GetConnectorDisplay(this.Tree.LinkConnector); context.ConnectorDisplayInfo=new ConnectorRendererEventArgs(); context.ConnectorDisplayInfo.Graphics=context.Graphics; if(this.Tree.SelectedPathConnector!=null) { // Prepare nodes for path display. Downstream nodes are easily recognized when // path upstream nodes need special treatment to improve performance if(this.Tree.SelectedNode!=null) { Node n=this.Tree.SelectedNode; while(n!=null) { // This marker will be reset once node is painted... n.SelectedConnectorMarker = true; n=n.Parent; } } //context.SelectedPathConnectorDisplay=GetConnectorDisplay(this.Tree.SelectedPathConnector); } // Setup Node Expander Painter context.ExpandDisplayInfo=new NodeExpandPartRendererEventArgs(context.Graphics); context.ExpandDisplayInfo.BackColor=this.Tree.GetColor(this.Tree.ExpandBackColor, this.Tree.ExpandBackColorSchemePart); context.ExpandDisplayInfo.BackColor2=this.Tree.GetColor(this.Tree.ExpandBackColor2, this.Tree.ExpandBackColor2SchemePart); context.ExpandDisplayInfo.BackColorGradientAngle=this.Tree.ExpandBackColorGradientAngle; context.ExpandDisplayInfo.BorderColor=this.Tree.GetColor(this.Tree.ExpandBorderColor, this.Tree.ExpandBorderColorSchemePart); context.ExpandDisplayInfo.ExpandLineColor=this.Tree.GetColor(this.Tree.ExpandLineColor, this.Tree.ExpandLineColorSchemePart); context.ExpandDisplayInfo.Graphics=context.Graphics; context.ExpandDisplayInfo.ExpandButtonType = this.Tree.ExpandButtonType; context.ExpandDisplayInfo.ExpandImage=this.Tree.ExpandImage; context.ExpandDisplayInfo.ExpandImageCollapse=this.Tree.ExpandImageCollapse; //context.ExpandDisplay=this.GetExpandDisplay(this.Tree.ExpandButtonType); // Setup Selection Display //context.SelectionDisplay=new NodeSelectionDisplay(); context.SelectionDisplayInfo=new SelectionRendererEventArgs(); context.SelectionDisplayInfo.Graphics=context.Graphics; context.SelectionDisplayInfo.FillColor=this.Tree.SelectionBoxFillColor; context.SelectionDisplayInfo.BorderColor=this.Tree.SelectionBoxBorderColor; context.SelectionDisplayInfo.Width=this.Tree.SelectionBoxSize; // Setup Node Command Display //context.CommandDisplay=new NodeCommandDisplay(); context.CommandDisplayInfo=new NodeCommandPartRendererEventArgs(context.Graphics); context.CommandDisplayInfo.BackColor=this.Tree.GetColor(this.Tree.CommandBackColor, this.Tree.CommandBackColorSchemePart); context.CommandDisplayInfo.BackColor2=this.Tree.GetColor(this.Tree.CommandBackColor2, this.Tree.CommandBackColor2SchemePart); context.CommandDisplayInfo.BackColorGradientAngle=this.Tree.CommandBackColorGradientAngle; context.CommandDisplayInfo.ForeColor=this.Tree.GetColor(this.Tree.CommandForeColor, this.Tree.CommandForeColorSchemePart); context.CommandDisplayInfo.MouseOverBackColor=this.Tree.GetColor(this.Tree.CommandMouseOverBackColor, this.Tree.CommandMouseOverBackColorSchemePart); context.CommandDisplayInfo.MouseOverBackColor2=this.Tree.GetColor(this.Tree.CommandMouseOverBackColor2, this.Tree.CommandMouseOverBackColor2SchemePart); context.CommandDisplayInfo.MouseOverBackColorGradientAngle=this.Tree.CommandMouseOverBackColorGradientAngle; context.CommandDisplayInfo.MouseOverForeColor=this.Tree.GetColor(this.Tree.CommandMouseOverForeColor, this.Tree.CommandMouseOverForeColorSchemePart); if(this.Tree.DisplayRootNode!=null) this.PaintNode(this.Tree.DisplayRootNode, context); else this.PaintNodes(this.Tree.Nodes, context); Node dragNode=this.Tree.GetDragNode(); if(dragNode!=null && dragNode.Parent==null) { Point p=context.Offset; context.Offset=Point.Empty; PaintNode(dragNode,context); context.Offset=p; } PaintSelection(context); }
private void PaintSingleNode(Node node, NodeDisplayContext context) { Rectangle r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds,node,context.Offset); NodeRenderer renderer=context.NodeRenderer; if(node.NodeRenderer!=null && node.RenderMode==eNodeRenderMode.Custom) renderer = node.NodeRenderer; // Paint node background ElementStyle style=context.DefaultNodeStyle.Copy(); if(node.Style!=null) style=node.Style.Copy(); bool bApllyStyles=true; if(node.MouseOverNodePart==eMouseOverNodePart.Node && style!=null) { ElementStyle mouseOverStyle=context.MouseOverNodeStyle; if(node.StyleMouseOver!=null) mouseOverStyle=node.StyleMouseOver; if (mouseOverStyle != null) { style.ApplyStyle(mouseOverStyle); bApllyStyles = false; } } // On default style apply expanded style if(bApllyStyles && node.Expanded && style!=null) { ElementStyle expandedStyle=context.ExpandedNodeStyle; if(node.StyleExpanded!=null) expandedStyle=node.StyleExpanded; if(expandedStyle!=null) style.ApplyStyle(expandedStyle); } // Apply selected style if needed too if(bApllyStyles && node.IsSelected && style!=null) { ElementStyle selectedStyle=context.SelectedNodeStyle; if(node.StyleSelected!=null) selectedStyle=node.StyleSelected; if(selectedStyle!=null) style.ApplyStyle(selectedStyle); } Region backRegion=null; if(style!=null) { if(style.Font==null) style.Font=context.DefaultFont; context.NodeRendererEventArgs.Graphics=context.Graphics; context.NodeRendererEventArgs.Node = node; context.NodeRendererEventArgs.NodeBounds = r; context.NodeRendererEventArgs.Style = style; renderer.DrawNodeBackground(context.NodeRendererEventArgs); ElementStyleDisplayInfo di=new ElementStyleDisplayInfo(style,context.Graphics,DisplayHelp.GetDrawRectangle(r)); //ElementStyleDisplay.Paint(di); backRegion=ElementStyleDisplay.GetStyleRegion(di); } if(NodeDisplay.DrawExpandPart(node)) { r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.ExpandBounds,node,context.Offset); context.ExpandDisplayInfo.Node=node; context.ExpandDisplayInfo.ExpandPartBounds=r; //context.ExpandDisplayInfo.MouseOver=(node.MouseOverNodePart==eMouseOverNodePart.Expand); //context.ExpandDisplay.DrawExpandButton(context.ExpandDisplayInfo); renderer.DrawNodeExpandPart(context.ExpandDisplayInfo); } // TODO: Support for display of columns should go here // if(node.NodesColumnHeaderVisible) // { // foreach(ColumnHeader col in node.NodesColumns) // { // r=col.Bounds; // r.Offset(context.Offset); // r.Offset(node.Bounds.Location); // using(Pen pen=new Pen(Color.Yellow)) // context.Graphics.DrawRectangle(pen,Display.GetDrawRectangle(r)); // } // } Region oldRegion=null; if(backRegion!=null) { oldRegion=context.Graphics.Clip; context.Graphics.SetClip(backRegion,CombineMode.Replace); } if(!node.CommandBoundsRelative.IsEmpty) { r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.CommandBounds,node,context.Offset); context.CommandDisplayInfo.Node=node; context.CommandDisplayInfo.CommandPartBounds=r; context.CommandDisplayInfo.Graphics = context.Graphics; //context.CommandDisplay.DrawCommandButton(context.CommandDisplayInfo); renderer.DrawNodeCommandPart(context.CommandDisplayInfo); context.CommandDisplayInfo.Graphics = null; } ElementStyle cellStyle = null; if(context.CellStyleDefault==null) { cellStyle=new ElementStyle(); cellStyle.TextColor = style.TextColor; cellStyle.TextShadowColor = style.TextShadowColor; cellStyle.TextShadowOffset = style.TextShadowOffset; cellStyle.TextAlignment = style.TextAlignment; cellStyle.TextLineAlignment = style.TextLineAlignment; cellStyle.WordWrap = style.WordWrap; cellStyle.Font = style.Font; } foreach(Cell cell in node.Cells) { if(cell.StyleNormal!=null) style=cell.StyleNormal; else if(context.CellStyleDefault!=null) style=context.CellStyleDefault.Copy(); else style = cellStyle; if(!cell.Enabled && cell.StyleDisabled!=null) style.ApplyStyle(cell.StyleDisabled); else if(!cell.Enabled && context.CellStyleDisabled!=null) style.ApplyStyle(context.CellStyleDisabled); else if(cell.IsMouseDown && cell.StyleMouseDown!=null) style.ApplyStyle(cell.StyleMouseDown); else if(cell.IsMouseDown && context.CellStyleMouseDown!=null) style.ApplyStyle(context.CellStyleMouseDown); else { if(cell.IsSelected && cell.StyleSelected!=null) style.ApplyStyle(cell.StyleSelected); else if(cell.IsSelected && context.CellStyleSelected!=null) style.ApplyStyle(context.CellStyleSelected); if(cell.IsMouseOver && cell.StyleMouseOver!=null) style.ApplyStyle(cell.StyleMouseOver); else if(cell.IsMouseOver && context.CellStyleMouseOver!=null) style.ApplyStyle(context.CellStyleMouseOver); } r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeBounds,node,context.Offset); if(style!=null) { if(style.Font==null) style.Font=context.DefaultFont; Rectangle rCell=cell.BoundsRelative; Rectangle rText=cell.TextContentBounds; rCell.Offset(r.Location); rText.Offset(r.Location); ElementStyleDisplayInfo di=GetElementStyleDisplayInfo(style,context.Graphics,DisplayHelp.GetDrawRectangle(rCell)); ElementStyleDisplay.Paint(di); NodeCellRendererEventArgs ci=GetCellDisplayInfo(style,context.Graphics,cell,r.Location, rCell, rText); if(ci.Cell.CheckBoxVisible) renderer.DrawCellCheckBox(ci); //CellDisplay.PaintCellCheckBox(ci); if(!ci.Cell.Images.LargestImageSize.IsEmpty) renderer.DrawCellImage(ci); //CellDisplay.PaintCellImage(ci); renderer.DrawCellText(ci) ; //CellDisplay.PaintText(ci); //CellDisplay.PaintCell(ci); } } if(backRegion!=null) context.Graphics.SetClip(oldRegion,CombineMode.Replace); }
private void PaintNode(Node node, NodeDisplayContext context) { if(!node.Visible) { node.SelectedConnectorMarker = false; return; } Rectangle r=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds,node,context.Offset); if(r.IsEmpty) { node.SelectedConnectorMarker = false; return; } if(node.Parent!=null && !node.Parent.BoundsRelative.IsEmpty) { this.PaintConnector(node, context); } if(node.HasLinkedNodes) { foreach(LinkedNode linkedNode in node.LinkedNodes) { if(!linkedNode.Node.IsVisible) continue; this.PaintConnector(node,linkedNode.Node, context,true, linkedNode.ConnectorPoints); } } node.SelectedConnectorMarker = false; if(r.IntersectsWith(context.ClipRectangle) || context.ClipRectangle.IsEmpty) PaintSingleNode(node, context); // else if(node.HasHostedControls) // Move controls to proper location // MoveHostedControls(node, context); if(node.Expanded && node.Nodes.Count>0) PaintNodes(node.Nodes,context); }
private Node PaintNodes(NodeCollection nodes, NodeDisplayContext context) { Node lastPainted = null; int count = nodes.Count; int start = 0; // Find first node to render in case there are lot of them if (context.View == eView.Tree && count > 99 && /*this.Tree.NodesConnector == null &&*/ context.Offset.Y != 0) { int testIndex = count / 2; int chunk = testIndex; while (testIndex > 0 && testIndex < count) { chunk = chunk / 2; Node node = nodes[testIndex]; Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, context.Offset); if (chunk > 0 && r.Y > context.ClipRectangle.Bottom) // go back testIndex -= chunk; else if (chunk > 0 && r.Y < context.ClipRectangle.Y) // go forward testIndex += chunk; else { if (testIndex == 0) break; testIndex--; for (int i = testIndex; i >= 0; i--) { node = nodes[i]; r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, context.Offset); if (r.Y < context.ClipRectangle.Y) { start = i; break; } } break; } } } bool clipEmpty = context.ClipRectangle.IsEmpty; for (int i = start; i < count; i++) { Node node = nodes[i]; if (PaintNode(node, context)) { lastPainted = node; Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, context.Offset); if (!clipEmpty && r.Y > context.ClipRectangle.Bottom && !context.ClientRectangle.IsEmpty) break; } } return lastPainted; }
private void PaintGridLines(NodeDisplayContext context) { PaintGridLines(context, Tree.Columns, context.ClientRectangle); }
private NodeDisplayContext CreateDisplayContext(Graphics g, Rectangle clipRectangle) { NodeDisplayContext context = new NodeDisplayContext(); context.Graphics = g; context.DefaultFont = this.Tree.Font; context.ClipRectangle = clipRectangle; context.Offset = this.Offset; context.Styles = this.Tree.Styles; context.IsBackgroundSelection = IsBackgroundSelection; context.ClientRectangle = ElementStyleLayout.GetInnerRect(Tree.BackgroundStyle, Tree.ClientRectangle); context.ColorScheme = Tree.ColorScheme; context.GridRowLines = Tree.GridRowLines; context.GridRowLineColor = Tree.GridLinesColor; context.CellSelection = Tree.SelectionPerCell; context.AlternateRowBrush = CreateBrush(Tree.AlternateRowColor); context.DrawAlternateRowBackground = !Tree.AlternateRowColor.IsEmpty; context.View = this.Tree.View; context.TileGroupLineColor = this.Tree.TileGroupLineColor; // Setup rendering context.NodeRenderer = m_SystemRenderer; if (this.Tree.NodeRenderer != null && this.Tree.RenderMode == eNodeRenderMode.Custom) context.NodeRenderer = this.Tree.NodeRenderer; if (GlobalManager.Renderer is Office2007Renderer) { context.NodeRenderer.Office2007ColorTable = ((Office2007Renderer)GlobalManager.Renderer).ColorTable; context.NodeRenderer.ColorTable = context.NodeRenderer.Office2007ColorTable.AdvTree; } context.NodeRendererEventArgs = new NodeRendererEventArgs(); if (this.Tree.NodeStyle != null) context.DefaultNodeStyle = this.Tree.NodeStyle; else context.DefaultNodeStyle = GetDefaultNodeStyle(); if (this.Tree.NodeStyleExpanded != null) context.ExpandedNodeStyle = this.Tree.NodeStyleExpanded; if (this.Tree.NodeStyleSelected != null) context.SelectedNodeStyle = this.Tree.NodeStyleSelected; if (this.Tree.NodeStyleMouseOver != null) context.MouseOverNodeStyle = this.Tree.NodeStyleMouseOver; if (this.Tree.CellStyleDefault != null) context.CellStyleDefault = this.Tree.CellStyleDefault; if (this.Tree.CellStyleDisabled != null) context.CellStyleDisabled = this.Tree.CellStyleDisabled; else context.CellStyleDisabled = ElementStyle.GetDefaultDisabledCellStyle(); if (this.Tree.CellStyleMouseDown != null) context.CellStyleMouseDown = this.Tree.CellStyleMouseDown; if (this.Tree.CellStyleMouseOver != null) context.CellStyleMouseOver = this.Tree.CellStyleMouseOver; if (this.Tree.CellStyleSelected != null) context.CellStyleSelected = this.Tree.CellStyleSelected; else context.CellStyleSelected = ElementStyle.GetDefaultSelectedCellStyle(); // Setup connector context.ConnectorDisplayInfo = new ConnectorRendererEventArgs(); context.ConnectorDisplayInfo.Graphics = context.Graphics; // Setup Node Expander Painter context.ExpandDisplayInfo = new NodeExpandPartRendererEventArgs(context.Graphics); context.ExpandDisplayInfo.BackColor = this.Tree.GetColor(this.Tree.ExpandBackColor, this.Tree.ExpandBackColorSchemePart); context.ExpandDisplayInfo.BackColor2 = this.Tree.GetColor(this.Tree.ExpandBackColor2, this.Tree.ExpandBackColor2SchemePart); context.ExpandDisplayInfo.BackColorGradientAngle = this.Tree.ExpandBackColorGradientAngle; context.ExpandDisplayInfo.BorderColor = this.Tree.GetColor(this.Tree.ExpandBorderColor, this.Tree.ExpandBorderColorSchemePart); context.ExpandDisplayInfo.ExpandLineColor = this.Tree.GetColor(this.Tree.ExpandLineColor, this.Tree.ExpandLineColorSchemePart); context.ExpandDisplayInfo.Graphics = context.Graphics; context.ExpandDisplayInfo.ExpandButtonType = this.Tree.ExpandButtonType; context.ExpandDisplayInfo.ExpandImage = this.Tree.ExpandImage; context.ExpandDisplayInfo.ExpandImageCollapse = this.Tree.ExpandImageCollapse; // Setup Selection Display context.SelectionDisplayInfo = new SelectionRendererEventArgs(); context.SelectionDisplayInfo.Graphics = context.Graphics; context.SelectionDisplayInfo.SelectionBoxStyle = this.Tree.SelectionBoxStyle; context.SelectionDisplayInfo.TreeActive = this.Tree.IsKeyboardFocusWithin || !this.Tree.SelectionFocusAware; return context; }
private void PaintGridLines(NodeDisplayContext context, ColumnHeaderCollection columnHeaderCollection, Rectangle bounds) { Color color = this.Tree.GridLinesColor.IsEmpty ? context.NodeRenderer.ColorTable.GridLines : this.Tree.GridLinesColor; Graphics g = context.Graphics; for (int i = 0; i < columnHeaderCollection.Count; i++) { ColumnHeader columnHeader = columnHeaderCollection.ColumnAtDisplayIndex(i); if (!columnHeader.Visible || columnHeader.Bounds.Width <= 0) continue; Rectangle r = columnHeader.Bounds; r.Offset(context.Offset); if (columnHeaderCollection.ParentNode == null) { r.Offset(bounds.Location); if (!columnHeader.CellsBackColor.IsEmpty) { SmoothingMode oldSmoothing = g.SmoothingMode; g.SmoothingMode = SmoothingMode.None; Rectangle rBack = new Rectangle(r.X - 5, context.ClientRectangle.Y, r.Width + 4, context.ClientRectangle.Height); using (SolidBrush brush = new SolidBrush(columnHeader.CellsBackColor)) g.FillRectangle(brush, rBack); g.SmoothingMode = oldSmoothing; } } DisplayHelp.DrawLine(g, r.Right - (columnHeader.IsLastVisible ? 0 : 1), bounds.Y, r.Right - (columnHeader.IsLastVisible ? 0 : 1), bounds.Bottom, color, 1); } }
private ElementStyle GetEffectiveNodeBackgroundStyle(Node node, NodeDisplayContext context) { ElementStyle style = context.DefaultNodeStyle.Copy(); bool bApplyStyles = true; bool isSelected = (node.IsSelected && node.IsSelectionVisible); if (isSelected && context.SelectedNodeStyle == null && node.StyleSelected == null && !node.FullRowBackground) bApplyStyles = false; if (isSelected && (context.SelectedNodeStyle == null || context.SelectedNodeStyle.TextColor.IsEmpty) && (node.StyleSelected == null || node.StyleSelected.TextColor.IsEmpty)) { eSelectionStyle ss = Tree.SelectionBoxStyle; TreeSelectionColors table = context.NodeRenderer.ColorTable.Selection; if (context.SelectionDisplayInfo.TreeActive) { if (ss == eSelectionStyle.FullRowSelect && !table.FullRowSelect.TextColor.IsEmpty) style.TextColor = table.FullRowSelect.TextColor; else if (ss == eSelectionStyle.HighlightCells && !table.HighlightCells.TextColor.IsEmpty) style.TextColor = table.HighlightCells.TextColor; else if (ss == eSelectionStyle.NodeMarker && !table.NodeMarker.TextColor.IsEmpty) style.TextColor = table.NodeMarker.TextColor; } else { if (ss == eSelectionStyle.FullRowSelect && !table.FullRowSelectInactive.TextColor.IsEmpty) style.TextColor = table.FullRowSelectInactive.TextColor; else if (ss == eSelectionStyle.HighlightCells && !table.HighlightCellsInactive.TextColor.IsEmpty) style.TextColor = table.HighlightCellsInactive.TextColor; else if (ss == eSelectionStyle.NodeMarker && !table.NodeMarkerInactive.TextColor.IsEmpty) style.TextColor = table.NodeMarkerInactive.TextColor; } } else if (this.Tree.HotTracking && !node.IsSelected && node.Selectable && this.Tree.MouseOverNode == node) { SelectionColorTable table = context.NodeRenderer.ColorTable.Selection.NodeHotTracking; if (!table.TextColor.IsEmpty) style.TextColor = table.TextColor; } if (node.Style != null) { if (bApplyStyles) style.ApplyStyle(node.Style); //=node.Style.Copy(); else style.ApplyFontStyle(node.Style); } if (bApplyStyles && node.MouseOverNodePart == eMouseOverNodePart.Node && style != null) { ElementStyle mouseOverStyle = context.MouseOverNodeStyle; if (node.StyleMouseOver != null) { mouseOverStyle = node.StyleMouseOver; bApplyStyles = false; } if (mouseOverStyle != null) { style.ApplyStyle(mouseOverStyle); bApplyStyles = false; } } // On default style apply expanded style if (bApplyStyles && node.Expanded && style != null) { ElementStyle expandedStyle = context.ExpandedNodeStyle; if (node.StyleExpanded != null) expandedStyle = node.StyleExpanded; if (expandedStyle != null) style.ApplyStyle(expandedStyle); } // Apply selected style if needed too if (bApplyStyles && node.IsSelected && style != null) { ElementStyle selectedStyle = context.SelectedNodeStyle; if (node.StyleSelected != null) selectedStyle = node.StyleSelected; if (selectedStyle != null) style.ApplyStyle(selectedStyle); } if (style != null) { if (style.Font == null) style.Font = context.DefaultFont; } return style; }
private void PaintFullRowBackgroundForNodes(NodeDisplayContext context, ArrayList nodesCollection) { Rectangle clientRectangle = context.ClientRectangle; if (this.Tree.VScrollBar != null) clientRectangle.Width -= this.Tree.VScrollBar.Width; foreach (Node node in nodesCollection) { Rectangle r = NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, node, context.Offset); if (!r.IsEmpty) { r.X = clientRectangle.X; r.Width = clientRectangle.Width; r.Inflate(0, 1); } if (r.IsEmpty || !r.IntersectsWith(context.ClipRectangle) && !context.ClipRectangle.IsEmpty) continue; ElementStyle style = GetEffectiveNodeBackgroundStyle(node, context); if (style == null) continue; TreeRenderer renderer = context.NodeRenderer; if (node.NodeRenderer != null && node.RenderMode == eNodeRenderMode.Custom) renderer = node.NodeRenderer; if (style != null) { context.NodeRendererEventArgs.Graphics = context.Graphics; context.NodeRendererEventArgs.Node = node; context.NodeRendererEventArgs.NodeBounds = r; context.NodeRendererEventArgs.Style = style; renderer.DrawNodeBackground(context.NodeRendererEventArgs); } } }
private void PaintConnector(Node fromNode, Node toNode, NodeDisplayContext context,bool linkConnector) { PaintConnector(fromNode, toNode, context, linkConnector, null); }
private void PaintDragInsertMarker(NodeDisplayContext context, Rectangle dragInsertionBounds) { if (dragInsertionBounds.IsEmpty) return; context.NodeRenderer.DrawDragDropMarker(new DragDropMarkerRendererEventArgs(context.Graphics, dragInsertionBounds)); }
private void PaintConnector(Node toNode, NodeDisplayContext context) { PaintConnector(toNode.Parent, toNode, context,false); }
private void PaintSelection(NodeDisplayContext context) { if(this.Tree.SelectedNode!=null && this.Tree.SelectedNode.Visible && this.Tree.SelectionBox) { context.SelectionDisplayInfo.Node=this.Tree.SelectedNode; context.SelectionDisplayInfo.Bounds=NodeDisplay.GetNodeRectangle(eNodeRectanglePart.NodeContentBounds, context.SelectionDisplayInfo.Node, context.Offset); //context.SelectionDisplay.PaintSelection(context.SelectionDisplayInfo); context.NodeRenderer.DrawSelection(context.SelectionDisplayInfo); } }