diff --git a/Library/PrintLibraryWidget.cs b/Library/PrintLibraryWidget.cs index d9a00e946..9f00d0e20 100644 --- a/Library/PrintLibraryWidget.cs +++ b/Library/PrintLibraryWidget.cs @@ -49,12 +49,14 @@ namespace MatterHackers.MatterControl.PrintLibrary internal bool multipleItems; internal bool protectedItems; internal bool collectionItems; + internal bool shareItems; - internal ButtonEnableData(bool multipleItems, bool protectedItems, bool collectionItems) + internal ButtonEnableData(bool multipleItems, bool protectedItems, bool collectionItems, bool shareItems = false) { this.multipleItems = multipleItems; this.protectedItems = protectedItems; this.collectionItems = collectionItems; + this.shareItems = shareItems; } } @@ -349,6 +351,19 @@ namespace MatterHackers.MatterControl.PrintLibrary itemOperationButtons.AddChild(removeFromLibraryButton); } + + + // add the share button + { + Button shareFromLibraryButton = editButtonFactory.Generate("Share".Localize()); + shareFromLibraryButton.Margin = new BorderDouble(3, 0); + shareFromLibraryButton.Click += shareFromLibraryButton_Click; + editButtonsEnableData.Add(new ButtonEnableData(false, false, false, true)); + itemOperationButtons.AddChild(shareFromLibraryButton); + } + + + // add a rename button { Button renameFromLibraryButton = editButtonFactory.Generate("Rename".Localize()); @@ -529,6 +544,14 @@ namespace MatterHackers.MatterControl.PrintLibrary } } + if (editButtonsEnableData[buttonIndex].shareItems) + { + if (!libraryDataView.CurrentLibraryProvider.CanShare) + { + enabledStateToSet = false; + } + } + button.Enabled = enabledStateToSet; } } @@ -571,6 +594,19 @@ namespace MatterHackers.MatterControl.PrintLibrary libraryDataView.ClearSelectedItems(); } + private void shareFromLibraryButton_Click(object sender, EventArgs e) + { + if (libraryDataView.SelectedItems.Count == 1) + { + LibraryRowItem rowItem = libraryDataView.SelectedItems[0]; + LibraryRowItemPart partItem = rowItem as LibraryRowItemPart; + if (partItem != null) + { + libraryDataView.CurrentLibraryProvider.ShareItem(partItem.ItemIndex); + } + } + } + private void exportButton_Click(object sender, EventArgs e) { //Open export options diff --git a/Library/Provider/LibraryProvider.cs b/Library/Provider/LibraryProvider.cs index 47a1a960c..e25a90cee 100644 --- a/Library/Provider/LibraryProvider.cs +++ b/Library/Provider/LibraryProvider.cs @@ -163,6 +163,8 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider public abstract int ItemCount { get; } + public abstract bool CanShare { get; } + public abstract string ProviderKey { get; } public abstract void AddCollectionToLibrary(string collectionName); @@ -194,6 +196,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider public abstract void RenameCollection(int collectionIndexToRename, string newName); public abstract void RenameItem(int itemIndexToRename, string newName); + public abstract void ShareItem(int itemIndexToShare); #endregion Abstract Methods diff --git a/Library/Provider/LibraryProviderFileSystem.cs b/Library/Provider/LibraryProviderFileSystem.cs index ea1b5d7ea..5c2f5143e 100644 --- a/Library/Provider/LibraryProviderFileSystem.cs +++ b/Library/Provider/LibraryProviderFileSystem.cs @@ -123,6 +123,13 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider } } + public override void ShareItem(int itemIndexToShare) + { + + } + + public override bool CanShare { get { return false; } } + public override int ItemCount { get diff --git a/Library/Provider/LibraryProviderHistory.cs b/Library/Provider/LibraryProviderHistory.cs index 807876d3f..3f73ef80f 100644 --- a/Library/Provider/LibraryProviderHistory.cs +++ b/Library/Provider/LibraryProviderHistory.cs @@ -103,6 +103,11 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider throw new NotImplementedException(); } + public override void ShareItem(int itemIndexToShare) + { + + } + public static string StaticProviderKey { get @@ -119,6 +124,8 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider } } + public override bool CanShare { get { return false; } } + public override int ItemCount { get diff --git a/Library/Provider/LibraryProviderQueue.cs b/Library/Provider/LibraryProviderQueue.cs index f1a062729..93757636a 100644 --- a/Library/Provider/LibraryProviderQueue.cs +++ b/Library/Provider/LibraryProviderQueue.cs @@ -113,6 +113,11 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider throw new NotImplementedException(); } + public override void ShareItem(int itemIndexToShare) + { + + } + public static string StaticProviderKey { get @@ -121,13 +126,15 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider } } + public override bool CanShare { get { return false; } } + public override int CollectionCount { get { return 0; } - } + } public override int ItemCount { diff --git a/Library/Provider/LibraryProviderSelector.cs b/Library/Provider/LibraryProviderSelector.cs index 24c3dda5c..9598244d4 100644 --- a/Library/Provider/LibraryProviderSelector.cs +++ b/Library/Provider/LibraryProviderSelector.cs @@ -164,6 +164,13 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider throw new NotImplementedException(); } + public override bool CanShare { get { return false; } } + + public override void ShareItem(int itemIndexToShare) + { + + } + public void CloudSyncStatusChanged(object sender, EventArgs eventArgs) { var e = eventArgs as ApplicationController.CloudSyncEventArgs; diff --git a/Library/Provider/LibraryProviderSqlite.cs b/Library/Provider/LibraryProviderSqlite.cs index abeacbf7c..bbcf6ae56 100644 --- a/Library/Provider/LibraryProviderSqlite.cs +++ b/Library/Provider/LibraryProviderSqlite.cs @@ -136,6 +136,8 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider } } + public override bool CanShare { get { return false; } } + public override int CollectionCount { get @@ -365,6 +367,11 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider LoadLibraryItems(); } + public override void ShareItem(int itemIndexToShare) + { + + } + protected static void SaveToLibraryFolder(PrintItemWrapper printItemWrapper, List meshGroups, bool AbsolutePositioned) { string[] metaData = { "Created By", "MatterControl" }; diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index c20a0e05e..ade4c6518 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -3745,3 +3745,39 @@ Translated:Add a new Material Preset English:Import an existing Material Preset Translated:Import an existing Material Preset +English:Share Library Item +Translated:Share Library Item + +English:Share Options +Translated:Share Options + +English:Your Share Code: +Translated:Your Share Code: + +English:Anyone with this code will have access +Translated:Anyone with this code will have access + +English:Share with someone +Translated:Share with someone + +English:read-only +Translated:read-only + +English:Generate Share Code +Translated:Generate Share Code + +English:Please wait. Retrieving share code... +Translated:Please wait. Retrieving share code... + +English:Provide this code to grant someone read-only access. +Translated:Provide this code to grant someone read-only access. + +English:Please wait. Sending invite... +Translated:Please wait. Sending invite... + +English:Invite sent! +Translated:Invite sent! + +English:Your invite has been sent! +Translated:Your invite has been sent! +