/// <summary> /// Converts this <see cref="DataTreeObject"/> and all children into an identical hierarchy of <see cref="TreeNode"/> objects, and then returns this object as a <see cref="TreeNode"/> with all of the proper children.<para/> /// This also connects events to being clicked so that they fire the associated events in <see cref="DataTreeObjectEventMarshaller"/>. /// </summary> /// <returns></returns> public TreeNode ConvertHierarchyToTreeNodes() { TreeNode thisNode = ToTreeNode(); CreateHierarchy(this, thisNode); DataTreeObjectEventMarshaller.RegisterTreeNodeBinding(this, thisNode); return(thisNode); }
/// <summary> /// The internal variant of <see cref="ConvertHierarchyToTreeNodes"/> that handles the recursion. /// </summary> /// <param name="current"></param> /// <param name="targetParent"></param> protected internal void CreateHierarchy(DataTreeObject current, TreeNode targetParent) { foreach (DataTreeObject child in current.Children) { TreeNode childAsTreeNode = child.ToTreeNode(); DataTreeObjectEventMarshaller.RegisterTreeNodeBinding(child, childAsTreeNode); if (child.Children.Count > 0) { CreateHierarchy(child, childAsTreeNode); } targetParent.Nodes.Add(childAsTreeNode); } }