예제 #1
0
        public void SelectNode(DocTreeNode docNode)
        {
            TreeNode node = FindByDocTreeNode(Nodes, docNode);

            SelectedNode = node;
            SelectedNode.EnsureVisible();
        }
예제 #2
0
        private void OnSelectionChanged(string OldSelection, string NewSelection)
        {
            // -----------------------------------------------------------------
            // Selection has changed - update tree.
            // -----------------------------------------------------------------
            //don't let the user click any other nodes while this code executes

            //Change the colour of all the old selected nodes to the "unselected" colours
            TreeNode Node = GetNodeFromPath(OldSelection);

            //get the node that the old selected path points to
            if ((Node != null))
            {
                ColourNode(Node);
                //change the colour of the unselected node to the unselected colours.
            }

            //Change the colour of all the new selected nodes to the "selected" colours
            //get the node that the new selected path points to.
            SelectedNode = GetNodeFromPath(NewSelection);
            //set the Tree's selected node to the node specified in the new selected path (just used to trigger the AfterSelect event, which is handled by OnTreeSelectionChanged() subroutine below this subroutine) (nb. we REDO this for EVERY node in NewSelections. We have to do this one node at a time because the Tree does not allow you to select more then one node)
            if ((SelectedNode != null))
            {
                ColourNode(SelectedNode);
                //change the colour of the new selected node to the selected colours.
                SelectedNode.EnsureVisible();
                //use inbuilt tree node function that expands the tree to make sure the node specified is visible in the tree.
                SelectedNode.EnsureVisible();
                //use inbuilt tree node function that expands the tree to make sure the node specified is visible in the tree.
            }

            //let the user click on other nodes again
        }
예제 #3
0
        public void SetInitialExpansion()
        {
            CollapseAll();

            switch (GetDisplayStyle())
            {
            case DisplayStyle.Expand:
                ExpandAll();
                break;

            case DisplayStyle.HideTests:
                HideTests();
                break;

            case DisplayStyle.Collapse:
            default:
                break;
            }

            if (Nodes.Count > 0)
            {
                SelectedNode = Nodes[0];
                SelectedNode.EnsureVisible();
            }
        }
예제 #4
0
        /// <summary>
        /// A recursive 'sub search' command is used to search part of the tree
        /// </summary>
        /// <param name="regularExpression">The regular expression to use to match text</param>
        /// <param name="treeNodeCollection">The collection of nodes to search down from</param>
        /// <param name="startAfterNode">The node that searching actually begins from
        /// (otherwise just walk the tree until this node is found)</param>
        /// <param name="stopAtNode">A node to terminate the search at</param>
        /// <param name="state">Sends and returns the state of the recursive search</param>
        private void SubSearch(Regex regularExpression, TreeNodeCollection treeNodeCollection, TreeNode startAfterNode, TreeNode stopAtNode, ref TreeSearchState state)
        {
            foreach (TreeNode treeNode in treeNodeCollection)
            {
                if (state == TreeSearchState.Started) // Has the search started?
                {
                    if (treeNode == stopAtNode)
                    {
                        state = TreeSearchState.HitEndNode;
                        return;
                    }


                    if (nodeSearcher(treeNode, regularExpression))
                    {
                        // We need to show search results even when the FindDialog is active
                        // This means turning off HideSelection if it is set.
                        // This unfortunately causes a slight flicker. One way to avoid this is to turn off HideSelection
                        // in individual control instances.
                        if (HideSelection)
                        {
                            // Ensure that the property is restored when the FindDialog is deactivated
                            findDialog1.Deactivate += new EventHandler(RestoreHideSelection);
                            HideSelection           = false;
                        }
                        SelectedNode = treeNode;
                        SelectedNode.EnsureVisible();  // Make sure the result node is visible
                        state = TreeSearchState.MatchMade;
                        return;
                    }
                }
                if (startAfterNode == treeNode)
                {
                    state = TreeSearchState.Started;
                }

                // sub search child nodes
                SubSearch(regularExpression, treeNode.Nodes, startAfterNode, stopAtNode, ref state);
                if (state == TreeSearchState.HitEndNode)
                {
                    return;
                }
                if (state == TreeSearchState.MatchMade)
                {
                    return;
                }
            }
        }
예제 #5
0
        public void Populate()
        {
            try
            {
                BeginUpdate();
                Nodes.Clear();
                foreach (Database database in Dome.Databases)
                {
                    DatabaseTreeNode dbTreeNode = new DatabaseTreeNode(database);
                    Nodes.Add(dbTreeNode);
                }

                if (Nodes.Count != 0)
                {
                    SelectedNode = Nodes[0];
                    SelectedNode.EnsureVisible();
                }
            }
            finally
            {
                EndUpdate();
            }
        }