// Convenience method to add a new tree node for a section. Return the added tree node. private TreeNode AddSingleSectionNode(ObiNode node) { if (InvokeRequired) { return((TreeNode)Invoke(new NodeInvokation(AddSingleSectionNode), node)); } else { TreeNode n = null; if (node is SectionNode && node.IsRooted) { if (node.ParentAs <SectionNode>() != null) { TreeNode p = FindTreeNode(node.ParentAs <SectionNode>()); n = p.Nodes.Insert(node.Index, node.GetHashCode().ToString(), ((SectionNode)node).Label); } else { n = Nodes.Insert(node.Index, node.GetHashCode().ToString(), ((SectionNode)node).Label); } n.Tag = node; ChangeColorUsed(n, mProjectView.ColorSettings); } return(n); } }