Example #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="targetNode">Target node that will be the parent of the new nodes</param>
 protected AsyncNodeProvider(TreeNodeData targetNode)
 {
     lockObj                 = new object();
     this.targetNode         = targetNode;
     dispatcher              = Dispatcher.CurrentDispatcher;
     uiThreadActions         = new List <Action>();
     cancellationTokenSource = new CancellationTokenSource();
     cancellationToken       = cancellationTokenSource.Token;
     thread = new Thread(ThreadMethodImpl);
     thread.IsBackground = true;
 }
Example #2
0
 /// <summary>
 /// Adds a new node
 /// </summary>
 /// <param name="node">New node</param>
 protected void AddNode(TreeNodeData node)
 {
     if (node is null)
     {
         throw new ArgumentNullException(nameof(node));
     }
     lock (lockObj) {
         nodesToAdd.Add(node);
         if (nodesToAdd.Count == 1)
         {
             UI(AddNodes_UI);
         }
     }
 }
Example #3
0
 /// <summary>
 /// Gets the ancestor of a certain type
 /// </summary>
 /// <typeparam name="T">Desired type</typeparam>
 /// <param name="self">This</param>
 /// <returns></returns>
 public static T GetAncestorOrSelf <T>(this TreeNodeData self) where T : TreeNodeData
 {
     while (self != null)
     {
         if (self is T found)
         {
             return(found);
         }
         var parent = self.TreeNode.Parent;
         if (parent == null)
         {
             break;
         }
         self = parent.Data;
     }
     return(null);
 }
Example #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="node">Node</param>
 /// <param name="removed">true if it was removed</param>
 public TreeViewNodeRemovedEventArgs(TreeNodeData node, bool removed)
 {
     Node    = node;
     Removed = removed;
 }
Example #5
0
 /// <summary>
 /// Gets all descendants including itself
 /// </summary>
 /// <param name="self">This</param>
 /// <returns></returns>
 public static IEnumerable <TreeNodeData> DescendantsAndSelf(this TreeNodeData self) => self.TreeNode.DescendantsAndSelf().Select(a => a.Data);