Esempio 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();
     }
 }
Esempio n. 2
0
 private void NodeAddToTree(TaskTreeNode node)
 {
     stackPanel.Children.Add(node);
     nodeDictionary[node.ID] = node;
     AddEvents(node);
     foreach (TaskTreeNode n in node.children)
     {
         NodeAddToTree(n);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Puts a certain node into focus
 /// </summary>
 /// <param name="node"></param>
 public void Select(TaskTreeNode node)
 {
     foreach (TaskTreeNode n in selectedNodes)
     {
         n.Deselect();
     }
     selectedNodes.Clear();
     selectedNodes.Add(node);
     node.Select();
     OnSelectionChanged();
 }
Esempio n. 4
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);
        }
Esempio n. 5
0
 private void NodeAddToTree(TaskTreeNode node, TaskTreeNode parentNode)
 {
     if (stackPanel.Children.Contains(parentNode)) //Only add to panel if the parent is visible
     {
         int index = stackPanel.Children.IndexOf(parentNode) + GetVisibleChildCount(parentNode);
         stackPanel.Children.Insert(index, node);
     }
     nodeDictionary[node.ID] = node;
     AddEvents(node);
     foreach (TaskTreeNode n in node.children)
     {
         NodeAddToTree(n, node);
     }
 }
Esempio n. 6
0
        private int GetVisibleChildCount(TaskTreeNode node)
        {
            int count = 0;

            if (node.isExpanded)
            {
                count += node.children.Count;
                foreach (TaskTreeNode n in node.children)
                {
                    count += GetVisibleChildCount(n);
                }
            }
            return(count);
        }
Esempio n. 7
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();
        }
Esempio n. 8
0
 public void RemoveNode(List <TaskTreeNode> nodes, string nodeID)
 {
     for (int i = 0; i < nodes.Count; i++)
     {
         TaskTreeNode n = nodes[i];
         if (n.ID == nodeID)
         {
             nodes.Remove(n);
             i--;
         }
         else
         {
             RemoveNode(n.children, nodeID);
         }
     }
 }
Esempio n. 9
0
        public void AddNode(Task task)
        {
            TaskTreeNode node = new TaskTreeNode(task, 0);

            NodeAddToTree(node);
        }
Esempio n. 10
0
        private void Node_ExpandUpdated(object sender, ExpandUpdatedEventArgs e)
        {
            TaskTreeNode node = (TaskTreeNode)sender;

            ExpandNode(node, e.expanded);
        }
Esempio n. 11
0
 private void AddEvents(TaskTreeNode node)
 {
     node.SelectionChanged += Node_SelectionChanged;
     node.ExpandUpdated    += Node_ExpandUpdated;
 }