public override void Execute(object parameter)
        {
            if (!(parameter is ElementTypeModel element))
            {
                return;
            }

            string name = ProjectItemFileSystem.GetValidFileName(
                element.Path,
                _newFileName,
                Util.GetExtensionByType(element.Type));

            ProjectItem newElement = new ProjectItem()
            {
                DisplayName = name,
                IsFolder    = false,
                IsRoot      = false,
                Type        = element.Type
            };

            SignalManager.Get <RegisterHistoryActionSignal>().Dispatch(new CreateNewElementHistoryAction(newElement));

            SignalManager.Get <FindAndCreateElementSignal>().Dispatch(newElement);

            ProjectItemFileSystem.CreateFileElement(newElement, element.Path, name);
        }
        public override void Execute(object parameter)
        {
            if (ItemSelected == null || ItemSelected.FileHandler == null)
            {
                return;
            }

            string path = Path.Combine(ItemSelected.FileHandler.Path, ItemSelected.FileHandler.Name);

            string name = ProjectItemFileSystem.GetValidFolderName(path, _newFolderName);

            ProjectItem newFolder = new ProjectItem()
            {
                DisplayName = name,
                IsFolder    = true,
                Parent      = ItemSelected,
                IsRoot      = false,
                Type        = ItemSelected.Type
            };

            ItemSelected.Items.Add(newFolder);

            SignalManager.Get <RegisterHistoryActionSignal>().Dispatch(new CreateNewElementHistoryAction(newFolder));

            SignalManager.Get <CreateNewElementSignal>().Dispatch(newFolder);

            ProjectItemFileSystem.CreateFileElement(newFolder, path, name);
        }
        private ProjectItem CreateTileSetElement(string name)
        {
            ProjectModel projectModel = ModelManager.Get <ProjectModel>();

            string tileSets = (string)Application.Current.FindResource(_folderTileSetsKey);

            string path = Path.Combine(projectModel.ProjectPath, tileSets);

            name = ProjectItemFileSystem.GetValidFileName(
                path,
                name,
                Util.GetExtensionByType(ProjectItemType.TileSet));

            ProjectItem newElement = new ProjectItem()
            {
                DisplayName = name,
                IsFolder    = false,
                IsRoot      = false,
                Type        = ProjectItemType.TileSet
            };

            SignalManager.Get <RegisterHistoryActionSignal>().Dispatch(new CreateNewElementHistoryAction(newElement));

            SignalManager.Get <FindAndCreateElementSignal>().Dispatch(newElement);

            ProjectItemFileSystem.CreateFileElement(newElement, path, name);

            return(newElement);
        }
Beispiel #4
0
        public override void Execute(object parameter)
        {
            if (ItemSelected == null || ItemSelected.FileHandler == null)
            {
                return;
            }

            ProjectItem newItem = new ProjectItem(ItemSelected.GetContent());

            string name = ProjectItemFileSystem.GetValidFileName(
                ItemSelected.FileHandler.Path,
                newItem.DisplayName,
                Util.GetExtensionByType(ItemSelected.Type));

            newItem.RenamedFromAction = true;
            newItem.DisplayName       = name;

            SignalManager.Get <RegisterHistoryActionSignal>().Dispatch(new DuplicateProjectItemHistoryAction(newItem));

            SignalManager.Get <PasteElementSignal>().Dispatch(ItemSelected, newItem);

            ProjectItemFileSystem.CreateFileElement(newItem, ItemSelected.FileHandler.Path, name);
        }