From cf3f856ac03b133c8ce6aa4f6ae94e9e98b15fc8 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 24 Jul 2020 18:20:53 -0700 Subject: [PATCH] Improving 'share with me' help --- .../Library/Widgets/LibraryWidget.cs | 63 ++++++++++++++++-- StaticData/Icons/enter-code.png | Bin 0 -> 1081 bytes StaticData/Icons/share.png | Bin 0 -> 664 bytes 3 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 StaticData/Icons/enter-code.png create mode 100644 StaticData/Icons/share.png diff --git a/MatterControlLib/Library/Widgets/LibraryWidget.cs b/MatterControlLib/Library/Widgets/LibraryWidget.cs index 814079cdc..4fe553b39 100644 --- a/MatterControlLib/Library/Widgets/LibraryWidget.cs +++ b/MatterControlLib/Library/Widgets/LibraryWidget.cs @@ -686,6 +686,24 @@ namespace MatterHackers.MatterControl.PrintLibrary } }); + menuActions.Add(new LibraryAction(ActionScope.ListView) + { + Title = "Enter Share Code...".Localize(), + Icon = AggContext.StaticData.LoadIcon("enter-code.png", 16, 16, theme.InvertIcons), + Action = (selectedLibraryItems, listView) => + { + UiThread.RunOnIdle(() => + { + // Implementation already does RunOnIdle + ApplicationController.Instance.EnterShareCode?.Invoke(); + }); + }, + IsEnabled = (s, l) => + { + return l.ActiveContainer.CollectionKeyName == "sharedwithme"; + } + }); + if (allowPrint) { menuActions.Add(new LibraryAction(ActionScope.ListItem) @@ -716,7 +734,7 @@ namespace MatterHackers.MatterControl.PrintLibrary break; default: - //TODO: Otherwise add the selected items to the plate and print the plate? + // TODO: Otherwise add the selected items to the plate and print the plate? if (printer != null) { UiThread.RunOnIdle(async () => @@ -736,7 +754,8 @@ namespace MatterHackers.MatterControl.PrintLibrary && selectedListItems.FirstOrDefault()?.Model is ILibraryItem firstItem && !(firstItem is ILibraryContainer) && (communicationState == CommunicationStates.Connected - || communicationState == CommunicationStates.FinishedPrint); + || communicationState == CommunicationStates.FinishedPrint) + && listView.SelectedItems.All(i => !(i.Model is ILibraryContainerLink)); } }); } @@ -748,16 +767,47 @@ namespace MatterHackers.MatterControl.PrintLibrary Icon = AggContext.StaticData.LoadIcon("cube.png", 16, 16, theme.InvertIcons), Action = (selectedLibraryItems, listView) => { - ApplicationController.Instance.OpenIntoNewTab(selectedLibraryItems); + if (listView.SelectedItems.All(i => !(i.Model is ILibraryContainerLink))) + { + ApplicationController.Instance.OpenIntoNewTab(selectedLibraryItems); + } + else + { + // open the folder + listView.SelectedItems.First().OnDoubleClick(); + } }, IsEnabled = (selectedListItems, listView) => { - // Singleselect - disallow containers - return listView.SelectedItems.Count == 1 - && listView.SelectedItems.All(i => !(i.Model is ILibraryContainerLink)); + // Singleselect + return listView.SelectedItems.Count == 1; } }); + // Share with me + menuActions.Add(new LibraryAction(ActionScope.ListItem) + { + Title = "Enter Share Code...".Localize(), + Icon = AggContext.StaticData.LoadIcon("enter-code.png", 16, 16, theme.InvertIcons), + Action = (selectedLibraryItems, listView) => + { + UiThread.RunOnIdle(() => + { + // Implementation already does RunOnIdle + ApplicationController.Instance.EnterShareCode?.Invoke(); + }); + }, + IsEnabled = (s, l) => + { + return s.First() + .ViewWidget + .Descendants() + .Where(i => i.Name != null && i.Name.Contains("Shared with Me")) + .Any(); + } + }); + + // edit menu item menuActions.Add(new LibraryAction(ActionScope.ListItem) { @@ -989,6 +1039,7 @@ namespace MatterHackers.MatterControl.PrintLibrary menuActions.Add(new LibraryAction(ActionScope.ListItem) { Title = "Share".Localize(), + Icon = AggContext.StaticData.LoadIcon("share.png", 16, 16, theme.InvertIcons), Action = (selectedLibraryItems, listView) => { // Previously - shareFromLibraryButton_Click diff --git a/StaticData/Icons/enter-code.png b/StaticData/Icons/enter-code.png new file mode 100644 index 0000000000000000000000000000000000000000..bfbcaac9c932bf49949dcbf7f0ba51197e73b743 GIT binary patch literal 1081 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}Y)RhkE)4%caKYZ?lNlHo zI14-?iy0XB4ude`@%$Aj3=9nHC7!;n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