private void RefreshBottomBarSelectedItem(int[] idList)
        {
            if (idList != null && idList.Length > 0)
            {
                var index = m_GridViewDataSource.GetItemIndexByItemId(idList[0]);
                if (index == -1)
                {
                    var item       = m_ConfigSource.GetValue <FolderGridItem>(BottomSelectedItem);
                    var parentItem = m_TreeView.FindItem(item.ParentId) as FolderTreeViewItem;
                    if (parentItem == null)
                    {
                        return;
                    }

                    if (parentItem.hasChildren)
                    {
                        foreach (var child in parentItem.children)
                        {
                            if (child.id == item.Id)
                            {
                                m_BottomBarSelectedItem = item;
                                m_BottomBar.SelectedPathSplitted.Clear();
                                return;
                            }
                        }
                    }

                    if (parentItem.FileList != null)
                    {
                        foreach (var child in parentItem.FileList)
                        {
                            if (child.id == item.Id)
                            {
                                m_BottomBarSelectedItem = item;
                                m_BottomBar.SelectedPathSplitted.Clear();
                                return;
                            }
                        }
                    }
                    return;
                }

                m_BottomBarSelectedItem = m_GridViewDataSource.GetItemByIndex(index) as FolderGridItem;
                m_ConfigSource.SetValue(BottomSelectedItem, m_BottomBarSelectedItem);
                m_BottomBar.SelectedPathSplitted.Clear();
            }
            else
            {
                m_BottomBarSelectedItem = null;
                m_ConfigSource.SetValue <FolderGridItem>(BottomSelectedItem, null);
                m_BottomBar.SelectedPathSplitted.Clear();
            }
            m_ConfigSource.SetConfigDirty();
        }
Пример #2
0
        private void UpdateSelectionItems()
        {
            var treeView = m_FolderGridViewGroup.GetFolderGridViewGroup().GetTreeView();

            if (treeView.data == null)
            {
                return;
            }

            var gridViewDataSource = m_FolderGridViewGroup.GetGridViewDataSource();
            var itemList           = gridViewDataSource.ItemList;

            itemList.Clear();
            if (treeView.state.selectedIDs != null)
            {
                foreach (var id in treeView.state.selectedIDs)
                {
                    var folderTreeItem = treeView.data.FindItem(id) as FolderTreeViewItem;

                    if (folderTreeItem != null && folderTreeItem.hasChildren)
                    {
                        foreach (var child in folderTreeItem.children)
                        {
                            var gridItem        = new FolderGridItem();
                            var childFolderItem = child as FolderTreeViewItem;
                            gridItem.Id          = child.id;
                            gridItem.DisplayName = child.displayName;
                            gridItem.Path        = childFolderItem.Path;
                            gridItem.ParentId    = folderTreeItem.id;
                            gridItem.IsFolder    = true;
                            gridItem.IsChildItem = false;
                            itemList.Add(gridItem);
                        }
                    }

                    if (folderTreeItem != null && folderTreeItem.FileList != null)
                    {
                        foreach (var child in folderTreeItem.FileList)
                        {
                            var gridItem = new FileGridItem();
                            gridItem.Id          = child.id;
                            gridItem.DisplayName = child.displayName;
                            gridItem.Path        = child.Path;
                            gridItem.ParentId    = folderTreeItem.id;
                            gridItem.IsFolder    = false;
                            gridItem.IsChildItem = false;
                            itemList.Add(gridItem);
                        }
                    }
                }
            }

            SortGridViewItem();
        }
Пример #3
0
        private void CreateFolder(FolderTreeViewItem parentItem = null)
        {
            var dataContainer = m_FolderGridViewGroup.GetDataContainer();
            var gridView      = m_FolderGridViewGroup.GetGridView();

            if (parentItem == null)
            {
                if (!m_TreeView.isSearching)
                {
                    parentItem = m_TreeView.data.FindItem(m_TreeView.state.selectedIDs[0]) as FolderTreeViewItem;
                }
                else
                {
                    parentItem = m_TreeView.data.root as FolderTreeViewItem;
                }
            }

            var folderItem = new FolderGridItem();

            folderItem.IsFolder = true;
            folderItem.ParentId = parentItem.id;
            folderItem.Id       = dataContainer.GetAutoID();
            var newPath = EditorFileUtility.CreateNewFolder(parentItem.Path, "New Folder");

            folderItem.Path = newPath;
            var di = new DirectoryInfo(newPath);

            folderItem.DisplayName = di.Name;

            //重命名完成后添加到TreeView中
            m_FolderGridViewGroup.RenameEndWhenCreatingAction  = null;
            m_FolderGridViewGroup.RenameEndWhenCreatingAction += () =>
            {
                //添加到TreeView
                var child = new FolderTreeViewItem();
                child.Path        = di.FullName.Replace("/", "\\");;
                child.IsFolder    = true;
                child.id          = folderItem.Id;
                child.displayName = di.Name;
                child.parent      = parentItem;
                child.SetConfigSource(m_WindowConfigSource);
                parentItem.AddChild(child);
            };

            m_FolderGridViewGroup.GetGridViewDataSource().ItemList.Add(folderItem);

            SortGridViewItem();

            m_FolderGridViewGroup.IsCreatingItem = true;
            gridView.SetSelection(new[] { folderItem.Id }, false);
            gridView.BeginRename(0);
        }
Пример #4
0
        private void GetSearchItems(string searchText, FolderTreeViewItem item, List <GridItem> itemList)
        {
            if (item != m_DataContainer.RootItem)
            {
                if (item.displayName.ToLower().Contains(searchText))
                {
                    var gridItem = new FolderGridItem();
                    gridItem.Id          = item.id;
                    gridItem.DisplayName = item.displayName;
                    gridItem.Path        = item.Path;
                    gridItem.ParentId    = item.parent.id;
                    gridItem.IsFolder    = true;
                    itemList.Add(gridItem);
                }
            }

            if (item.hasChildren)
            {
                foreach (var child in item.children)
                {
                    GetSearchItems(searchText, child as FolderTreeViewItem, itemList);
                }
            }

            if (item.FileList != null)
            {
                foreach (var child in item.FileList)
                {
                    if (child.displayName.ToLower().Contains(searchText))
                    {
                        var gridItem = new FileGridItem();
                        gridItem.Id          = child.id;
                        gridItem.DisplayName = child.displayName;
                        gridItem.Path        = child.Path;
                        gridItem.ParentId    = item.id;
                        gridItem.IsFolder    = false;
                        itemList.Add(gridItem);
                    }
                }
            }
        }
 private void CheckBottomBarItemValidity()
 {
     if (m_BottomBarSelectedItem != null)
     {
         if (m_BottomBarSelectedItem.IsFolder)
         {
             if (!Directory.Exists(m_BottomBarSelectedItem.Path))
             {
                 m_BottomBarSelectedItem = null;
                 m_BottomBar.SelectedPathSplitted.Clear();
             }
         }
         else
         {
             if (!File.Exists(m_BottomBarSelectedItem.Path))
             {
                 m_BottomBarSelectedItem = null;
                 m_BottomBar.SelectedPathSplitted.Clear();
             }
         }
     }
 }