diff --git a/MatterControl.Winforms/InspectForm.cs b/MatterControl.Winforms/InspectForm.cs index d7469d804..79cb4a065 100644 --- a/MatterControl.Winforms/InspectForm.cs +++ b/MatterControl.Winforms/InspectForm.cs @@ -509,16 +509,7 @@ namespace MatterHackers.MatterControl private void button1_Click(object sender, EventArgs e) { var context = ApplicationController.Instance.ActivePrinters.First().Connection.TotalGCodeStream; - - var sb = new StringBuilder(); - - while (context is GCodeStream gCodeStream) - { - sb.AppendFormat("{0} {1}\r\n", gCodeStream.GetType().Name, gCodeStream.DebugInfo); - context = gCodeStream.InternalStream; - } - - textBox1.Text = sb.ToString(); + textBox1.Text = context.GetDebugState(); } } } diff --git a/MatterControlLib/CustomWidgets/ExtensionMethods.cs b/MatterControlLib/CustomWidgets/ExtensionMethods.cs index 97306c6f7..41cc0fd71 100644 --- a/MatterControlLib/CustomWidgets/ExtensionMethods.cs +++ b/MatterControlLib/CustomWidgets/ExtensionMethods.cs @@ -28,11 +28,13 @@ either expressed or implied, of the FreeBSD Project. */ using System.Linq; +using System.Text; using MatterHackers.Agg.Image; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.ImageProcessing; using MatterHackers.MatterControl.CustomWidgets; +using MatterHackers.MatterControl.PrinterCommunication.Io; namespace MatterHackers.MatterControl { @@ -61,5 +63,26 @@ namespace MatterHackers.MatterControl { return sourceImage.AnyAlphaToColor(ApplicationController.Instance.Theme.PrimaryAccentColor); } + + + public static string GetDebugState(this GCodeStream sourceStream) + { + return GetDebugState(sourceStream, ApplicationController.Instance.ActivePrinters.First()); + } + + public static string GetDebugState(this GCodeStream sourceStream, PrinterConfig printer) + { + var context = printer.Connection.TotalGCodeStream; + + var sb = new StringBuilder(); + + while (context is GCodeStream gCodeStream) + { + sb.AppendFormat("{0} {1}\r\n", gCodeStream.GetType().Name, gCodeStream.DebugInfo); + context = gCodeStream.InternalStream; + } + + return sb.ToString(); + } } } diff --git a/MatterControlLib/PrinterCommunication/Io/ProcessWriteRegExStream.cs b/MatterControlLib/PrinterCommunication/Io/ProcessWriteRegExStream.cs index 6d902776f..1c4640171 100644 --- a/MatterControlLib/PrinterCommunication/Io/ProcessWriteRegExStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/ProcessWriteRegExStream.cs @@ -101,15 +101,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io public static List ProcessWriteRegEx(string lineToWrite, PrinterConfig printer) { - var WriteLineReplacements = printer.Settings.Helpers.WriteLineReplacements; - var linesToWrite = new List(); linesToWrite.Add(lineToWrite); var addedLines = new List(); for (int i = 0; i < linesToWrite.Count; i++) { - foreach (var item in WriteLineReplacements) + foreach (var item in printer.Settings.Helpers.WriteLineReplacements) { var splitReplacement = item.Replacement.Split(','); if (splitReplacement.Length > 0)