Пример #1
0
        /// <summary>
        /// Gets the tree roots.
        /// </summary>
        /// <returns>List of roots</returns>
        /// <param name="cls">Project details</param>
        private List<TreeNode> GetTreeRoots(UMLClass cls)
        {
            // Map every class node.
            // Namespace - Treenode
            foreach(var cnode in cls.ClassNodes){
                TreeNode tn = new TreeNode(cnode.Namespace);
                tn.Node = cnode;
                TreeNodes.Add(tn);
                if(!map.ContainsKey(tn.Name))
                    map.Add(tn.Name,tn);
            }

            //Create all parent child links
            foreach(var cnode in cls.ClassNodes)
            {
                foreach(var parent in cnode.Links)
                {
                    var parentnode = GetTreeNode(parent);
                    var childnode = GetTreeNode(cnode.Namespace);

                    if(parentnode == null){
                        //If inherits class outside project
                        continue;
                    }
                    parentnode.AddChild(childnode);
                    childnode.Parent = parentnode;
                }
            }

            //At this point, we have a forest. Every tree in the
            //forest wil be drawn separately

            List<TreeNode> Roots = new List<TreeNode>();
            // Add all roots to a list
            foreach(TreeNode tn in TreeNodes)
            {
                var temp = tn;
                while(temp.Parent !=null){
                    temp = temp.Parent;
                }
                if(!Roots.Contains(temp))
                {
                    Roots.Add(temp);
                }
            }
            return Roots;
        }
Пример #2
0
 public void AddChild(TreeNode node)
 {
     this.children.Add(node);
 }