Long running tasks prototype
- Issue MatterHackers/MCCentral#2393 Finish up and check in long running tasks prototype
This commit is contained in:
parent
b1090c9ed3
commit
f401278d25
19 changed files with 541 additions and 403 deletions
|
|
@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
|
@ -52,11 +53,15 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
private OverflowMenu overflowMenu;
|
||||
|
||||
private PrinterTabPage printerTabPage;
|
||||
internal GuiWidget sliceButton;
|
||||
|
||||
private bool activelySlicing;
|
||||
|
||||
public PrinterActionsBar(PrinterConfig printer, PrinterTabPage printerTabPage, ThemeConfig theme)
|
||||
{
|
||||
this.printer = printer;
|
||||
this.printerTabPage = printerTabPage;
|
||||
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
this.VAnchor = VAnchor.Fit;
|
||||
|
|
@ -80,7 +85,22 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
this.AddChild(new PrintPauseResumeButton(this, printerTabPage, printer, theme));
|
||||
this.AddChild(new CancelButton(printer, theme));
|
||||
|
||||
this.AddChild(sliceButton = new SlicePopupMenu(printer, theme, printerTabPage));
|
||||
var sliceButton = new SliceButton(printer, theme)
|
||||
{
|
||||
Name = "Generate Gcode Button",
|
||||
BackgroundColor = theme.ButtonFactory.Options.NormalFillColor,
|
||||
HoverColor = theme.ButtonFactory.Options.HoverFillColor,
|
||||
Margin = theme.ButtonSpacing,
|
||||
};
|
||||
|
||||
sliceButton.Click += async (s, e) =>
|
||||
{
|
||||
if (!activelySlicing)
|
||||
{
|
||||
await this.SliceFileTask();
|
||||
}
|
||||
};
|
||||
this.AddChild(sliceButton);
|
||||
|
||||
// put in the detail message
|
||||
var printerConnectionDetail = new TextWidget("")
|
||||
|
|
@ -133,6 +153,40 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
this.AddChild(overflowMenu);
|
||||
}
|
||||
|
||||
public async Task SliceFileTask()
|
||||
{
|
||||
if (printer.Settings.PrinterSelected)
|
||||
{
|
||||
if (printer.Settings.IsValid() && printer.Bed.EditContext.SourceItem != null)
|
||||
{
|
||||
activelySlicing = true;
|
||||
|
||||
try
|
||||
{
|
||||
await ApplicationController.Instance.Tasks.Execute(printerTabPage.view3DWidget.SaveChanges);
|
||||
|
||||
await ApplicationController.Instance.SliceFileLoadOutput(
|
||||
printer,
|
||||
printer.Bed.EditContext.PartFilePath,
|
||||
printer.Bed.EditContext.GCodeFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error slicing file: " + ex.Message);
|
||||
}
|
||||
|
||||
activelySlicing = false;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
StyledMessageBox.ShowMessageBox("Oops! Please select a printer in order to continue slicing.", "Select Printer", StyledMessageBox.MessageType.OK);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddChild(GuiWidget childToAdd, int indexInChildrenList = -1)
|
||||
{
|
||||
childToAdd.VAnchor = VAnchor.Center;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue