private void SetChildren(TreeControl.Node parentNode) { if (m_treeView == null) { return; } if (parentNode.Expanded) { object obj = parentNode.Tag; if (obj != null) { TreeControl.Node node = null; foreach (object child in m_treeView.GetChildren(obj)) { node = parentNode.Add(child); m_itemToNodeMap.Add(child, node); UpdateNode(node); } if (node == null) // no children? { parentNode.IsLeaf = true; } } } else { foreach (TreeControl.Node child in parentNode.Children) { Unbind(child); } parentNode.Clear(); } }
void UpdateNode(TreeControl.Node node) { Translators.HierarchyTranslator trans = Translators.HierarchyTranslator.GetTranslator(node.Tag.GetType()); if (trans != null) { node.Clear(); FontStyle fs = node.FontStyle; node.Label = trans.GetLabel(node.Tag, out fs); node.FontStyle = fs; node.ImageIndex = trans.GetImage(node.Tag); object statusTag = trans.GetStatusTag(node.Tag); node.Expanded = expansionStatus.ContainsKey(statusTag) && expansionStatus[statusTag]; List <object> children = trans.GetChildren(node.Tag); if (children != null && children.Count > 0) { node.IsLeaf = false; foreach (object o in children) { Fill(node, o); } } else { node.IsLeaf = true; } } }