Exemplo n.º 1
0
 internal void InsertChild(TreeViewItemData <T> child, int index)
 {
     if (index < 0 || index >= m_Children.Count)
     {
         m_Children.Add(child);
     }
     else
     {
         m_Children.Insert(index, child);
     }
 }
Exemplo n.º 2
0
        internal void ReplaceChild(TreeViewItemData <T> newChild)
        {
            if (!hasChildren)
            {
                return;
            }

            var i = 0;

            foreach (var child in m_Children)
            {
                if (child.id == newChild.id)
                {
                    m_Children.RemoveAt(i);
                    m_Children.Insert(i, newChild);
                    break;
                }

                i++;
            }
        }
Exemplo n.º 3
0
        internal static void AddItem(BaseTreeView treeView, TreeViewItemData <T> item, int parentId = -1, int childIndex = -1, bool rebuildTree = true)
        {
            if (treeView.viewController is TDefaultController defaultController)
            {
                defaultController.AddItem(item, parentId, childIndex, rebuildTree);

                if (rebuildTree)
                {
                    treeView.RefreshItems();
                }

                return;
            }

            Type dataSourceType = null;

            if (treeView.viewController?.GetType().GetGenericTypeDefinition() == typeof(TDefaultController).GetGenericTypeDefinition())
            {
                dataSourceType = treeView.viewController?.GetType().GetGenericArguments()[0];
            }

            throw new ArgumentException($"Type parameter ({typeof(T)}) differs from data source ({dataSourceType})and is not recognized by the controller.");
        }
Exemplo n.º 4
0
 internal void AddChild(TreeViewItemData <T> child)
 {
     m_Children.Add(child);
 }