Пример #1
0
        private void FillChildren()
        {
            if (m_filledChildren)
            {
                return;
            }
            m_filledChildren = true;
            Nodes.Clear();
            //List<TreeNode> nodes = new List<TreeNode>();
            List <ITreeNode> children = new List <ITreeNode>();

            children.AddRange(m_node.GetChildren());
            foreach (var item in TreeExtenderAddonType.Instance.CommonSpace.GetAllAddons())
            {
                var ext = (ITreeExtender)item.InstanceModel;
                try
                {
                    ext.GetExtendedChildren(m_node, children);
                }
                catch (Exception e)
                {
                    Logging.Warning("Error generating node:" + e.ToString());
                }
            }
            Dictionary <string, bool> usedKeys = new Dictionary <string, bool>();

            foreach (ITreeNode child in children)
            {
                if (!m_tree.FilterNode(child))
                {
                    continue;
                }
                if (child.AllowReuse() && m_oldnodes != null && m_oldnodes.ContainsKey(NodeKey(child)) && !usedKeys.ContainsKey(NodeKey(child)))
                {
                    usedKeys[NodeKey(child)] = true;
                    Nodes.Add(m_oldnodes[NodeKey(child)]);
                }
                else
                {
                    var danode = new DATreeNode(child, m_tree);
                    Nodes.Add(danode);
                    if (IsExpanded)
                    {
                        danode.WantChildren();
                        danode.UpdateImageIndex();
                    }
                }
            }
            //Nodes.AddRange(nodes.ToArray());
            m_oldnodes = null;
        }
Пример #2
0
 private void SetRoot(ITreeNode node)
 {
     if (node != null)
     {
         m_root = new DATreeNode(node, this);
     }
     else
     {
         m_root = null;
     }
     tree.Nodes.Clear();
     if (m_root != null)
     {
         if (VisibleRoot)
         {
             tree.Nodes.Add(m_root);
             m_root.UpdateImageIndex();
             m_root.WantChildren();
             MainWindow.Instance.RunInMainWindow(tree.Nodes[0].Expand);
         }
         else
         {
             foreach (ITreeNode child in m_root.m_node.GetChildrenNow())
             {
                 var ada = new DATreeNode(child, this);
                 ada.UpdateImageIndex();
                 if (FilterNode(child))
                 {
                     tree.Nodes.Add(ada);
                 }
                 ada.WantChildren();
             }
         }
     }
     UpdateToolbarEnabling();
 }