/// <summary>
 /// 子を削除する
 /// </summary>
 private void RemoveChild(AssetElement child)
 {
     if (!Children.Contains(child))
     {
         return;
     }
     Children.Remove(child);
     child.Parent = null;
 }
        /// <summary>
        /// 子を追加する
        /// </summary>
        public void AddChild(AssetElement child)
        {
            if (child.Parent != null)
            {
                child.Parent.RemoveChild(child);
            }

            Children.Add(child);
            child.Parent = this;
        }
        AssetElement BuildRoot(string header, string[] elements)
        {
            var root = new AssetElement()
            {
                Id = Id++, Name = header, IconPath = ""
            };

            foreach (var path in elements)
            {
                var element = new AssetElement {
                    Id = Id++, Name = path, IconPath = path
                };
                root.AddChild(element);
            }

            return(root);
        }
Example #4
0
 private void AddChildrenRecursive(AssetElement element, TreeViewItem item, IList <TreeViewItem> rows)
 {
     foreach (var childElement in element.Children)
     {
         var childItem = CreateTreeViewItem(childElement);
         item.AddChild(childItem);
         rows.Add(childItem);
         if (childElement.Children.Count >= 1)
         {
             if (IsExpanded(childElement.Id))
             {
                 AddChildrenRecursive(childElement, childItem, rows);
             }
             else
             {
                 childItem.children = CreateChildListForCollapsedParent();
             }
         }
     }
 }
Example #5
0
 private ExampleTreeViewItem CreateTreeViewItem(AssetElement model)
 => new ExampleTreeViewItem
 {
     id = model.Id, displayName = model.Name, Data = model
 };