コード例 #1
0
		private void ProcessRootNode(NodeLayoutContextInfo layoutInfo)
		{
			if(m_DiagramFlow==eDiagramFlow.RightToLeft || m_DiagramFlow==eDiagramFlow.BottomToTop)
				layoutInfo.MapPositionNear=true;
			ProcessSubNode(layoutInfo);
			PositionRootNode(layoutInfo);
		}
コード例 #2
0
		private void ProcessNode(NodeLayoutContextInfo layoutInfo)
		{
			LayoutNode(layoutInfo);
			layoutInfo.ContextNode.SetBounds(new Rectangle(layoutInfo.Left,layoutInfo.Top,layoutInfo.ContextNode.BoundsRelative.Width,layoutInfo.ContextNode.BoundsRelative.Height));
			//OffsetNodeLocation(layoutInfo.ContextNode,layoutInfo.Left,layoutInfo.Top);
			layoutInfo.Top+=(layoutInfo.ContextNode.BoundsRelative.Height+this.NodeVerticalSpacing);
		}
コード例 #3
0
		// Assumes that layoutInfo is up-to-date and that Node that is connected with
		// columns is already processed and it's size and location calculated.
		// layoutInfo.Top member reflects the next position below the node
		// layoutInfo.LevelOffset should reflect the X offset for the child nodes.
		public static int LayoutColumnHeader(NodeLayoutContextInfo layoutInfo,int x, int y, int clientWidth, int cellHorizontalSpacing)
		{
			Node node=layoutInfo.ContextNode;
            int height=0;
			
			foreach(ColumnHeader col in node.NodesColumns)
			{
				if(!col.Visible)
					continue;

				if(col.SizeChanged)
				{
					// Column for child nodes is always placed below the current node and
					// is not included in the node's rectangle
					Rectangle bounds=Rectangle.Empty;
					bounds.X=x;
					bounds.Y=y;
					if(col.Width.Relative>0)
						bounds.Width=(clientWidth*col.Width.Relative)/100-1;
					else
						bounds.Width=col.Width.Absolute;

					if(col.StyleNormal=="" && col.StyleMouseDown=="" && col.StyleMouseOver=="")
					{
						bounds.Height=layoutInfo.DefaultHeaderSize.Height;
					}
					else
					{
						Size sz=Size.Empty;
						if(col.StyleNormal!="")
						{
							ElementStyleLayout.CalculateStyleSize(layoutInfo.Styles[col.StyleNormal],layoutInfo.DefaultFont);
							sz=layoutInfo.Styles[col.StyleNormal].Size;
						}
												
						if(sz.Height==0)
							bounds.Height=layoutInfo.DefaultHeaderSize.Height;
						else
							bounds.Height=sz.Height;
					}

					col.SetBounds(bounds);
					col.SizeChanged=false;
					
					x+=(bounds.Width+cellHorizontalSpacing);

					if(bounds.Height>height)
						height=bounds.Height;
				}
				else if(col.Bounds.Height>height)
					height=col.Bounds.Height;
			}

			return height;
		}
コード例 #4
0
		private void ProcessNode(NodeLayoutContextInfo layoutInfo)
		{
			Node node=layoutInfo.ContextNode;
			if(node.SizeChanged)
			{
				// Calculate size of the node itself...
				LayoutNode(layoutInfo);

				// Calculate size and location of node column header if any
//				if(node.NodesColumnHeaderVisible)
//				{
//					layoutInfo.Left+=this.NodeLevelOffset;
//					LayoutColumnHeader(layoutInfo);
//					layoutInfo.Left-=this.NodeLevelOffset;
//				}
			}
			else if(node.BoundsRelative.Top!=layoutInfo.Top)
			{
				// Adjust top position
				node.SetBounds(new Rectangle(node.BoundsRelative.X,layoutInfo.Top,node.BoundsRelative.Width,node.BoundsRelative.Height));
				foreach(Cell c in node.Cells)
					c.SetBounds(new Rectangle(c.BoundsRelative.X,layoutInfo.Top,c.BoundsRelative.Width,c.BoundsRelative.Height));
			}

			// Need to set the Top position properly
			layoutInfo.Top+=(node.BoundsRelative.Height+this.NodeVerticalSpacing);
//			if(node.Expanded && node.NodesColumnHeaderVisible && node.NodesColumns.Count>0)
//				layoutInfo.Top+=node.ColumnHeaderHeight;
			
			if(node.Expanded)
			{
				int originalLevelOffset=layoutInfo.Left;
				layoutInfo.Left+=this.NodeLevelOffset;
				
				ArrayList parentColumns=layoutInfo.ChildColumns;
				ArrayList childColumns=GetNodeColumnInfo(node);

				foreach(Node childNode in node.Nodes)
				{
					layoutInfo.ContextNode=childNode;
					layoutInfo.ChildColumns=childColumns;
					ProcessNode(layoutInfo);
				}
				layoutInfo.ChildColumns=parentColumns;

				layoutInfo.ContextNode=node;
				layoutInfo.Left=originalLevelOffset;
			}
		}
コード例 #5
0
		private void PositionRootNode(NodeLayoutContextInfo layoutInfo)
		{
			Point location=Point.Empty;
			Node root=layoutInfo.ContextNode;
			switch(m_DiagramFlow)
			{
				case eDiagramFlow.LeftToRight:
				{
					location.Y=(root.ChildNodesBounds.Height-root.BoundsRelative.Height)/2;
					break;
				}
				case eDiagramFlow.RightToLeft:
				{
					location.X=root.ChildNodesBounds.Width+this.NodeHorizontalSpacing;
					location.Y=(root.ChildNodesBounds.Height-root.BoundsRelative.Height)/2;
					break;
				}
				case eDiagramFlow.TopToBottom:
				{
					location.X=0; //(root.ChildNodesBounds.Width-root.Bounds.Width)/2;
					break;
				}
				case eDiagramFlow.BottomToTop:
				{
					location.X=root.ChildNodesBounds.Width; //-root.Bounds.Width; //-root.Bounds.Width)/2;
					location.Y=root.ChildNodesBounds.Height+this.NodeVerticalSpacing; //-root.Bounds.Height; //+this.NodeVerticalSpacing;
					break;
				}
			}
			OffsetNodeLocation(root,location.X,location.Y);

			Rectangle area=Rectangle.Empty;
			area=Rectangle.Union(area,root.BoundsRelative);

			PositionSubNodes(root);
			
			area=Rectangle.Union(area,root.ChildNodesBounds);
			root.ChildNodesBounds=area;
			m_Width=area.Width;
			m_Height=area.Height;
		}
コード例 #6
0
		protected virtual NodeLayoutContextInfo GetDefaultNodeLayoutContextInfo(System.Drawing.Graphics graphics)
		{
			NodeLayoutContextInfo layoutInfo=new NodeLayoutContextInfo();
			layoutInfo.ClientRectangle=m_ClientArea;
			layoutInfo.DefaultColumns=this.GetDefaultColumnInfo();
			layoutInfo.ChildColumns=null;
			layoutInfo.Left=0;
			layoutInfo.Top=0; // TODO: Include Columns if visible into this...
			layoutInfo.DefaultFont=m_Tree.Font;
			layoutInfo.LeftToRight=(this.LeftRight==System.Windows.Forms.LeftRightAlignment.Left);
			layoutInfo.Graphics=graphics;
			layoutInfo.Styles=m_Tree.Styles;
			if(m_Tree.CellLayout!=eCellLayout.Default)
				layoutInfo.CellLayout=m_Tree.CellLayout;
			if(m_Tree.CellPartLayout!=eCellPartLayout.Default)
				layoutInfo.CellPartLayout=m_Tree.CellPartLayout;
				
			if(m_Tree.NodeStyle!=null)
				layoutInfo.DefaultNodeStyle=m_Tree.NodeStyle;

			if(m_Tree.CellStyleDefault!=null)
				layoutInfo.DefaultCellStyle=m_Tree.CellStyleDefault;
			else
				layoutInfo.DefaultCellStyle=ElementStyle.GetDefaultCellStyle(layoutInfo.DefaultNodeStyle);

			// Determine size of the default Column Header
			if(m_Tree.ColumnStyleNormal!=null)
			{
				ElementStyleLayout.CalculateStyleSize(m_Tree.ColumnStyleNormal,layoutInfo.DefaultFont);
				layoutInfo.DefaultHeaderSize=m_Tree.ColumnStyleNormal.Size;
			}

			if(layoutInfo.DefaultHeaderSize.IsEmpty)
				layoutInfo.DefaultHeaderSize.Height=layoutInfo.DefaultFont.Height+4;

			return layoutInfo;
		}
コード例 #7
0
		private void ProcessRootNode(NodeLayoutContextInfo layoutInfo)
		{
			Node node=layoutInfo.ContextNode;

			// Center root node on the screen
			//if(node.SizeChanged)
			//{
				// Calculate size of the node itself...
				LayoutNode(layoutInfo);

				// Calculate size and location of node column header if any
				//				if(node.NodesColumnHeaderVisible)
				//				{
				//					LayoutColumnHeader(layoutInfo);
				//				}
			//}
			
			
			//			if(node.Expanded && node.NodesColumnHeaderVisible && node.NodesColumns.Count>0)
			//				layoutInfo.Top+=node.ColumnHeaderHeight;
			NodesMapPosition positions=NodesMapPosition.Empty;
			bool bNear=false;
			if(node.Expanded)
			{
				if(node.NodesColumns.Count>0)
					layoutInfo.ChildColumns=GetNodeColumnInfo(node);
				foreach(Node childNode in node.Nodes)
				{
					if(!childNode.Visible)
						continue;

					layoutInfo.ContextNode=childNode;
					
					if(bNear || childNode.MapSubRootPosition==eMapPosition.Near)
					{
						layoutInfo.MapPositionNear=true;
						ProcessSubNode(layoutInfo);

						positions.Near.Add(childNode);
						positions.NearHeight+=GetTotalChildNodeHeight(childNode);
						bNear=true;
					}
					else if(childNode.MapSubRootPosition==eMapPosition.Far)
					{
						layoutInfo.MapPositionNear=false;
						ProcessSubNode(layoutInfo);

						positions.Far.Add(childNode);
						positions.FarHeight+=GetTotalChildNodeHeight(childNode);
					}
					else
						positions.Default.Add(childNode);
				}

				// Assign nodes to appropriate sides....
				if(positions.Default.Count>0)
				{
					int toFar=0;
					if(positions.Near.Count==0 && positions.Far.Count==0 && positions.Default.Count<=4)
						toFar=2;
					else
						toFar=(int)Math.Ceiling((double)((positions.Near.Count-positions.Far.Count+positions.Default.Count))/2);
					for(int i=0;i<toFar;i++)
					{
						layoutInfo.ContextNode=positions.Default[0] as Node;
						if(m_MapFlow==eMapFlow.RightToLeft)
							layoutInfo.MapPositionNear=true;
						else
							layoutInfo.MapPositionNear=false;
						ProcessSubNode(layoutInfo);

						positions.Far.Add(positions.Default[0]);
						positions.FarHeight+=GetTotalChildNodeHeight(positions.Default[0] as Node);
						positions.Default.RemoveAt(0);
						if(positions.Default.Count==0)
							break;
					}
					for(int i=0;i<positions.Default.Count;i++)
					{
						layoutInfo.ContextNode=positions.Default[i] as Node;
						if(m_MapFlow==eMapFlow.LeftToRight)
							layoutInfo.MapPositionNear=false;
						else
							layoutInfo.MapPositionNear=true;
						ProcessSubNode(layoutInfo);

						positions.Near.Add(positions.Default[i]);
						positions.NearHeight+=GetTotalChildNodeHeight(positions.Default[i] as Node); //+this.NodeVerticalSpacing;
					}
					positions.Default.Clear();
				}

				layoutInfo.ChildColumns=null;
				layoutInfo.ContextNode=node;
			}

			// Set the position of the root node
            Point pRoot = new Point(0, 0);
			pRoot.Offset(node.Offset,0);

			// Adjust top position
			node.SetBounds(new Rectangle(pRoot,node.BoundsRelative.Size));
			node.ExpandPartRectangleRelative.Offset(pRoot);
			foreach(Cell c in node.Cells)
				c.BoundsRelative.Offset(pRoot);

			// Set the position of the child nodes
			if(node.Expanded)
			{
				PositionCenterRootSubNodes(node, positions);
			}
			else
			{
				node.ChildNodesBounds = Rectangle.Empty;
				m_Width = node.Bounds.Width;
				m_Height = node.Bounds.Height;
			}
		}
コード例 #8
0
			private Size LayoutCellsVertical(NodeLayoutContextInfo layoutInfo, int x, int y)
			{
				Node node=layoutInfo.ContextNode;
				int height=0, width=0;
				eHorizontalAlign align=eHorizontalAlign.Center;
				int iVisibleCells=0;

				for(int i=0;i<node.Cells.Count;i++)
				{
					Cell cell=node.Cells[i];

					bool bCellVisible=true;

					// Setup cell layout helper class
					LayoutCellInfo cellLayout=this.GetLayoutCellInfo();
					cellLayout.Top=y;
					cellLayout.Left=x;
					cellLayout.CellWidth=0;
					cellLayout.ContextCell=cell;
					cellLayout.Graphics=layoutInfo.Graphics;
					cellLayout.LeftToRight=layoutInfo.LeftToRight;
					cellLayout.Font=layoutInfo.DefaultFont;
					if(cell.Layout!=eCellPartLayout.Default)
						cellLayout.VerticalPartAlignment=(cell.Layout==eCellPartLayout.Vertical);
					else if(layoutInfo.CellPartLayout!=eCellPartLayout.Default)
						cellLayout.VerticalPartAlignment=(layoutInfo.CellPartLayout==eCellPartLayout.Vertical);
					
					if(layoutInfo.DefaultColumns.Count>0 || layoutInfo.ChildColumns!=null && layoutInfo.ChildColumns.Count>0)
					{
						ColumnInfo ci=null;
						if(layoutInfo.ChildColumns!=null && layoutInfo.ChildColumns.Count>0)
							ci=layoutInfo.ChildColumns[i] as ColumnInfo;
						else
							ci=layoutInfo.DefaultColumns[i] as ColumnInfo;
					
						bCellVisible=ci.Visible;
						cellLayout.CellWidth=ci.Width;
					}

					// Prepare union style
					if(cell.StyleNormal!=null)
						cellLayout.LayoutStyle=cell.StyleNormal;
					else
						cellLayout.LayoutStyle=layoutInfo.DefaultCellStyle;

					this.LayoutSingleCell(cellLayout);

					cell.SetVisible(bCellVisible);
					if(bCellVisible)
					{
						iVisibleCells++;
						y+=cell.BoundsRelative.Height;
						height+=cell.BoundsRelative.Height;
						if(cell.BoundsRelative.Height>0)
						{
							y+=this.CellVerticalSpacing;
							height+=this.CellVerticalSpacing;
						}
						if(cell.BoundsRelative.Width>width)
							width=cell.BoundsRelative.Width;
					}
				}

				// Take last added spacing off
				y-=this.CellVerticalSpacing;
				height-=this.CellVerticalSpacing;

				// Additional pass needed if horizontal alignment is other than left and there is more than one cell visible
				if(align!=eHorizontalAlign.Left && iVisibleCells>1)
				{
					foreach(Cell cell in node.Cells)
					{
						if(!cell.IsVisible)
							continue;
						if(align==eHorizontalAlign.Center)
							this.Offset(cell,(width-cell.BoundsRelative.Width)/2,0);
						else // Right aligned cells
							this.Offset(cell,width-cell.BoundsRelative.Width,0);
					}
				}

				return new Size(width,height);
			}
コード例 #9
0
		private void ProcessSubNode(NodeLayoutContextInfo layoutInfo)
		{
			Node node=layoutInfo.ContextNode;

			//if(node.SizeChanged)
			//{
				// Calculate size of the node itself...
				LayoutNode(layoutInfo);
			//}
			//else
			//	node.SetBounds(new Rectangle(Point.Empty,node.Bounds.Size));
			
			if(node.Expanded && node.AnyVisibleNodes)
			{
				ArrayList parentColumns=layoutInfo.ChildColumns;
				ArrayList childColumns=GetNodeColumnInfo(node);

				if(node.NodesColumns.Count>0)
					layoutInfo.ChildColumns=GetNodeColumnInfo(node);
				Rectangle childNodesBounds=Rectangle.Empty;
				foreach(Node childNode in node.Nodes)
				{
					if(!childNode.Visible)
						continue;

					layoutInfo.ContextNode=childNode;
					layoutInfo.ChildColumns=childColumns;
					ProcessSubNode(layoutInfo);

					childNodesBounds.Height+=(Math.Max(childNode.BoundsRelative.Height,childNode.ChildNodesBounds.Height)+this.NodeVerticalSpacing);
					childNodesBounds.Width=Math.Max(childNodesBounds.Width,childNode.BoundsRelative.Width+(childNode.ChildNodesBounds.Width>0?this.NodeHorizontalSpacing+childNode.ChildNodesBounds.Width:0));
				}
				
				layoutInfo.ChildColumns=parentColumns;

				if(childNodesBounds.Height>0)
					childNodesBounds.Height-=this.NodeVerticalSpacing;
				node.ChildNodesBounds=childNodesBounds;
				layoutInfo.ChildColumns=null;
				layoutInfo.ContextNode=node;
			}
			else node.ChildNodesBounds=Rectangle.Empty;
		}
コード例 #10
0
			public Size LayoutCells(NodeLayoutContextInfo layoutInfo, int x, int y)
			{
				eCellLayout layout=layoutInfo.CellLayout;
				if(layoutInfo.ContextNode.CellLayout!=layoutInfo.CellLayout && layoutInfo.ContextNode.CellLayout!=eCellLayout.Default)
					layout=layoutInfo.ContextNode.CellLayout;
				if(layout==eCellLayout.Horizontal || layout==eCellLayout.Default)
					return this.LayoutCellsHorizontal(layoutInfo,x,y);
				else
					return this.LayoutCellsVertical(layoutInfo,x,y);
			}
コード例 #11
0
			private Size LayoutCellsHorizontal(NodeLayoutContextInfo layoutInfo, int x, int y)
			{
				Node node=layoutInfo.ContextNode;
				int height=0, width=0;

				for(int i=0;i<node.Cells.Count;i++)
				{
					Cell cell=node.Cells[i];

					bool bCellVisible=true;

					// Setup cell layout helper class
					LayoutCellInfo cellLayout=this.GetLayoutCellInfo();
					cellLayout.Top=y;
					cellLayout.Left=x;
					cellLayout.CellWidth=0;
					cellLayout.ContextCell=cell;
					cellLayout.Graphics=layoutInfo.Graphics;
					cellLayout.LeftToRight=layoutInfo.LeftToRight;
					cellLayout.Font=layoutInfo.DefaultFont;
					if(cell.Layout!=eCellPartLayout.Default)
						cellLayout.VerticalPartAlignment=(cell.Layout==eCellPartLayout.Vertical);
					else if(layoutInfo.CellPartLayout!=eCellPartLayout.Default)
						cellLayout.VerticalPartAlignment=(layoutInfo.CellPartLayout==eCellPartLayout.Vertical);

				
					if(layoutInfo.DefaultColumns.Count>0 || layoutInfo.ChildColumns!=null && layoutInfo.ChildColumns.Count>0)
					{
						ColumnInfo ci=null;
						if(layoutInfo.ChildColumns!=null && layoutInfo.ChildColumns.Count>0)
							ci=layoutInfo.ChildColumns[i] as ColumnInfo;
						else
							ci=layoutInfo.DefaultColumns[i] as ColumnInfo;
					
						bCellVisible=ci.Visible;
						cellLayout.CellWidth=ci.Width;
					}

					// Prepare union style
					if(cell.StyleNormal!=null)
						cellLayout.LayoutStyle=cell.StyleNormal;
					else
					{
						if(layoutInfo.ContextNode.Style!=null)
						{
							ElementStyle styleCopy = layoutInfo.DefaultCellStyle.Copy();
							styleCopy.ApplyStyle(layoutInfo.ContextNode.Style);
							cellLayout.LayoutStyle = styleCopy;
						}
						else
							cellLayout.LayoutStyle=layoutInfo.DefaultCellStyle;
					}

					this.LayoutSingleCell(cellLayout);

					if(bCellVisible)
					{
						x+=cell.BoundsRelative.Width;
						width+=cell.BoundsRelative.Width;
						if(cell.BoundsRelative.Width>0)
						{
							x+=this.CellHorizontalSpacing;
							width+=this.CellHorizontalSpacing;
						}
						if(cell.BoundsRelative.Height>height)
							height=cell.BoundsRelative.Height;
					}
				}

				// Take last added spacing off
				x-=this.CellHorizontalSpacing;
				width-=this.CellHorizontalSpacing;

				return new Size(width,height);
			}
コード例 #12
0
		private void ProcessSubNode(NodeLayoutContextInfo layoutInfo)
		{
			Node node=layoutInfo.ContextNode;
			bool bHorizontalFlow=true;//(m_DiagramFlow==eDiagramFlow.LeftToRight || m_DiagramFlow==eDiagramFlow.RightToLeft);
			if(node.SizeChanged)
			{
				// Calculate size of the node itself...
				LayoutNode(layoutInfo);
			}
			else
				node.SetBounds(new Rectangle(Point.Empty,node.BoundsRelative.Size));
			
			if(node.Expanded)
			{
				ArrayList parentColumns=layoutInfo.ChildColumns;
				ArrayList childColumns=GetNodeColumnInfo(node);

				Rectangle childNodesBounds=Rectangle.Empty;
				foreach(Node childNode in node.Nodes)
				{
					if(!childNode.Visible)
						continue;
					layoutInfo.ContextNode=childNode;
				
					layoutInfo.ChildColumns=childColumns;
					ProcessSubNode(layoutInfo);

					if(bHorizontalFlow)
					{
						childNodesBounds.Height+=(Math.Max(childNode.BoundsRelative.Height,childNode.ChildNodesBounds.Height)+this.NodeVerticalSpacing);
						childNodesBounds.Width=Math.Max(childNodesBounds.Width,childNode.BoundsRelative.Width+(childNode.ChildNodesBounds.Width>0?this.NodeHorizontalSpacing+childNode.ChildNodesBounds.Width:0));
					}
					else
					{
						childNodesBounds.Width+=(Math.Max(childNode.BoundsRelative.Width,childNode.ChildNodesBounds.Width)+this.NodeHorizontalSpacing);
						childNodesBounds.Height=Math.Max(childNodesBounds.Height,childNode.BoundsRelative.Height+(childNode.ChildNodesBounds.Height>0?this.NodeVerticalSpacing+childNode.ChildNodesBounds.Height:0));
					}
				}

				layoutInfo.ChildColumns=parentColumns;

				if(bHorizontalFlow)
				{
					if(childNodesBounds.Height>0)
						childNodesBounds.Height-=this.NodeVerticalSpacing;
				}
				else
				{
					if(childNodesBounds.Width>0)
						childNodesBounds.Width-=this.NodeHorizontalSpacing;
				}
				node.ChildNodesBounds=childNodesBounds;
				layoutInfo.ChildColumns=null;
				layoutInfo.ContextNode=node;
			}
			else node.ChildNodesBounds=Rectangle.Empty;
		}
コード例 #13
0
		// Assumes that layoutInfo is up-to-date and that Node that is connected with
		// columns is already processed and it's size and location calculated.
		// layoutInfo.Top member reflects the next position below the node
		// layoutInfo.LevelOffset should reflect the X offset for the child nodes.
		public void LayoutColumnHeader(NodeLayoutContextInfo layoutInfo)
		{
			Node node=layoutInfo.ContextNode;

			if(node.NodesColumns.Count==0)
			{
				node.ColumnHeaderHeight=0;
				return;
			}
			
			int x=layoutInfo.Left;
			int y=layoutInfo.ContextNode.BoundsRelative.Bottom;

			bool bLeftNode=(layoutInfo.MapPositionNear && layoutInfo.LeftToRight);
			int expandPartWidth=this.ExpandAreaWidth;
			int cellPartSpacing=GetCellLayout().CellPartSpacing;

			if(!bLeftNode)
				x+=(expandPartWidth+cellPartSpacing);

			int clientWidth=layoutInfo.ClientRectangle.Width-(layoutInfo.Left+expandPartWidth);
			if(clientWidth<=0)
				clientWidth=layoutInfo.ClientRectangle.Width;
			
			node.ColumnHeaderHeight=Layout.ColumnHeaderLayout.LayoutColumnHeader(layoutInfo,x,y,clientWidth,this.GetCellLayout().CellHorizontalSpacing);
		}
コード例 #14
0
		/// <summary>
		/// Returns whether given node has command part.
		/// </summary>
		/// <param name="layoutInfo">Layout context information.</param>
		/// <returns>True if command part should be drawn otherwise false.</returns>
		protected virtual bool HasCommandPart(NodeLayoutContextInfo layoutInfo)
		{
			return layoutInfo.ContextNode.CommandButton;
		}
コード例 #15
0
		/// <summary>
		/// Returns true if given node has expand part.
		/// </summary>
		/// <param name="layoutInfo">Layout context information.</param>
		/// <returns></returns>
		protected virtual bool HasExpandPart(NodeLayoutContextInfo layoutInfo)
		{
			Node node=layoutInfo.ContextNode;
			if(node.ExpandVisibility==eNodeExpandVisibility.Auto)
			{
				if(IsRootNode(node) && !RootHasExpandedPart || !NodeOperations.GetAnyVisibleNodes(node))
					return false;
				return true;
			}
			else
				return (node.ExpandVisibility==eNodeExpandVisibility.Visible);
		}
コード例 #16
0
		/// <summary>
		/// Provides the layout for single node.
		/// </summary>
		/// <param name="layoutInfo">Layout information.</param>
		protected virtual void LayoutNode(NodeLayoutContextInfo layoutInfo)
		{
//			if(!layoutInfo.ContextNode.SizeChanged)
//				return;

			bool bHasExpandPart=this.HasExpandPart(layoutInfo);
			bool bHasCommandPart=this.HasCommandPart(layoutInfo);

			Node node=layoutInfo.ContextNode;
			
			Rectangle nodeRect=Rectangle.Empty;
			Rectangle nodeContentRect=Rectangle.Empty; // Node content rect excludes expand rect

			int height=0, width=0;
			
			// Left node relative to the main root node...
			bool bLeftNode=(layoutInfo.MapPositionNear && layoutInfo.LeftToRight);
			if(bLeftNode && bHasExpandPart || this.ReserveExpandPartSpace)
			{
				width+=(this.ExpandAreaWidth+this.GetCellLayout().CellPartSpacing);
			}

			int x=width;		// relative to 0,0 of the node
			int y=0;			// Relative to 0,0 of the node
			
			// Apply node style
			ElementStyle nodeStyle=null;
			if(node.Expanded && node.StyleExpanded!=null)
				nodeStyle=node.StyleExpanded;
			else if(node.Style!=null)
				nodeStyle=node.Style;
			else
				nodeStyle=layoutInfo.DefaultNodeStyle;

			nodeContentRect.X=x;

			if(nodeStyle!=null)
			{
				x+=ElementStyleLayout.LeftWhiteSpace(nodeStyle); // nodeStyle.MarginLeft+nodeStyle.PaddingLeft;
				y+=ElementStyleLayout.TopWhiteSpace(nodeStyle); //nodeStyle.MarginTop+nodeStyle.PaddingTop;
				nodeContentRect.X+=nodeStyle.MarginLeft;
				nodeContentRect.Y+=nodeStyle.MarginTop;
			}

			Size size=this.GetCellLayout().LayoutCells(layoutInfo,x,y);

			node.SetCellsBounds(new Rectangle(x,y,size.Width,size.Height));

			height=size.Height;
			width+=size.Width;

			nodeContentRect.Width=size.Width;
			nodeContentRect.Height=size.Height;

			if(nodeStyle!=null)
			{
				nodeContentRect.Width+=(ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Padding | eSpacePart.Border,eStyleSide.Left)+
					ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Padding | eSpacePart.Border,eStyleSide.Right));
				nodeContentRect.Height+=(ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Padding | eSpacePart.Border,eStyleSide.Top)+
					ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Padding | eSpacePart.Border,eStyleSide.Bottom));

				width+=(ElementStyleLayout.HorizontalStyleWhiteSpace(nodeStyle));
				height+=(ElementStyleLayout.VerticalStyleWhiteSpace(nodeStyle));
			}

			if(!bLeftNode && bHasExpandPart)
				width+=this.ExpandAreaWidth;

			if(bHasCommandPart)
			{
				width+=this.CommandAreaWidth;
				nodeContentRect.Width+=this.CommandAreaWidth;
			}

			nodeRect.Height=height;
			nodeRect.Width=width;
			node.SetBounds(nodeRect);
			node.SetContentBounds(nodeContentRect);

			if(bHasCommandPart)
				LayoutCommandPart(layoutInfo, nodeStyle);
			else
				node.CommandBoundsRelative=Rectangle.Empty;

			if(bHasExpandPart)
				LayoutExpandPart(layoutInfo,bLeftNode);
			else
				node.SetExpandPartRectangle(Rectangle.Empty);

			node.SizeChanged=false;

			// Calculate size and location of node column header if any
			//if(node.NodesColumnHeaderVisible)
			{
				//layoutInfo.Left+=this.NodeLevelOffset;
				LayoutColumnHeader(layoutInfo);
				//layoutInfo.Left-=this.NodeLevelOffset;
			}
		}
コード例 #17
0
		/// <summary>
		/// Determines the rectangle of the +/- part of the tree node that is used to expand node.
		/// </summary>
		/// <param name="layoutInfo">Node layout context information</param>
		protected virtual void LayoutExpandPart(NodeLayoutContextInfo layoutInfo, bool bLeftNode)
		{
			Node node=layoutInfo.ContextNode;

			Size partSize=GetExpandPartSize();

			Rectangle bounds=new Rectangle(0,0,partSize.Width,partSize.Height);
			
			bounds.Y=(node.BoundsRelative.Height-bounds.Height)/2;

			if(bLeftNode)
				bounds.X=(this.ExpandAreaWidth-bounds.Width)/2;
			else
				bounds.X=node.BoundsRelative.Right-this.ExpandAreaWidth+(this.ExpandAreaWidth-partSize.Width)/2;

			node.SetExpandPartRectangle(bounds);
		}
コード例 #18
0
		/// <summary>
		/// Sets the position and size of the node command button.
		/// </summary>
		/// <param name="layoutInfo">Node layout context information</param>
		protected virtual void LayoutCommandPart(NodeLayoutContextInfo layoutInfo, ElementStyle nodeStyle)
		{
			// Command part is right-aligned just before the node border
			Rectangle bounds=new Rectangle(layoutInfo.ContextNode.ContentBounds.Right-this.CommandAreaWidth-
				ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Border,eStyleSide.Right),layoutInfo.ContextNode.ContentBounds.Y+
				ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Border,eStyleSide.Top), 
				this.CommandAreaWidth, layoutInfo.ContextNode.ContentBounds.Height-
				ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Border,eStyleSide.Top)-
				ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Border,eStyleSide.Bottom));
//			Rectangle bounds=new Rectangle(layoutInfo.ContextNode.ContentBounds.Right-this.CommandAreaWidth-
//				ElementStyleLayout.StyleSpacing(nodeStyle,eSpacePart.Border,eStyleSide.Right),layoutInfo.ContextNode.ContentBounds.Y, 
//				this.CommandAreaWidth, layoutInfo.ContextNode.ContentBounds.Height);
			layoutInfo.ContextNode.CommandBoundsRelative=bounds;
		}