* FolderBrowserDialog.cs: Fix the recursive FindPathInNodes method.
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Sun, 30 Sep 2007 02:32:52 +0000 (02:32 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Sun, 30 Sep 2007 02:32:52 +0000 (02:32 -0000)
Also remove the stack.Count > 0 check in FBTreeView.SetSelectedNode
method, since it causes the dialog to not select folders directly
under the root path (when setting SelectedPath property).

2007-09-29  Carlos Alberto Cortez <calberto.cortez@gmail.com>

svn path=/trunk/mcs/; revision=86656

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs

index 662b7491a75c39c67337de801be3e4e600e4402e..0e07b81c0e80a8a76681af88f0d6b05f8135e83c 100644 (file)
@@ -1,3 +1,10 @@
+2007-09-29  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * FolderBrowserDialog.cs: Fix the recursive FindPathInNodes method.
+       Also remove the stack.Count > 0 check in FBTreeView.SetSelectedNode
+       method, since it causes the dialog to not select folders directly
+       under the root path (when setting SelectedPath property).
+
 2007-09-29  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * TreeNode.cs: When calling Expand/Collapse and need to call 
index 3a9e8578d8acecd56ffffab2cd93fc5b26200509..eb038ce7256e5dcaedbe6451aabe6589c4aee264 100644 (file)
@@ -498,38 +498,36 @@ namespace System.Windows.Forms {
                                                }
                                        }
                                        
-                                       if (stack.Count > 0) {
-                                               FillNode (node);
-                                               node.Expand ();
-                                               
-                                               // walk through the subdirs and fill the nodes
-                                               while (stack.Count > 0) {
-                                                       string part_name = stack.Pop () as string;
-                                                       
-                                                       foreach (TreeNode treeNode in node.Nodes) {
-                                                               FBTreeNode fbnode = treeNode as FBTreeNode;
-                                                               
-                                                               if (path_cut + part_name == fbnode.RealPath) {
-                                                                       node = fbnode;
-                                                                       path_cut += part_name;
-                                                                       
-                                                                       FillNode (node);
-                                                                       node.Expand ();
-                                                                       break;
-                                                               }
-                                                       }
-                                               }
-                                               
-                                               // finally find the node for the complete path
+                                       FillNode (node);
+                                       node.Expand ();
+
+                                       // walk through the subdirs and fill the nodes
+                                       while (stack.Count > 0) {
+                                               string part_name = stack.Pop () as string;
+
                                                foreach (TreeNode treeNode in node.Nodes) {
                                                        FBTreeNode fbnode = treeNode as FBTreeNode;
-                                                       
-                                                       if (path == fbnode.RealPath) {
+
+                                                       if (path_cut + part_name == fbnode.RealPath) {
                                                                node = fbnode;
+                                                               path_cut += part_name;
+
+                                                               FillNode (node);
+                                                               node.Expand ();
                                                                break;
                                                        }
                                                }
                                        }
+
+                                       // finally find the node for the complete path
+                                       foreach (TreeNode treeNode in node.Nodes) {
+                                               FBTreeNode fbnode = treeNode as FBTreeNode;
+
+                                               if (path == fbnode.RealPath) {
+                                                       node = fbnode;
+                                                       break;
+                                               }
+                                       }
                                }
                                
                                if (node != null) {
@@ -550,7 +548,9 @@ namespace System.Windows.Forms {
                                                        return fbnode;
                                        }
                                        
-                                       return FindPathInNodes (path, node.Nodes);
+                                       FBTreeNode n = FindPathInNodes (path, node.Nodes);
+                                       if (n != null)
+                                               return n;
                                }
                                
                                return null;