more cleanup
svn path=/trunk/msdn-browse/; revision=49396
This commit is contained in:
Родитель
3affb3cf85
Коммит
c8e4a8209f
45
main.cs
45
main.cs
|
@ -162,7 +162,26 @@ public class TreeNode : Gtk.TreeNode {
|
|||
return children;
|
||||
}
|
||||
set {
|
||||
children = Flatten (value);
|
||||
if (value == null)
|
||||
return;
|
||||
ArrayList ar = new ArrayList (value.Length);
|
||||
Flatten (ar, value);
|
||||
children = (TreeNode []) ar.ToArray (typeof (TreeNode));
|
||||
}
|
||||
}
|
||||
|
||||
static void Flatten (ArrayList ar, TreeNode [] nodes)
|
||||
{
|
||||
foreach (TreeNode n in nodes) {
|
||||
if (n is Tree) {
|
||||
// Trees always seem to have nodes
|
||||
// included in the xml, so I am not
|
||||
// sure if the populaltion is
|
||||
// necessary. But let's be safe
|
||||
n.PopulateChildrenData ();
|
||||
Flatten (ar, n.Children);
|
||||
} else
|
||||
ar.Add (n);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,30 +238,6 @@ public class TreeNode : Gtk.TreeNode {
|
|||
AddChild (new DummyNode ());
|
||||
}
|
||||
|
||||
static TreeNode [] Flatten (TreeNode [] nodes)
|
||||
{
|
||||
if (nodes == null)
|
||||
return null;
|
||||
ArrayList ar = new ArrayList (nodes.Length);
|
||||
DoFlatten (ar, nodes);
|
||||
return (TreeNode []) ar.ToArray (typeof (TreeNode));
|
||||
}
|
||||
|
||||
static void DoFlatten (ArrayList ar, TreeNode [] nodes)
|
||||
{
|
||||
foreach (TreeNode n in nodes) {
|
||||
if (n is Tree) {
|
||||
// Trees always seem to have nodes
|
||||
// included in the xml, so I am not
|
||||
// sure if the populaltion is
|
||||
// necessary. But let's be safe
|
||||
n.PopulateChildrenData ();
|
||||
DoFlatten (ar, n.Children);
|
||||
} else
|
||||
ar.Add (n);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return string.Format ("TreeNode [{0}:{1}]", NodeId, Title);
|
||||
|
|
Загрузка…
Ссылка в новой задаче