Exemplo n.º 1
0
 /// <summary>
 /// Expands or unexpands a specific node
 /// </summary>
 /// <param name="node"></param>
 /// <param name="expand"></param>
 public void ExpandNode(TaskTreeNode node, bool expand)
 {
     if (expand != node.isExpanded)
     {
         int index = stackPanel.Children.IndexOf(node);
         if (expand)
         {
             node.isExpanded = true;
             try
             {
                 foreach (TaskTreeNode n in node.children)
                 {
                     stackPanel.Children.Insert(index + 1, n);
                     InitalizeExpandNode(n);
                     index += GetVisibleChildCount(n) + 1;
                 }
             }
             catch (Exception ex) { Console.WriteLine(ex); RefreshAll(); return; }
         }
         else
         {
             int children = GetVisibleChildCount(node);
             try { stackPanel.Children.RemoveRange(index + 1, children); }
             catch (Exception ex) { Console.WriteLine(ex); RefreshAll(); return; }
             node.isExpanded = false;
         }
         node.ExpanderRefresh();
     }
 }
Exemplo n.º 2
0
        public void AddNode(Task task, string parentID, bool expandParent)
        {
            TaskTreeNode parentNode = nodeDictionary[parentID];
            TaskTreeNode node       = new TaskTreeNode(task, parentNode.depth + 1);

            if (expandParent)
            {
                ExpandNode(parentNode, true);
            }
            parentNode.children.Add(node);
            parentNode.ExpanderRefresh();
            NodeAddToTree(node, parentNode);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the subnodes for a node assuming they were not there before
        /// </summary>
        /// <param name="node"></param>
        private void InitalizeExpandNode(TaskTreeNode node)
        {
            if (node.isExpanded)
            {
                int index = stackPanel.Children.IndexOf(node);
                foreach (TaskTreeNode n in node.children)
                {
                    stackPanel.Children.Insert(index + 1, n);
                    InitalizeExpandNode(n);
                    index += GetVisibleChildCount(n) + 1;
                }
            }

            node.ExpanderRefresh();
        }