diff --git a/CustomWidgets/ExportPrintItemPage.cs b/CustomWidgets/ExportPrintItemPage.cs index 1091c846f..a8d0deb1a 100644 --- a/CustomWidgets/ExportPrintItemPage.cs +++ b/CustomWidgets/ExportPrintItemPage.cs @@ -83,6 +83,12 @@ namespace MatterHackers.MatterControl { plugin.Initialize(printer); + // Skip plugins which are invalid for the current printer + if (!plugin.Enabled) + { + continue; + } + // Create export button for each plugin var pluginButton = new RadioButton(new RadioImageWidget(plugin.ButtonText, plugin.Icon)) { @@ -114,8 +120,6 @@ namespace MatterHackers.MatterControl } } - //if (plugin.EnabledForCurrentPart(libraryContent)) - contentRow.AddChild(new VerticalSpacer()); // TODO: make this work on the mac and then delete this if diff --git a/Library/Export/FolderExport.cs b/Library/Export/FolderExport.cs index 901eec6b2..0cb9578a7 100644 --- a/Library/Export/FolderExport.cs +++ b/Library/Export/FolderExport.cs @@ -53,10 +53,9 @@ namespace MatterHackers.MatterControl.Library.Export { } - public bool EnabledForCurrentPart(ILibraryAssetStream libraryContent) - { - return !libraryContent.IsProtected; - } + public bool Enabled => true; + + public bool ExportPossible(ILibraryAsset libraryItem) => true; public async Task Generate(IEnumerable libraryItems, string outputPath) { diff --git a/Library/Export/GCodeExport.cs b/Library/Export/GCodeExport.cs index 4899d0020..fb8ce4050 100644 --- a/Library/Export/GCodeExport.cs +++ b/Library/Export/GCodeExport.cs @@ -65,11 +65,14 @@ namespace MatterHackers.MatterControl.Library.Export this.printer = printer; } - public bool EnabledForCurrentPart(ILibraryAssetStream libraryContent) + public bool Enabled { - return !libraryContent.IsProtected; + get => printer.Settings.PrinterSelected + && !printer.Settings.GetValue("enable_sailfish_communication"); } + public bool ExportPossible(ILibraryAsset libraryItem) => true; + public GuiWidget GetOptionsPanel() { var container = new FlowLayoutWidget() diff --git a/Library/Export/IExportPlugin.cs b/Library/Export/IExportPlugin.cs index 983e57f97..095360fef 100644 --- a/Library/Export/IExportPlugin.cs +++ b/Library/Export/IExportPlugin.cs @@ -44,7 +44,10 @@ namespace MatterHackers.MatterControl void Initialize(PrinterConfig printer); Task Generate(IEnumerable libraryItems, string outputPath); - bool EnabledForCurrentPart(ILibraryAssetStream libraryContent); + + bool Enabled { get; } + + bool ExportPossible(ILibraryAsset libraryItem); } public interface IExportWithOptions diff --git a/Library/Export/StlExport.cs b/Library/Export/StlExport.cs index c5e69668a..6dd27d46f 100644 --- a/Library/Export/StlExport.cs +++ b/Library/Export/StlExport.cs @@ -52,10 +52,9 @@ namespace MatterHackers.MatterControl.Library.Export { } - public bool EnabledForCurrentPart(ILibraryAssetStream libraryContent) - { - return !libraryContent.IsProtected; - } + public bool Enabled => true; + + public bool ExportPossible(ILibraryAsset libraryItem) => true; public Task Generate(IEnumerable libraryItems, string outputPath) { diff --git a/Library/Export/ZipExport.cs b/Library/Export/ZipExport.cs index e99907b8f..7899d92d9 100644 --- a/Library/Export/ZipExport.cs +++ b/Library/Export/ZipExport.cs @@ -54,10 +54,9 @@ namespace MatterHackers.MatterControl.Library.Export { } - public bool EnabledForCurrentPart(ILibraryAssetStream libraryContent) - { - return !libraryContent.IsProtected; - } + public bool Enabled => true; + + public bool ExportPossible(ILibraryAsset libraryItem) => true; public async Task Generate(IEnumerable libraryItems, string outputPath) {