Skip plugins which are invalid for the current printer

- Issue MatterHackers/MCCentral#2829
Export dialog should filter non-applicable export plugins
This commit is contained in:
John Lewin 2018-02-13 18:30:17 -08:00
parent 55511875b1
commit b582a83082
6 changed files with 24 additions and 17 deletions

View file

@ -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

View file

@ -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<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath)
{

View file

@ -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<bool>("enable_sailfish_communication");
}
public bool ExportPossible(ILibraryAsset libraryItem) => true;
public GuiWidget GetOptionsPanel()
{
var container = new FlowLayoutWidget()

View file

@ -44,7 +44,10 @@ namespace MatterHackers.MatterControl
void Initialize(PrinterConfig printer);
Task<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath);
bool EnabledForCurrentPart(ILibraryAssetStream libraryContent);
bool Enabled { get; }
bool ExportPossible(ILibraryAsset libraryItem);
}
public interface IExportWithOptions

View file

@ -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<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath)
{

View file

@ -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<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath)
{