Exemplo n.º 1
0
		//Gets all the immediate nodes for the current node
		private void GetChildNodes(Elements nodes, Node currentNode, bool parents, bool children, int maxDepth, int currentDepth)
		{
			currentDepth += 1;
			
			if (parents) AddRange(nodes,currentNode.Parents);
			if (children) AddRange(nodes,currentNode.Children);
			
			if (currentDepth < maxDepth)
			{
				foreach (Element element in currentNode.Parents.Values)
				{
					GetChildNodes(nodes,(Node) mNodes[element.Key],parents,children,maxDepth,currentDepth);
				}
				foreach (Element element in currentNode.Children.Values)
				{
					GetChildNodes(nodes,(Node) mNodes[element.Key],parents,children,maxDepth,currentDepth);
				}
			}
		}
Exemplo n.º 2
0
		private void BuildSearchTree()
		{
			mNodes = new Hashtable();
			Shape start;
			Shape end;

			//Loop through each shape and build a node of parent and child shapes
			foreach(Shape shape in Shapes.Values)
			{
				Node node = new Node();
				node.Shape = shape;
				node.Parents = new Elements();
				node.Children = new Elements();

				//Loop through each line and check the start and end shapes
				foreach (Line line in Lines.Values)
				{
					//Set the start and end shape
					if (line.Start.Docked && line.End.Docked)
					{
						if (line.Start.DockedElement == shape) node.Children.Add(line.End.DockedElement.Key,line.End.DockedElement);
						if (line.End.DockedElement == shape) node.Parents.Add(line.Start.DockedElement.Key,line.Start.DockedElement);
					}
				}
				mNodes.Add(shape.Key,node);
			}
		}