diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 1d8f34337..741a28e7e 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -996,19 +996,33 @@ namespace MatterHackers.MatterControl if (sender is PrinterConnection printerConnection) { UiThread.RunOnIdle(() => - StyledMessageBox.ShowMessageBox( - (clickedOk) => + { + var messageBox = new StyledMessageBox.MessageBoxPage((clickedOk) => + { + if (clickedOk && printerConnection.Paused) { - if (clickedOk && printerConnection.Paused) - { - printerConnection.Resume(); - } - }, - message, - "Printer Hardware Error".Localize(), - StyledMessageBox.MessageType.YES_NO, - "Resume".Localize(), - "OK".Localize())); + printerConnection.Resume(); + } + }, + message, + "Printer Hardware Error".Localize(), + StyledMessageBox.MessageType.YES_NO, + null, + 400, + 300, + "Resume".Localize(), + "OK".Localize(), + ApplicationController.Instance.Theme); + + var exportButton = Theme.CreateDialogButton("Export Print Log...".Localize()); + exportButton.Click += (s, e) => + { + UiThread.RunOnIdle(() => TerminalLog.Export(printerConnection), .1); + }; + messageBox.AddPageAction(exportButton); + + DialogWindow.Show(messageBox); + }); } } } @@ -1832,7 +1846,7 @@ namespace MatterHackers.MatterControl "Warning - GCode file".Localize(), new GuiWidget[] { - hideGCodeWarningCheckBox + hideGCodeWarningCheckBox }, StyledMessageBox.MessageType.YES_NO); }); diff --git a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs index 66eef43e3..bb1ba147e 100644 --- a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs @@ -39,7 +39,6 @@ using MatterHackers.Agg.VertexSource; using MatterHackers.DataConverters2D; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; -using MatterHackers.MatterControl.DesignTools.Operations; using MatterHackers.PolygonMesh.Csg; using MatterHackers.VectorMath; using Newtonsoft.Json; diff --git a/MatterControlLib/PrinterCommunication/Drivers/Emulator/Emulator.cs b/MatterControlLib/PrinterCommunication/Drivers/Emulator/Emulator.cs index f21d8ab3e..fd120c836 100644 --- a/MatterControlLib/PrinterCommunication/Drivers/Emulator/Emulator.cs +++ b/MatterControlLib/PrinterCommunication/Drivers/Emulator/Emulator.cs @@ -99,11 +99,18 @@ namespace MatterHackers.PrinterEmulator { "M851", SetXYZProbeOffset }, { "N", ParseChecksumLine }, { "SLOW", ChangeToSlow }, + { "THROWERROR", ThrowError }, { "T0", SetExtruderIndex }, { "T1", SetExtruderIndex }, }; } + private string ThrowError(string arg) + { + // throw an error for testing + return "MINTEMP\nok\n"; + } + private AxisAlignedBoundingBox xMaxTriggerRegion = new AxisAlignedBoundingBox(95, 210, -10, 105, 220, 0); private string ReportEndStops(string arg) @@ -328,6 +335,7 @@ namespace MatterHackers.PrinterEmulator Commands: SLOW // make the emulator simulate actual printing speeds (default) FAST // run as fast as possible + THROWERROR // generate a simulated error for testing Emulating: FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:https://github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:Framelis v1 EXTRUDER_COUNT:1 UUID:155f84b5-d4d7-46f4-9432-667e6876f37a ok diff --git a/MatterControlLib/PrinterControls/TerminalWindow/TerminalLog.cs b/MatterControlLib/PrinterControls/TerminalWindow/TerminalLog.cs index 1bd582a07..18f159e7c 100644 --- a/MatterControlLib/PrinterControls/TerminalWindow/TerminalLog.cs +++ b/MatterControlLib/PrinterControls/TerminalWindow/TerminalLog.cs @@ -30,6 +30,8 @@ either expressed or implied, of the FreeBSD Project. using System; using System.Collections.Generic; using System.Linq; +using MatterHackers.Agg.Platform; +using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.PrinterCommunication; @@ -59,6 +61,49 @@ namespace MatterHackers.MatterControl } } + public static void Export(PrinterConnection printerConnection) + { + AggContext.FileDialogs.SaveFileDialog( + new SaveFileDialogParams("Save as Text|*.txt") + { + Title = "MatterControl: Terminal Log", + ActionButtonLabel = "Export", + FileName = "print_log.txt" + }, + (saveParams) => + { + if (!string.IsNullOrEmpty(saveParams.FileName)) + { + string filePathToSave = saveParams.FileName; + + if (filePathToSave != null && filePathToSave != "") + { + try + { + printerConnection.TerminalLog.WriteToFile(filePathToSave); + } + catch (UnauthorizedAccessException ex) + { + printerConnection.TerminalLog.WriteLine(""); + printerConnection.TerminalLog.WriteLine("WARNING: Write Failed!".Localize()); + printerConnection.TerminalLog.WriteLine("Can't access".Localize() + " " + filePathToSave); + printerConnection.TerminalLog.WriteLine(""); + + UiThread.RunOnIdle(() => + { + StyledMessageBox.ShowMessageBox(ex.Message, "Couldn't save file".Localize()); + }); + } + } + } + }); + } + + private void WriteToFile(string filePath) + { + System.IO.File.WriteAllLines(filePath, AllLines()); + } + public event EventHandler LineAdded; public event EventHandler LogCleared; diff --git a/MatterControlLib/PrinterControls/TerminalWindow/TerminalWidget.cs b/MatterControlLib/PrinterControls/TerminalWindow/TerminalWidget.cs index 4e1356a57..78e6238ac 100644 --- a/MatterControlLib/PrinterControls/TerminalWindow/TerminalWidget.cs +++ b/MatterControlLib/PrinterControls/TerminalWindow/TerminalWidget.cs @@ -258,45 +258,7 @@ namespace MatterHackers.MatterControl exportButton.Margin = theme.ButtonSpacing; exportButton.Click += (s, e) => { - UiThread.RunOnIdle(() => - { - AggContext.FileDialogs.SaveFileDialog( - new SaveFileDialogParams("Save as Text|*.txt") - { - Title = "MatterControl: Terminal Log", - ActionButtonLabel = "Export", - FileName = "print_log.txt" - }, - (saveParams) => - { - if (!string.IsNullOrEmpty(saveParams.FileName)) - { - string filePathToSave = saveParams.FileName; - - if (filePathToSave != null && filePathToSave != "") - { - try - { - textScrollWidget.WriteToFile(filePathToSave); - } - catch (UnauthorizedAccessException ex) - { - Debug.Print(ex.Message); - - printer.Connection.TerminalLog.WriteLine(""); - printer.Connection.TerminalLog.WriteLine("WARNING: Write Failed!".Localize()); - printer.Connection.TerminalLog.WriteLine("Can't access".Localize() + " " + filePathToSave); - printer.Connection.TerminalLog.WriteLine(""); - - UiThread.RunOnIdle(() => - { - StyledMessageBox.ShowMessageBox(ex.Message, "Couldn't save file".Localize()); - }); - } - } - } - }); - }); + UiThread.RunOnIdle(() => TerminalLog.Export(printer.Connection)); }; footerRow.AddChild(exportButton); diff --git a/MatterControlLib/PrinterControls/TerminalWindow/TextScrollWidget.cs b/MatterControlLib/PrinterControls/TerminalWindow/TextScrollWidget.cs index d6530dc12..33b823240 100644 --- a/MatterControlLib/PrinterControls/TerminalWindow/TextScrollWidget.cs +++ b/MatterControlLib/PrinterControls/TerminalWindow/TextScrollWidget.cs @@ -155,11 +155,6 @@ namespace MatterHackers.MatterControl } } - public void WriteToFile(string filePath) - { - System.IO.File.WriteAllLines(filePath, terminalLog.AllLines()); - } - public override void OnClosed(EventArgs e) { // Unregister listeners diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index f0f251065..f1c669e23 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit f0f25106545fb7ec1778cae939b31a248f38f4fd +Subproject commit f1c669e23ab522b1fc925db1116bbf56788d3e88