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); }
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); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ProjectItemFileSystem.Initialize(); HistoryManager.Initialize(); }
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); }
public void Redo() { SignalManager.Get <PasteElementSignal>().Dispatch(_item.Parent, _item); SignalManager.Get <CreateNewElementSignal>().Dispatch(_item); ProjectItemFileSystem.CreateElement(_item, _item.FileHandler.Path, _item.DisplayName); }
public override void Execute(object parameter) { if (ItemSelected == null) { return; } MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this element?", "Delete", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { SignalManager.Get <RegisterHistoryActionSignal>().Dispatch(new DeleteProjectItemHitoryAction(ItemSelected)); ProjectItemFileSystem.DeteElement(ItemSelected); SignalManager.Get <DeleteElementSignal>().Dispatch(ItemSelected); } }
public override void Execute(object parameter) { if (ItemSelected.FileHandler == null) { return; } if (ClipboardManager.GetData() is ProjectItem newItem) { string newItemPath = string.Empty; string name = string.Empty; if (ItemSelected.IsFolder) { newItemPath = Path.Combine(ItemSelected.FileHandler.Path, ItemSelected.FileHandler.Name); } else { newItemPath = ItemSelected.FileHandler.Path; } if (newItem.IsFolder) { name = ProjectItemFileSystem.GetValidFolderName(newItemPath, newItem.DisplayName); } else { string extension = Util.GetExtensionByType(ItemSelected.Type); name = ProjectItemFileSystem.GetValidFileName(newItemPath, newItem.DisplayName, extension); } newItem.RenamedFromAction = true; newItem.DisplayName = name; newItem.IsLoaded = true; SignalManager.Get <RegisterHistoryActionSignal>().Dispatch(new PasteProjectItemHistoryAction(newItem)); SignalManager.Get <PasteElementSignal>().Dispatch(ItemSelected, newItem); ProjectItemFileSystem.CreateElement(newItem, newItemPath, name); } }
private void EditableTextBox_KeyDown(object sender, KeyEventArgs e) { TextBox tb = sender as TextBox; if (tb.DataContext is ProjectItem item) { if (e.Key == Key.Enter) { item.IsInEditMode = false; string name = tb.Text; if (name != item.DisplayName) { // now check if the name is not already taken if (item.IsFolder) { name = ProjectItemFileSystem.GetValidFolderName(item.FileHandler.Path, tb.Text); } else { string extension = Util.GetExtensionByType(item.Type); name = ProjectItemFileSystem.GetValidFileName(item.FileHandler.Path, tb.Text, extension); } tb.Text = name; } } if (e.Key == Key.Escape) { tb.Text = item.OldCaptionValue; item.IsInEditMode = false; } } }
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); }
public void Undo() { ProjectItemFileSystem.DeteElement(_item); SignalManager.Get <DeleteElementSignal>().Dispatch(_item); }
public override void Execute(object parameter) { DragEventArgs dragEvent = parameter as DragEventArgs; dragEvent.Handled = true; if (dragEvent.Data.GetDataPresent(typeof(ProjectItem))) { ProjectItem draggingObject = dragEvent.Data.GetData(typeof(ProjectItem)) as ProjectItem; TreeViewItem treeViewItem = Util.FindAncestor <TreeViewItem>((DependencyObject)dragEvent.OriginalSource); if (treeViewItem == null) { return; } if (!(treeViewItem.Header is ProjectItem dropTarget) || draggingObject == null) { return; } // It is important to deselect the dragged object to select it again when the whole process finishes draggingObject.IsSelected = false; string name; string destinationFolder; if (dropTarget.IsFolder) { destinationFolder = Path.Combine(dropTarget.FileHandler.Path, dropTarget.FileHandler.Name); } else { destinationFolder = dropTarget.FileHandler.Path; } if (destinationFolder == draggingObject.FileHandler.Path) { return; } if (draggingObject.IsFolder) { name = ProjectItemFileSystem.GetValidFolderName(destinationFolder, draggingObject.DisplayName); } else { string extension = Util.GetExtensionByType(draggingObject.Type); name = ProjectItemFileSystem.GetValidFileName(destinationFolder, draggingObject.DisplayName, extension); } string oldName = draggingObject.DisplayName; draggingObject.RenamedFromAction = true; draggingObject.DisplayName = name; SignalManager.Get <RegisterHistoryActionSignal>().Dispatch( new MoveProjectItemHistoryAction(dropTarget, draggingObject, draggingObject.Parent, name, oldName) ); SignalManager.Get <DropElementSignal>().Dispatch(dropTarget, draggingObject); SignalManager.Get <MoveElementSignal>().Dispatch(dropTarget, draggingObject); } dragEvent.Effects = DragDropEffects.None; }