Пример #1
0
        public void SetSelectedDirectory(CDirectoryEntry directory)
        {
            ActiveDirectory = directory.Path;
            SelectedFolderPath.Clear();
            CDirectoryEntry dir = directory;

            SelectedFolderPath.Add(RootDirectory);
            while (dir.ParentDirectory != null)
            {
                SelectedFolderPath.Insert(1, dir);
                dir = dir.ParentDirectory;
            }
            UpdateShownAssets();
        }
Пример #2
0
        public CAssetBrowserViewModel() : base("AssetBrowser")
        {
            SetIconSourcePath("Resources/Images/Tabs/assetbrowser.png");

            Content         = new AssetBrowserView();
            m_rootDirectory = new CDirectoryEntry("", this);             // Start at the project root
            RootFolders.Add(m_rootDirectory);
            SelectedFolderPath.Add(m_rootDirectory);
            ImportCommand          = new CRelayCommand(OnImport);
            DeleteAssetCommand     = new CRelayCommand(OnDeleteAsset);
            CreateMaterialCommand  = new CRelayCommand(OnCreateMaterial);
            CreateEntityCommand    = new CRelayCommand(OnCreateEntity);
            CreateInterfaceCommand = new CRelayCommand(OnCreateInterface);
        }
Пример #3
0
        private void OnDrop(object e)
        {
            DragEventArgs args = (DragEventArgs)e;

            if (args.Data.GetDataPresent("assetEntry"))
            {
                // Move single asset
                CAssetEntryViewModel assetEntry = (CAssetEntryViewModel)args.Data.GetData("assetEntry");
                if (CAssetRegistry.Instance.MoveAssetFile(assetEntry.Asset, Path))
                {
                    m_viewModel.RemoveShownAsset(assetEntry);
                }
            }
            else if (args.Data.GetDataPresent("assetEntries"))
            {
                // Move multiple assets
                object[] assetEntries = (object[])args.Data.GetData("assetEntries");
                foreach (object entry in assetEntries)
                {
                    CAssetEntryViewModel assetEntry = (CAssetEntryViewModel)entry;
                    if (CAssetRegistry.Instance.MoveAssetFile(assetEntry.Asset, Path))
                    {
                        m_viewModel.RemoveShownAsset(assetEntry);
                    }
                }
            }
            else if (args.Data.GetDataPresent("folderEntry"))
            {
                CDirectoryEntry folderEntry = (CDirectoryEntry)args.Data.GetData("folderEntry");
                if (folderEntry.ParentDirectory != null)
                {
                    CAssetRegistry.Instance.MoveAssetFolder(folderEntry.Path, Path);
                    folderEntry.ParentDirectory.UpdateSubDirectories();
                    UpdateSubDirectories();
                }
            }
            else if (args.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])args.Data.GetData(DataFormats.FileDrop);
                foreach (string file in files)
                {
                    m_viewModel.ImportFile(file, Path);
                }
            }
        }
Пример #4
0
        public CDirectoryEntry(string directoryPath, CAssetBrowserViewModel viewModel, CDirectoryEntry parent = null)
        {
            ParentDirectory = parent;
            m_viewModel     = viewModel;
            Path            = directoryPath;
            string        absolutePath = ProjectDefinitions.GetAbsolutePath(directoryPath);
            DirectoryInfo dirInfo      = new DirectoryInfo(absolutePath);

            Name     = string.IsNullOrWhiteSpace(directoryPath) ? "Project" : dirInfo.Name;
            EditName = Name;

            UpdateSubDirectories();

            SelectCommand       = new CRelayCommand(OnDirectoryClicked);
            DragEnterCommand    = new CRelayCommand(OnDragEnter);
            DragOverCommand     = new CRelayCommand(OnDragOver);
            DropCommand         = new CRelayCommand(OnDrop);
            AddFolderCommand    = new CRelayCommand(OnAddFolder);
            DeleteFolderCommand = new CRelayCommand(OnDeleteFolder);
        }