Exemple #1
0
 // Find a tree node for a section node, regardless of its label.
 // Return null when no node is found (do not throw an exception.)
 private TreeNode FindTreeNodeWithoutLabel(SectionNode section)
 {
     TreeNode[] nodes = Nodes.Find(section.GetHashCode().ToString(), true);
     foreach (TreeNode n in nodes)
     {
         if (n.Tag == section)
         {
             return(n);
         }
     }
     return(null);
 }
Exemple #2
0
 // Check whether a node is in the tree view.
 private bool IsInTree(SectionNode section)
 {
     if (section != null)
     {
         TreeNode[] nodes = Nodes.Find(section.GetHashCode().ToString(), true);
         foreach (TreeNode n in nodes)
         {
             if (n.Tag == section && n.Text == section.Label)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #3
0
        // Find the tree node for a section node. The labels must also match.
        private TreeNode FindTreeNode(SectionNode section)
        {
            TreeNode n = FindTreeNodeWithoutLabel(section);

            if (n == null)
            {
                throw new Exception(String.Format("Could not find tree node for section with label \"{0}\"",
                                                  section.Label));
            }
            if (n.Text != section.Label)
            {
                throw new Exception(
                          String.Format("Found tree node matching section node #{0} but labels mismatch (wanted \"{1}\" but got \"{2}\").",
                                        section.GetHashCode(), section.Label, n.Text));
            }
            return(n);
        }