public ExpandInfo(TreeNodeCollection nodes, string fileName, int sourceId) { FileName = fileName; SourceId = sourceId; root = new ExpandInfoChild(); Check(nodes, root); }
private void Check(TreeNodeCollection nodes, ExpandInfoChild info) { foreach (TreeNode childNode in nodes) { var child = new ExpandInfoChild { IsExpanded = childNode.IsExpanded }; info.Add(child); Check(childNode.Nodes, child); } }
private void Restore(TreeNodeCollection nodes, ExpandInfoChild info) { for (int i = 0; i < Math.Min(nodes.Count, info.ChildrenCount); i++) { if (info.Children[i].IsExpanded) { nodes[i].Expand(); } else { nodes[i].Collapse(); } Restore(nodes[i].Nodes, info.Children[i]); } }
public void Add(ExpandInfoChild child) { children.Add(child); }