disable export if printer not setup

show reason why export is disabled

issue: MatterHackers/MCCentral#4573
Export should follow the same rules as printer/setup buttons
This commit is contained in:
Lars Brubaker 2018-11-29 17:35:08 -08:00
parent 33d4ed529c
commit 726b14f9c0
9 changed files with 66 additions and 8 deletions

View file

@ -57,6 +57,8 @@ namespace MatterHackers.MatterControl.Library.Export
public bool Enabled => true;
public string DissabledReason => "";
public bool ExportPossible(ILibraryAsset libraryItem) => true;
public async Task<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)

View file

@ -67,12 +67,26 @@ namespace MatterHackers.MatterControl.Library.Export
public bool Enabled
{
// TODO: Someday we should show details on why we aren't enabled...
//if (!showExportGCodeButton)
// var noGCodeMessage = "Note".Localize() + ": " + "To enable GCode export, select a printer profile.".Localize(),
get => printer.Settings.PrinterSelected
&& !printer.Settings.GetValue<bool>("enable_sailfish_communication");
&& !printer.Settings.GetValue<bool>("enable_sailfish_communication")
&& !ApplicationController.PrinterNeedsToRunSetup(printer);
}
public string DissabledReason
{
get
{
if(!printer.Settings.PrinterSelected)
{
return "No Printer Selected".Localize();
}
else if(ApplicationController.PrinterNeedsToRunSetup(printer))
{
return "Setup Needs to be Run".Localize();
}
return "";
}
}
public bool ExportPossible(ILibraryAsset libraryItem) => true;

View file

@ -49,6 +49,7 @@ namespace MatterHackers.MatterControl
Task<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken);
bool Enabled { get; }
string DissabledReason { get; }
bool ExportPossible(ILibraryAsset libraryItem);
}

View file

@ -57,6 +57,8 @@ namespace MatterHackers.MatterControl.Library.Export
public bool Enabled => true;
public string DissabledReason => "";
public bool ExportPossible(ILibraryAsset libraryItem) => true;
public Task<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)

View file

@ -58,6 +58,8 @@ namespace MatterHackers.MatterControl.Library.Export
public bool Enabled => true;
public string DissabledReason => "";
public bool ExportPossible(ILibraryAsset libraryItem) => true;
public async Task<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath, IProgress<ProgressStatus> progress, CancellationToken cancellationToken)