From 715d051d79effb331ee40a68f9d634f66a64fa5b Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 20 Mar 2019 18:20:46 -0700 Subject: [PATCH] Need to unregister from printer so we don't hold in memory and call multiple times --- .../CustomWidgets/XyCalibrationCollectDataPage.cs | 4 +++- MatterControlLib/CustomWidgets/XyCalibrationStartPrintPage.cs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/MatterControlLib/CustomWidgets/XyCalibrationCollectDataPage.cs b/MatterControlLib/CustomWidgets/XyCalibrationCollectDataPage.cs index d14d03c60..9f0995485 100644 --- a/MatterControlLib/CustomWidgets/XyCalibrationCollectDataPage.cs +++ b/MatterControlLib/CustomWidgets/XyCalibrationCollectDataPage.cs @@ -40,6 +40,7 @@ namespace MatterHackers.MatterControl private List xButtons; private XyCalibrationData xyCalibrationData; private List yButtons; + private bool HaveWrittenData = false; public XyCalibrationCollectDataPage(ISetupWizard setupWizard, PrinterConfig printer, XyCalibrationData xyCalibrationData) : base(setupWizard) @@ -108,7 +109,7 @@ namespace MatterHackers.MatterControl public override void OnClosed(EventArgs e) { // save the offsets to the extruder - if (!HasBeenClosed + if (!HaveWrittenData && xyCalibrationData.XPick != -1 && xyCalibrationData.YPick != -1) { @@ -117,6 +118,7 @@ namespace MatterHackers.MatterControl hotendOffset.Y -= xyCalibrationData.Offset * -2 + xyCalibrationData.Offset * xyCalibrationData.YPick; printer.Settings.Helpers.SetExtruderOffset(xyCalibrationData.ExtruderToCalibrateIndex, hotendOffset); + HaveWrittenData = true; } base.OnClosed(e); diff --git a/MatterControlLib/CustomWidgets/XyCalibrationStartPrintPage.cs b/MatterControlLib/CustomWidgets/XyCalibrationStartPrintPage.cs index fc1914fb0..383b54ac8 100644 --- a/MatterControlLib/CustomWidgets/XyCalibrationStartPrintPage.cs +++ b/MatterControlLib/CustomWidgets/XyCalibrationStartPrintPage.cs @@ -108,6 +108,7 @@ namespace MatterHackers.MatterControl private void RestoreBedAndClearPrinterCallbacks() { printer.Connection.Disposed -= Connection_Disposed; + printer.Connection.CommunicationStateChanged -= Connection_CommunicationStateChanged; } private void Connection_CommunicationStateChanged(object sender, EventArgs e)