diff --git a/Library/LibraryRowItemCollection.cs b/Library/LibraryRowItemCollection.cs index 22bf6334b..484c8635c 100644 --- a/Library/LibraryRowItemCollection.cs +++ b/Library/LibraryRowItemCollection.cs @@ -48,12 +48,12 @@ namespace MatterHackers.MatterControl.PrintLibrary { LibraryProvider parentProvider; PrintItemCollection printItemCollection; - int collectionIndex; + public int CollectionIndex { get; private set; } public LibraryRowItemCollection(PrintItemCollection collection, int collectionIndex, LibraryDataView libraryDataView, LibraryProvider parentProvider, GuiWidget thumbnailWidget) : base(libraryDataView, thumbnailWidget) { - this.collectionIndex = collectionIndex; + this.CollectionIndex = collectionIndex; this.parentProvider = parentProvider; this.printItemCollection = collection; this.ItemName = printItemCollection.Name; @@ -85,12 +85,12 @@ namespace MatterHackers.MatterControl.PrintLibrary public override void RemoveFromCollection() { - int collectionItemCollectionCount = LibraryDataView.CurrentLibraryProvider.GetCollectionChildCollectionCount(collectionIndex); - int collectionItemItemCount = LibraryDataView.CurrentLibraryProvider.GetCollectionItemCount(collectionIndex); + int collectionItemCollectionCount = LibraryDataView.CurrentLibraryProvider.GetCollectionChildCollectionCount(CollectionIndex); + int collectionItemItemCount = LibraryDataView.CurrentLibraryProvider.GetCollectionItemCount(CollectionIndex); if (collectionItemCollectionCount > 0 || collectionItemItemCount > 0) { - string message = collectionNotEmtyMessage.FormatWith(LibraryDataView.CurrentLibraryProvider.GetCollectionItem(collectionIndex).Name); + string message = collectionNotEmtyMessage.FormatWith(LibraryDataView.CurrentLibraryProvider.GetCollectionItem(CollectionIndex).Name); UiThread.RunOnIdle(() => { // Let the user know this collection is not empty and check if they want to delete it. @@ -99,7 +99,7 @@ namespace MatterHackers.MatterControl.PrintLibrary } else { - LibraryDataView.CurrentLibraryProvider.RemoveCollection(collectionIndex); + LibraryDataView.CurrentLibraryProvider.RemoveCollection(CollectionIndex); } } @@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.PrintLibrary { if (messageBoxResponse) { - LibraryDataView.CurrentLibraryProvider.RemoveCollection(collectionIndex); + LibraryDataView.CurrentLibraryProvider.RemoveCollection(CollectionIndex); } } diff --git a/Library/LibraryRowItemPart.cs b/Library/LibraryRowItemPart.cs index 7cbb25c9e..fce1d609d 100644 --- a/Library/LibraryRowItemPart.cs +++ b/Library/LibraryRowItemPart.cs @@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl.PrintLibrary { public bool isActivePrint = false; LibraryProvider libraryProvider; - private int itemIndex; + public int ItemIndex { get; private set; } double thumbnailWidth = 0; public PrintItemWrapper printItemInstance = null; @@ -73,7 +73,7 @@ namespace MatterHackers.MatterControl.PrintLibrary this.ItemName = libraryProvider.GetPrintItemName(itemIndex); this.libraryProvider = libraryProvider; - this.itemIndex = itemIndex; + this.ItemIndex = itemIndex; CreateGuiElements(); @@ -84,7 +84,7 @@ namespace MatterHackers.MatterControl.PrintLibrary { get { - return libraryProvider.IsItemProtected(itemIndex); + return libraryProvider.IsItemProtected(ItemIndex); } } @@ -92,7 +92,7 @@ namespace MatterHackers.MatterControl.PrintLibrary { if (printItemInstance == null) { - printItemInstance = await libraryProvider.GetPrintItemWrapperAsync(this.itemIndex, ReportProgressRatio); + printItemInstance = await libraryProvider.GetPrintItemWrapperAsync(this.ItemIndex, ReportProgressRatio); } return printItemInstance; @@ -223,7 +223,7 @@ namespace MatterHackers.MatterControl.PrintLibrary public async override void RemoveFromCollection() { - LibraryDataView.CurrentLibraryProvider.RemoveItem(itemIndex); + LibraryDataView.CurrentLibraryProvider.RemoveItem(ItemIndex); } protected override SlideWidget GetItemActionButtons() @@ -287,7 +287,7 @@ namespace MatterHackers.MatterControl.PrintLibrary protected async override void RemoveThisFromPrintLibrary() { // TODO: The LibraryProvider does not need a printitemwrapper to remove an item! Why not an interger like the others? - LibraryDataView.CurrentLibraryProvider.RemoveItem(itemIndex); + LibraryDataView.CurrentLibraryProvider.RemoveItem(ItemIndex); } private void ExportQueueItemWindow_Closed(object sender, EventArgs e) diff --git a/Library/PrintLibraryWidget.cs b/Library/PrintLibraryWidget.cs index 7b27cc63d..a2203955b 100644 --- a/Library/PrintLibraryWidget.cs +++ b/Library/PrintLibraryWidget.cs @@ -281,9 +281,24 @@ namespace MatterHackers.MatterControl.PrintLibrary { if (renameItemWindow == null) { - string currentName = "currentName"; + LibraryRowItem rowItem = libraryDataView.SelectedItems[0]; + LibraryRowItemPart partItem = rowItem as LibraryRowItemPart; + LibraryRowItemCollection collectionItem = rowItem as LibraryRowItemCollection; + + string currentName = libraryDataView.SelectedItems[0].ItemName; + renameItemWindow = new RenameItemWindow(currentName, (returnInfo) => - { + { + if (partItem != null) + { + LibraryDataView.CurrentLibraryProvider.RenameItem(partItem.ItemIndex, returnInfo.newName); + } + else if (collectionItem != null) + { + LibraryDataView.CurrentLibraryProvider.RenameCollection(collectionItem.CollectionIndex, returnInfo.newName); + } + + libraryDataView.SelectedItems.Clear(); }); renameItemWindow.Closed += (sender2, e2) => { renameItemWindow = null; }; diff --git a/Library/Provider/LibraryProviderFileSystem.cs b/Library/Provider/LibraryProviderFileSystem.cs index ecbef9688..a7bd45ac5 100644 --- a/Library/Provider/LibraryProviderFileSystem.cs +++ b/Library/Provider/LibraryProviderFileSystem.cs @@ -191,7 +191,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider string sourceDir = Path.Combine(rootPath, currentDirectoryDirectories[collectionIndexToRename]); if (Directory.Exists(sourceDir)) { - string destDir = Path.Combine(Path.GetDirectoryName(sourceDir), sourceDir); + string destDir = Path.Combine(Path.GetDirectoryName(sourceDir), newName); Directory.Move(sourceDir, destDir); Stopwatch time = Stopwatch.StartNew(); // Wait for up to some amount of time for the directory to be gone. diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 3149168b7..39e981abe 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -3430,3 +3430,12 @@ Translated:Cloud Library English:Rename Translated:Rename +English:Rename Item: +Translated:Rename Item: + +English:New Name +Translated:New Name + +English:Enter New Name Here +Translated:Enter New Name Here +