示例#1
0
        public bool ShowAssetNameChangeDialog(string name, Asset asset, FolderAsset parent, out string newName)
        {
            var wasNameChanged = false;

            newName = name;

            var extension            = Path.GetExtension(name) ?? string.Empty;
            var nameWithoutExtension = name;

            if (!string.IsNullOrWhiteSpace(extension))
            {
                nameWithoutExtension = Path.GetFileNameWithoutExtension(name);
            }

            var window = this._container.Resolve <AssetNameChangeDialog>(
                new ParameterOverride("name", nameWithoutExtension),
                new ParameterOverride("extension", extension),
                new ParameterOverride("asset", asset),
                new ParameterOverride("parent", parent));

            var result = window.ShowDialog();

            if (result.HasValue && result.Value)
            {
                newName        = $"{window.ViewModel.NewName}{extension}";
                wasNameChanged = true;
            }

            return(wasNameChanged);
        }
示例#2
0
        /// <summary>
        /// Finds the folder by folderid.
        /// </summary>
        /// <param name="actualAssets">The list of all the assets.</param>
        /// <param name="folderId">The folder id.</param>
        /// <returns>The <see cref="FolderAsset"/>.</returns>
        private static FolderAsset FindFolderById(IEnumerable <Asset> actualAssets, Guid folderId)
        {
            foreach (Asset currentAsset in actualAssets)
            {
                FolderAsset folder = currentAsset as FolderAsset;
                if (folder != null)
                {
                    if (folder.Id == folderId)
                    {
                        return(folder);
                    }
                    else
                    {
                        FolderAsset subFolder = FindFolderById(folder.Assets, folderId);

                        if (subFolder != null)
                        {
                            return(subFolder);
                        }
                    }
                }
            }

            return(null);
        }
示例#3
0
        /// <summary>
        /// Finds the parent folder of the given asset.
        /// </summary>
        /// <param name="actualAssets">The IEnumerable list of assets.</param>
        /// <param name="asset">The <see cref="Asset"/>.</param>
        /// <returns>The <see cref="FolderAsset"/>.</returns>
        private static FolderAsset FindFolderByAsset(IEnumerable <Asset> actualAssets, Asset asset)
        {
            foreach (Asset currentAsset in actualAssets)
            {
                FolderAsset folder = currentAsset as FolderAsset;
                if (folder != null)
                {
                    if (folder.Assets.Contains(asset))
                    {
                        return(folder);
                    }
                    else
                    {
                        FolderAsset subFolder = FindFolderByAsset(folder.Assets, asset);

                        if (subFolder != null)
                        {
                            return(subFolder);
                        }
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// Finds the parent folder of the given asset.
        /// </summary>
        /// <param name="actualAssets">The IEnumerable list of assets.</param>
        /// <param name="asset">The <see cref="Asset"/>.</param>
        /// <returns>The <see cref="FolderAsset"/>.</returns>
        private static FolderAsset FindFolderByAsset(IEnumerable <Asset> actualAssets, Asset asset)
        {
            foreach (Asset currentAsset in actualAssets)
            {
                FolderAsset folder = currentAsset as FolderAsset;
                if (folder != null)
                {
                    bool found = folder.Assets.Any(x => x.Id == asset.Id);

                    if (found)
                    {
                        return(folder);
                    }
                    else
                    {
                        FolderAsset subFolder = FindFolderByAsset(folder.Assets, asset);

                        if (subFolder != null)
                        {
                            return(subFolder);
                        }
                    }
                }
            }

            return(null);
        }
示例#5
0
        public void ShouldShowAssetsOfParentFolderWhenUpArrowCommandIsExecuted()
        {
            VideoAsset videoAsset = new VideoAsset {
                Title = "VideoAsset"
            };
            AudioAsset audioAsset = new AudioAsset {
                Title = "AudioAsset"
            };
            FolderAsset folderAsset = new FolderAsset {
                Title = "ParentFolder"
            };

            folderAsset.AddAssets(new ObservableCollection <Asset> {
                videoAsset, audioAsset
            });

            var presentationModel = this.CreatePresentationModel();

            this.assetsAvailableEvent.SubscribeArgumentAction.Invoke(new Infrastructure.DataEventArgs <List <Asset> >(new List <Asset> {
                folderAsset
            }));

            presentationModel.OnAssetSelected(folderAsset);

            Assert.AreEqual(2, presentationModel.Assets.Count);

            presentationModel.UpArrowCommand.Execute(null);

            Assert.AreEqual(1, presentationModel.Assets.Count);
        }
示例#6
0
        public static FolderAsset CreateFolder(this Session session)
        {
            var folder = FolderAsset.Create();

            session.AddAsset(folder);
            return(folder);
        }
示例#7
0
        public void ChangeAssetParent(Asset assetToMove, FolderAsset newParent)
        {
            if (newParent == null)
            {
                throw new ArgumentNullException(nameof(newParent));
            }

            if (this.ValidateNewParent(assetToMove, newParent, out var newName))
            {
                var originalName   = assetToMove.Name;
                var originalPath   = assetToMove.GetPath();
                var originalParent = assetToMove.Parent;
                var newPath        = originalPath;

                var undoCommand = new UndoCommand(() => {
                    assetToMove.Name   = newName;
                    assetToMove.Parent = newParent;
                    newPath            = assetToMove.GetPath();
                    this.MoveAsset(assetToMove, originalPath);
                }, () => {
                    assetToMove.Name   = originalName;
                    assetToMove.Parent = originalParent;
                    this.MoveAsset(assetToMove, newPath);
                });

                this._undoService.Do(undoCommand);
            }
        }
示例#8
0
        public void ShouldShowOnlyTheTopLevelAssetsAtStart()
        {
            VideoAsset videoAsset = new VideoAsset()
            {
                Title = "VideoAsset"
            };

            FolderAsset parentFolderAsset = new FolderAsset()
            {
                Title = "ParentFolder"
            };

            FolderAsset childFolderAsset1 = new FolderAsset()
            {
                Title        = "Child1Folder",
                ParentFolder = parentFolderAsset
            };

            FolderAsset childFolderAsset2 = new FolderAsset()
            {
                Title        = "Child1Folder",
                ParentFolder = parentFolderAsset
            };

            parentFolderAsset.Assets.Add(childFolderAsset1);
            parentFolderAsset.Assets.Add(childFolderAsset2);

            var presentationModel = this.CreatePresentationModel();

            presentationModel.Assets = new List <Asset> {
                videoAsset, parentFolderAsset
            };

            Assert.IsTrue(presentationModel.Assets.Count == 2);
        }
示例#9
0
        public void ShouldNotChangeCurrentFolderIfParentFolderIsNullAndUpArrowCommandIsExecuted()
        {
            VideoAsset videoAsset = new VideoAsset {
                Title = "VideoAsset"
            };
            FolderAsset folderAsset = new FolderAsset {
                Title = "ParentFolder",
            };

            folderAsset.AddAssets(new ObservableCollection <Asset> {
                videoAsset
            });

            var presentationModel = this.CreatePresentationModel();

            presentationModel.Assets = new List <Asset> {
                folderAsset
            };

            Assert.AreEqual(1, presentationModel.Assets.Count);

            presentationModel.UpArrowCommand.Execute(null);

            Assert.AreEqual(1, presentationModel.Assets.Count);
        }
示例#10
0
        /// <summary>
        /// Adds a new folder in the current folder with the given name.
        /// </summary>
        /// <param name="folderName">Name of the new folder.</param>
        private void AddFolder(string folderName)
        {
            // When this method is called by the command then this value would be null as we are
            // not passing any parameter from the xaml file.
            // We are checking null value so that we can reuse the same function with given folderName.
            folderName = string.IsNullOrEmpty(folderName) ? this.FolderTitle.Trim() : folderName.Trim();
            if (this.CanAddFolder(folderName))
            {
                FolderAsset folderAsset = new FolderAsset
                {
                    // Unique value for all the folders.
                    Title        = folderName,
                    ParentFolder = this.currentFolderAsset
                };
                if (this.currentFolderAsset != null)
                {
                    this.currentFolderAsset.Assets.Add(folderAsset);
                }
                else
                {
                    this.currentAssets.Add(folderAsset);
                }

                this.FilterAssets();
                this.AddFolderCommand.RaiseCanExecuteChanged();
            }
        }
示例#11
0
        private bool ValidateAssetName(string name, Asset asset, FolderAsset parentAsset, out string newName)
        {
            var result = !string.IsNullOrWhiteSpace(name);
            var nameWithoutExtension = Path.GetFileNameWithoutExtension(name);

            if (string.IsNullOrWhiteSpace(nameWithoutExtension))
            {
                nameWithoutExtension = name;
            }

            newName = name;

            if (!result || parentAsset.Children.Any(x => string.Equals(x.NameWithoutExtension, nameWithoutExtension, StringComparison.OrdinalIgnoreCase)))
            {
                if (this._dialogService.ShowAssetNameChangeDialog(name, asset, parentAsset, out newName))
                {
                    result = this.ValidateAssetName(newName, asset, parentAsset, out newName);
                }
                else
                {
                    result = false;
                }
            }

            return(result);
        }
        /// <summary>
        /// Searches the specified filter.
        /// </summary>
        /// <param name="filter">The filter.</param>
        private void Search(string filter)
        {
            this.currentFolderAsset = null;
            this.UpArrowCommand.RaiseCanExecuteChanged();

            // this.serviceFacade.LoadAssetsAsync(this.configurationService.GetMediaLibraryUri(), filter, this.configurationService.GetMaxNumberOfItems());
        }
示例#13
0
 internal NintendoOpticalDiscPartitionFile(FolderAsset parent, int index, int nameOffset, BinaryReader reader, NintendoOpticalDiscSystem system)
     : base(parent, "")
 {
     Index      = index;
     NameOffset = nameOffset;
     DataOffset = NintendoOpticalDiscPartition.LoadOffset(reader, system);
     Size       = reader.ReadUInt32();
 }
示例#14
0
 /// <summary>
 /// Shows the assets of the parent folders.
 /// </summary>
 /// <param name="folderName">Name of the folder.</param>
 private void ShowParentFolders(string folderName)
 {
     if (this.currentFolderAsset != null)
     {
         this.currentFolderAsset = this.GetParentFolderAsset;
         this.UpArrowCommand.RaiseCanExecuteChanged();
         this.FilterAssets();
     }
 }
示例#15
0
        public override async Task <ExecutionResult> RunAsync(IStepExecutionContext context)
        {
            Output = Session.CreateFolder();
            var options = new BlastMakeClient.BlastMakeOptions(DbName, DbType, FastaFile.AbsolutePath);

            options.DbPath = Output.AbsolutePath;
            await BlastClient.Execute(options);

            return(ExecutionResult.Next());
        }
示例#16
0
文件: Rom.cs 项目: layshua/Alexandria
 internal void Sort(FolderAsset parent, string name)
 {
     if (Used)
     {
         throw new InvalidDataException();
     }
     Parent = parent;
     Name   = name;
     Used   = true;
 }
示例#17
0
        private void SetInitialFolder()
        {
            FolderAsset folderAsset = LessonAccess.Instance.RootFolder;

            if (LessonAccess.Instance.CurrentLessonAsset?.ParentFolder != null)
            {
                folderAsset = LessonAccess.Instance.CurrentLessonAsset.ParentFolder;
            }

            SetFolder(folderAsset);
        }
示例#18
0
        /// <summary>
        /// Adds the asset to folder.
        /// </summary>
        /// <param name="asset">The asset.</param>
        /// <param name="folderId">The folder id.</param>
        public void AddAssetToFolder(Asset asset, Guid folderId)
        {
            FolderAsset folderAsset = FindFolderById(this.currentAssets, folderId);

            if (folderAsset != null)
            {
                this.RemoveAssetFromOriginalSource(asset);
                folderAsset.Assets.Add(asset);
                this.FilterAssets();
            }
        }
示例#19
0
        /// <summary>
        /// Drops an asset to a folder.
        /// </summary>
        /// <param name="dropPayload">The drop payload that contains the drop information.</param>
        private void DropAssetOnFolder(DropPayload dropPayload)
        {
            FolderAsset folderAsset = dropPayload.DropData as FolderAsset;
            Asset       asset       = dropPayload.DraggedItem as Asset;

            if (folderAsset != null)
            {
                this.AddAssetToFolder(asset, folderAsset.Id);
                this.RefreshCurrentAssets();
            }
        }
示例#20
0
        public void SetFolder(FolderAsset folderAsset)
        {
            m_ElementVMs.Clear();
            foreach (FileSystemAsset asset in folderAsset.AssetsList)
            {
                AssetListElementVM elementVM = new AssetListElementVM(asset, m_OnAssetChosen);
                AddDisposable(elementVM);
                m_ElementVMs.Add(elementVM);
            }

            OnListUpdated.Execute();
        }
示例#21
0
        private bool ValidateNewParent(Asset assetToMove, FolderAsset newParent, out string newName)
        {
            var result = false;

            newName = assetToMove.Name;

            if (assetToMove.Parent == null || newParent.Id != assetToMove.Parent.Id)
            {
                result = this.ValidateAssetName(assetToMove.Name, assetToMove, newParent, out newName);
            }

            return(result);
        }
示例#22
0
        public void ShouldNotPublishShowMetadataEventWhenShowMetadataIsCalledAndAssetIsFolderAsset()
        {
            FolderAsset asset             = new FolderAsset();
            var         presentationModel = this.CreatePresentationModel();

            this.showMetadataEvent.PublishCalled = false;
            this.showMetadataEvent.Asset         = null;

            presentationModel.ShowMetadata(asset);

            Assert.IsFalse(this.showMetadataEvent.PublishCalled);
            Assert.IsNull(this.showMetadataEvent.Asset);
        }
示例#23
0
        internal ModelBoneUnknown(FolderAsset bonesFolder, int index, AssetLoader loader)
            : base(bonesFolder, index, loader)
        {
            var reader = loader.Reader;

            Unknowns.ReadSingles(reader, 3);
            reader.Require(IsDS1 ? 0xFFFFFFFFu : 0xFF000000u);
            Unknowns.ReadSingles(reader, 3);
            Unknowns.ReadInt16s(reader, 2);
            Unknowns.ReadSingles(reader, 3);
            Unknowns.ReadInt16s(reader, 2);
            reader.RequireZeroes(4 * 4);
        }
示例#24
0
        private void MoveFolder(FolderAsset folder, string originalPath)
        {
            var newPath = folder.GetPath();

            if (!Directory.Exists(newPath))
            {
                Directory.CreateDirectory(newPath);

                foreach (var child in folder.Children)
                {
                    this.MoveAsset(child, Path.Combine(originalPath, child.Name));
                }

                Directory.Delete(originalPath, true);
            }
        }
示例#25
0
        internal static Asset LoadFile(FolderAsset parent, BinaryReader reader, ref int index, NintendoOpticalDiscSystem system)
        {
            int  nameOffset  = reader.ReadInt32();
            bool isDirectory = (nameOffset & 0xFF000000) != 0;

            nameOffset &= 0xFFFFFF;

            if (isDirectory)
            {
                return(new NintendoOpticalDiscPartitionFolder(parent, ref index, nameOffset, reader, system));
            }
            else
            {
                return(new NintendoOpticalDiscPartitionFile(parent, index++, nameOffset, reader, system));
            }
        }
示例#26
0
        internal NintendoOpticalDiscPartitionFolder(FolderAsset parent, ref int index, int nameOffset, BinaryReader reader, NintendoOpticalDiscSystem system)
            : base(parent, "")
        {
            Index      = index;
            NameOffset = nameOffset;
            int firstIndex = reader.ReadInt32();

            /*if (firstIndex != index + 1)
             *      throw new InvalidDataException();*/
            int endIndex = reader.ReadInt32();

            index++;
            while (index < endIndex)
            {
                NintendoOpticalDiscPartition.LoadFile(this, reader, ref index, system);
            }
        }
        public void ShouldNotPublishShowMetadataEventWhenShowMetadataIsCalledAndAssetIsFolderAsset()
        {
            FolderAsset asset             = new FolderAsset();
            var         presentationModel = this.CreatePresentationModel();

            this.showMetadataEvent.PublishCalled = false;
            this.showMetadataEvent.Payload       = null;

            var payload = new TimelineElement {
                Asset = asset
            };

            presentationModel.ShowMetadata(payload);

            Assert.IsFalse(this.showMetadataEvent.PublishCalled);
            Assert.IsNull(this.showMetadataEvent.Payload);
        }
示例#28
0
        internal ModelMesh(FolderAsset folder, int index, AssetLoader loader)
            : base(folder, index, loader)
        {
            var reader = loader.Reader;

            Unknowns.ReadInt32s(reader, 1);             // 1?
            MaterialIndex = reader.ReadInt32();
            reader.RequireZeroes(4 * 2);
            Unknowns.ReadInt32s(reader, 1);             // 0 or 1, seems to be material-related but is not transparency; second seems bones-related
            int boneCount = reader.ReadInt32();

            reader.RequireZeroes(4 * 1);
            int boneIndicesOffset = reader.ReadInt32();

            PartCount = reader.ReadInt32();
            int partIndicesOffset = reader.ReadInt32();

            reader.Require(1);
            int indexOffset = reader.ReadInt32();

            long reset = reader.BaseStream.Position;

            reader.BaseStream.Position = boneIndicesOffset;
            var bones = new Codex <ModelBone>();

            Bones = bones;
            for (int i = 0; i < boneCount; i++)
            {
                bones.Add(Model.Bones[reader.ReadInt32()]);
            }

            // Read the part indices.
            reader.BaseStream.Position = partIndicesOffset;
            int partStart = PartStartIndex;

            for (int i = 0; i < PartCount; i++)
            {
                reader.Require(i + partStart);
            }

            reader.BaseStream.Position = indexOffset;
            reader.Require(Index);

            reader.BaseStream.Position = reset;
        }
示例#29
0
        internal static void LoadFileTable(FolderAsset parent, BinaryReader reader, NintendoOpticalDiscSystem system)
        {
            reader.BaseStream.Position = 0x424;
            long fileTableOffset = LoadOffset(reader, system);

            reader.BaseStream.Position = fileTableOffset + 8;
            int count = reader.ReadInt32();

            for (int index = 1; index < count;)
            {
                LoadFile(parent, reader, ref index, system);
            }

            foreach (Asset asset in parent.Children)
            {
                LoadFileName(asset, reader, fileTableOffset + count * 12);
            }
        }
示例#30
0
        /// <summary>
        /// Removes the asset from original source.
        /// </summary>
        /// <param name="asset">The asset.</param>
        private void RemoveAssetFromOriginalSource(Asset asset)
        {
            Asset currentAsset = this.currentAssets.SingleOrDefault(x => x.Id == asset.Id);

            if (currentAsset != null)
            {
                this.currentAssets.Remove(currentAsset);
            }
            else
            {
                FolderAsset folderAsset = FindFolderByAsset(this.currentAssets, asset);

                if (folderAsset != null)
                {
                    folderAsset.Assets.Remove(asset);
                }
            }
        }