Esempio n. 1
0
 public bool IsIDVisible(int id)
 {
     if (this.m_TreeView == null)
     {
         return(false);
     }
     return(TreeViewController.GetIndexOfID(this.m_TreeView.data.GetRows(), id) >= 0);
 }
Esempio n. 2
0
        public bool IsIDVisible(int id)
        {
            if (m_TreeView == null)
            {
                return(false);
            }

            var rows = m_TreeView.data.GetRows();

            return(TreeViewController.GetIndexOfID(rows, id) >= 0);
        }
Esempio n. 3
0
        public bool IsIDVisible(int id)
        {
            bool result;

            if (this.m_TreeView == null)
            {
                result = false;
            }
            else
            {
                IList <TreeViewItem> rows = this.m_TreeView.data.GetRows();
                result = (TreeViewController.GetIndexOfID(rows, id) >= 0);
            }
            return(result);
        }
        override public void InsertFakeItem(int id, int parentID, string name, Texture2D icon)
        {
            bool isCreatingNewFolder = GetCreateAssetUtility().endAction is DoCreateFolder;

            TreeViewItem checkItem = FindItem(id);

            if (checkItem != null)
            {
                Debug.LogError("Cannot insert fake Item because id is not unique " + id + " Item already there: " + checkItem.displayName);
                return;
            }

            if (FindItem(parentID) != null)
            {
                // Ensure parent Item's children is visible
                SetExpanded(parentID, true);

                var visibleRows = GetRows();

                TreeViewItem parentItem;
                int          parentIndex = TreeViewController.GetIndexOfID(visibleRows, parentID);
                if (parentIndex >= 0)
                {
                    parentItem = visibleRows[parentIndex];
                }
                else
                {
                    parentItem = m_RootItem; // Fallback to root Item as parent
                }
                // Create fake folder for insertion
                int indentLevel = parentItem.depth + (parentItem == m_RootItem ? 0 : 1);
                m_FakeItem      = new TreeViewItem(id, indentLevel, parentItem, name);
                m_FakeItem.icon = icon;

                // Find pos under parent
                int insertAfterID = GetInsertAfterItemIDForNewItem(name, parentItem, isCreatingNewFolder, foldersFirst);

                // Find pos in expanded rows and insert
                int index = TreeViewController.GetIndexOfID(visibleRows, insertAfterID);
                if (index >= 0)
                {
                    // Ensure to bypass all children of 'insertAfterID'
                    while (++index < visibleRows.Count)
                    {
                        if (visibleRows[index].depth <= indentLevel)
                        {
                            break;
                        }
                    }

                    if (index < visibleRows.Count)
                    {
                        visibleRows.Insert(index, m_FakeItem);
                    }
                    else
                    {
                        visibleRows.Add(m_FakeItem);
                    }
                }
                else
                {
                    // not visible parent: insert as first
                    if (visibleRows.Count > 0)
                    {
                        visibleRows.Insert(0, m_FakeItem);
                    }
                    else
                    {
                        visibleRows.Add(m_FakeItem);
                    }
                }

                m_NeedRefreshRows = false;

                m_TreeView.Frame(m_FakeItem.id, true, false);
                m_TreeView.Repaint();
            }
            else
            {
                Debug.LogError("No parent Item found");
            }
        }
        public override void InsertFakeItem(int id, int parentID, string name, Texture2D icon)
        {
            TreeViewItem item = this.FindItem(id);

            if (item != null)
            {
                Debug.LogError(string.Concat(new object[] { "Cannot insert fake Item because id is not unique ", id, " Item already there: ", item.displayName }));
            }
            else if (this.FindItem(parentID) == null)
            {
                Debug.LogError("No parent Item found with ID: " + parentID);
            }
            else
            {
                TreeViewItem rootItem;
                this.SetExpanded(parentID, true);
                IList <TreeViewItem> rows = this.GetRows();
                int indexOfID             = TreeViewController.GetIndexOfID(rows, parentID);
                if (indexOfID >= 0)
                {
                    rootItem = rows[indexOfID];
                }
                else
                {
                    rootItem = base.m_RootItem;
                }
                int depth = rootItem.depth + 1;
                base.m_FakeItem      = new TreeViewItem(id, depth, rootItem, name);
                base.m_FakeItem.icon = icon;
                int insertAfterItemIDForNewItem = this.GetInsertAfterItemIDForNewItem(name, rootItem);
                int index = TreeViewController.GetIndexOfID(rows, insertAfterItemIDForNewItem);
                if (index < 0)
                {
                    if (rows.Count > 0)
                    {
                        rows.Insert(0, base.m_FakeItem);
                    }
                    else
                    {
                        rows.Add(base.m_FakeItem);
                    }
                }
                else
                {
                    while (++index < rows.Count)
                    {
                        if (rows[index].depth <= depth)
                        {
                            break;
                        }
                    }
                    if (index < rows.Count)
                    {
                        rows.Insert(index, base.m_FakeItem);
                    }
                    else
                    {
                        rows.Add(base.m_FakeItem);
                    }
                }
                base.m_NeedRefreshRows = false;
                base.m_TreeView.Frame(base.m_FakeItem.id, true, false);
                base.m_TreeView.Repaint();
            }
        }
        public override void InsertFakeItem(int id, int parentID, string name, Texture2D icon)
        {
            bool         isCreatingNewFolder = this.GetCreateAssetUtility().endAction is DoCreateFolder;
            TreeViewItem treeViewItem        = this.FindItem(id);

            if (treeViewItem != null)
            {
                Debug.LogError(string.Concat(new object[]
                {
                    "Cannot insert fake Item because id is not unique ",
                    id,
                    " Item already there: ",
                    treeViewItem.displayName
                }));
            }
            else if (this.FindItem(parentID) != null)
            {
                this.SetExpanded(parentID, true);
                IList <TreeViewItem> rows = this.GetRows();
                int          indexOfID    = TreeViewController.GetIndexOfID(rows, parentID);
                TreeViewItem treeViewItem2;
                if (indexOfID >= 0)
                {
                    treeViewItem2 = rows[indexOfID];
                }
                else
                {
                    treeViewItem2 = this.m_RootItem;
                }
                int num = treeViewItem2.depth + ((treeViewItem2 != this.m_RootItem) ? 1 : 0);
                this.m_FakeItem      = new TreeViewItem(id, num, treeViewItem2, name);
                this.m_FakeItem.icon = icon;
                int insertAfterItemIDForNewItem = this.GetInsertAfterItemIDForNewItem(name, treeViewItem2, isCreatingNewFolder, this.foldersFirst);
                int num2 = TreeViewController.GetIndexOfID(rows, insertAfterItemIDForNewItem);
                if (num2 >= 0)
                {
                    while (++num2 < rows.Count)
                    {
                        if (rows[num2].depth <= num)
                        {
                            break;
                        }
                    }
                    if (num2 < rows.Count)
                    {
                        rows.Insert(num2, this.m_FakeItem);
                    }
                    else
                    {
                        rows.Add(this.m_FakeItem);
                    }
                }
                else if (rows.Count > 0)
                {
                    rows.Insert(0, this.m_FakeItem);
                }
                else
                {
                    rows.Add(this.m_FakeItem);
                }
                this.m_NeedRefreshRows = false;
                this.m_TreeView.Frame(this.m_FakeItem.id, true, false);
                this.m_TreeView.Repaint();
            }
            else
            {
                Debug.LogError("No parent Item found");
            }
        }