Пример #1
0
        public void AddChildren(IEnumerable <ITreeItem> children)
        {
            List <ITreeItem> added = new List <ITreeItem>();

            foreach (ITreeItem child in children)
            {
                if (Add(child, false))
                {
                    added.Add(child);
                }
            }
            if (added.Count > 0)
            {
                TreeItemChildrenAddEventArgs args =
                    new TreeItemChildrenAddEventArgs(added);
                ChildrenAdded?.Invoke(this, args);
            }
        }
Пример #2
0
 private bool Add(ITreeItem item, bool sendEvent)
 {
     if (!children.Contains(item))
     {
         children.Add(item);
         item.Parent = this;
         if (sendEvent)
         {
             TreeItemChildrenAddEventArgs args =
                 new TreeItemChildrenAddEventArgs(new List <ITreeItem>()
             {
                 item
             });
             ChildrenAdded?.Invoke(this, args);
         }
         return(true);
     }
     return(false);
 }