diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/LevelingStrings.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/LevelingStrings.cs index 5d009fdda..21574eb3f 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/LevelingStrings.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/LevelingStrings.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs index 0908a93ef..ef62c6f9b 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -36,7 +36,6 @@ using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; -using MatterHackers.MatterControl.PrinterCommunication; using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling @@ -83,7 +82,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling return extruderCount > 1 && !printer.Settings.GetValue(SettingsKey.filament_1_has_been_loaded); } - protected override IEnumerator GetWizardSteps() + protected override IEnumerator GetWizardSteps() { var extruderCount = printer.Settings.GetValue(SettingsKey.extruder_count); @@ -103,13 +102,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling // show the trim filament message { - PrinterSetupWizardPage trimFilamentPage = null; - trimFilamentPage = new PrinterSetupWizardPage( - this, - "Trim Filament".Localize(), - "") + var trimFilamentPage = new WizardPage(this, "Trim Filament".Localize(), "") { - BecomingActive = () => + PageLoad = (page) => { // start heating up the extruder printer.Connection.SetTargetHotendTemperature(extruderIndex, printer.Settings.GetValue(SettingsKey.temperature)); @@ -117,7 +112,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling var markdownText = printer.Settings.GetValue(SettingsKey.trim_filament_markdown); var markdownWidget = new MarkdownWidget(theme); markdownWidget.Markdown = markdownText = markdownText.Replace("\\n", "\n"); - trimFilamentPage.ContentRow.AddChild(markdownWidget); + page.ContentRow.AddChild(markdownWidget); } }; yield return trimFilamentPage; @@ -135,13 +130,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling // show the insert filament page { RunningInterval runningGCodeCommands = null; - PrinterSetupWizardPage insertFilamentPage = null; - insertFilamentPage = new PrinterSetupWizardPage( - this, - "Insert Filament".Localize(), - "") + var insertFilamentPage = new WizardPage(this, "Insert Filament".Localize(), "") { - BecomingActive = () => + PageLoad = (page) => { var markdownText = printer.Settings.GetValue(SettingsKey.insert_filament_markdown2); if(extruderIndex == 1) @@ -150,7 +141,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } var markdownWidget = new MarkdownWidget(theme); markdownWidget.Markdown = markdownText = markdownText.Replace("\\n", "\n"); - insertFilamentPage.ContentRow.AddChild(markdownWidget); + page.ContentRow.AddChild(markdownWidget); // turn off the fan printer.Connection.FanSpeed0To255 = 0; @@ -175,7 +166,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling }, .1); }, - BecomingInactive = () => + PageClose = () => { if (runningGCodeCommands != null) { @@ -197,15 +188,11 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling // show the loading filament progress bar { RunningInterval runningGCodeCommands = null; - PrinterSetupWizardPage loadingFilamentPage = null; - loadingFilamentPage = new PrinterSetupWizardPage( - this, - "Loading Filament".Localize(), - "") + var loadingFilamentPage = new WizardPage(this, "Loading Filament".Localize(), "") { - BecomingActive = () => + PageLoad = (page) => { - loadingFilamentPage.NextButton.Enabled = false; + page.NextButton.Enabled = false; // add the progress bar var holder = new FlowLayoutWidget() @@ -227,7 +214,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling }; holder.AddChild(progressBar); holder.AddChild(progressBarText); - loadingFilamentPage.ContentRow.AddChild(holder); + page.ContentRow.AddChild(holder); // Allow extrusion at any temperature. S0 only works on Marlin S1 works on repetier and marlin printer.Connection.QueueLine("M302 S1"); @@ -274,12 +261,12 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling && remainingLengthMm <= .001) { UiThread.ClearInterval(runningGCodeCommands); - loadingFilamentPage.NextButton.InvokeClick(); + page.NextButton.InvokeClick(); } }, .1); }, - BecomingInactive = () => + PageClose = () => { UiThread.ClearInterval(runningGCodeCommands); } @@ -312,13 +299,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling // extrude slowly so that we can prime the extruder { RunningInterval runningGCodeCommands = null; - PrinterSetupWizardPage runningCleanPage = null; - runningCleanPage = new PrinterSetupWizardPage( - this, - "Wait For Running Clean".Localize(), - "") + var runningCleanPage = new WizardPage(this, "Wait For Running Clean".Localize(), "") { - BecomingActive = () => + PageLoad = (page) => { var markdownText = printer.Settings.GetValue(SettingsKey.running_clean_markdown2); if(extruderIndex == 1) @@ -327,7 +310,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } var markdownWidget = new MarkdownWidget(theme); markdownWidget.Markdown = markdownText = markdownText.Replace("\\n", "\n"); - runningCleanPage.ContentRow.AddChild(markdownWidget); + page.ContentRow.AddChild(markdownWidget); var runningTime = Stopwatch.StartNew(); runningGCodeCommands = UiThread.SetInterval(() => @@ -346,7 +329,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling }, .1); }, - BecomingInactive = () => + PageClose = () => { UiThread.ClearInterval(runningGCodeCommands); } @@ -374,7 +357,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } } - public class DoneLoadingPage : PrinterSetupWizardPage + public class DoneLoadingPage : WizardPage { public DoneLoadingPage(PrinterSetupWizard setupWizard, int extruderIndex) : base(setupWizard, "Success".Localize(), "Success!\n\nYour filament should now be loaded".Localize()) @@ -413,11 +396,11 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } } - public override void PageIsBecomingActive() + public override void OnLoad(EventArgs args) { - ShowWizardFinished(); + this.ShowWizardFinished(); - base.PageIsBecomingActive(); + base.OnLoad(args); } } } diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/PrintLevelingWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/PrintLevelingWizard.cs index 3cf0695c8..36286553d 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/PrintLevelingWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/PrintLevelingWizard.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -27,14 +27,13 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ +using System; +using System.Collections.Generic; using MatterHackers.Agg; using MatterHackers.Localizations; using MatterHackers.MatterControl.PrinterCommunication; -using MatterHackers.MatterControl.PrinterCommunication.Io; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; -using System; -using System.Collections.Generic; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { @@ -136,7 +135,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling }; } - protected override IEnumerator GetWizardSteps() + protected override IEnumerator GetWizardSteps() { var probePositions = new List(levelingPlan.ProbeCount); for (int j = 0; j < levelingPlan.ProbeCount; j++) @@ -152,7 +151,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling if (showWelcomeScreen) { - yield return new PrinterSetupWizardPage( + yield return new WizardPage( this, "Initial Printer Setup".Localize(), string.Format( @@ -200,7 +199,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } } - yield return new PrinterSetupWizardPage( + yield return new WizardPage( this, "Print Leveling Overview".Localize(), buildWelcomeText()); @@ -259,7 +258,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling this, "Waiting For Printer To Heat".Localize(), heatingInstructions, - targetBedTemp, new double[] { targetHotendTemp }); + targetBedTemp, + new double[] { targetHotendTemp }); } double bedRadius = Math.Min(printer.Settings.GetValue(SettingsKey.bed_size).X, printer.Settings.GetValue(SettingsKey.bed_size).Y) / 2; diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/PrinterSetupWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/PrinterSetupWizard.cs index bde27aacd..4499193d1 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/PrinterSetupWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/PrinterSetupWizard.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -27,21 +27,16 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System; using System.Collections.Generic; using MatterHackers.Agg.UI; -using MatterHackers.Localizations; -using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling; -using MatterHackers.MatterControl.PrinterCommunication.Io; -using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl { public abstract class PrinterSetupWizard { - private IEnumerator pages; + private IEnumerator pages; - protected abstract IEnumerator GetWizardSteps(); + protected abstract IEnumerator GetWizardSteps(); public string WindowTitle { get; internal set; } @@ -60,14 +55,11 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle(() => { // Shutdown active page - pages.Current?.PageIsBecomingInactive(); pages.Current?.Close(); // Advance if (pages.MoveNext()) { - pages.Current?.PageIsBecomingActive(); - dialogWindow.ChangeToPage(pages.Current); } }); diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/ProbeCalibrationWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/ProbeCalibrationWizard.cs index 96d84b320..805b9c75c 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/ProbeCalibrationWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/ProbeCalibrationWizard.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -27,13 +27,12 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using MatterHackers.Agg; -using MatterHackers.Localizations; -using MatterHackers.MatterControl.PrinterCommunication.Io; -using MatterHackers.MatterControl.SlicerConfiguration; -using MatterHackers.VectorMath; using System; using System.Collections.Generic; +using MatterHackers.Agg; +using MatterHackers.Localizations; +using MatterHackers.MatterControl.SlicerConfiguration; +using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { @@ -93,7 +92,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling && printer.Settings.GetValue(SettingsKey.use_z_probe); } - protected override IEnumerator GetWizardSteps() + protected override IEnumerator GetWizardSteps() { var levelingStrings = new LevelingStrings(); var autoProbePositions = new List(3); @@ -107,7 +106,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling // make a welcome page if this is the first time calibrating the probe if (!printer.Settings.GetValue(SettingsKey.probe_has_been_calibrated)) { - yield return new PrinterSetupWizardPage( + yield return new WizardPage( this, "Initial Printer Setup".Localize(), string.Format( @@ -117,7 +116,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } // show what steps will be taken - yield return new PrinterSetupWizardPage( + yield return new WizardPage( this, "Probe Calibration Overview".Localize(), string.Format( @@ -188,7 +187,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling 0); // show what steps will be taken - yield return new PrinterSetupWizardPage( + yield return new WizardPage( this, "Measure the nozzle offset".Localize(), "{0}:\n\n\t• {1}\n\n{2}\n\n{3}".FormatWith( @@ -268,7 +267,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling printer.Connection.QueueLine($"T{extruderPriorToMeasure}"); } - yield return new CalibrateProbeLastPagelInstructions( + yield return new CalibrateProbeLastPageInstructions( this, "Done".Localize()); } diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs index 0f381df14..d1fed2514 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling this.extruderIndex = extruderIndex; } - protected override IEnumerator GetWizardSteps() + protected override IEnumerator GetWizardSteps() { var extruderCount = printer.Settings.GetValue(SettingsKey.extruder_count); @@ -109,15 +109,11 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling int extruderPriorToUnload = printer.Connection.ActiveExtruderIndex; RunningInterval runningGCodeCommands = null; - PrinterSetupWizardPage unloadingFilamentPage = null; - unloadingFilamentPage = new PrinterSetupWizardPage( - this, - "Unloading Filament".Localize(), - "") + var unloadingFilamentPage = new WizardPage(this, "Unloading Filament".Localize(), "") { - BecomingActive = () => + PageLoad = (page) => { - unloadingFilamentPage.NextButton.Enabled = false; + page.NextButton.Enabled = false; // add the progress bar var holder = new FlowLayoutWidget() @@ -139,7 +135,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling }; holder.AddChild(progressBar); holder.AddChild(progressBarText); - unloadingFilamentPage.ContentRow.AddChild(holder); + page.ContentRow.AddChild(holder); if (extruderCount > 1) { @@ -199,12 +195,12 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling && remainingLengthMm <= .001) { UiThread.ClearInterval(runningGCodeCommands); - unloadingFilamentPage.NextButton.InvokeClick(); + page.NextButton.InvokeClick(); } }, .1); }, - BecomingInactive = () => + PageClose = () => { UiThread.ClearInterval(runningGCodeCommands); } @@ -228,7 +224,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } } - public class DoneUnloadingPage : PrinterSetupWizardPage + public class DoneUnloadingPage : WizardPage { public DoneUnloadingPage(PrinterSetupWizard setupWizard, int extruderIndex) : base(setupWizard, "Success".Localize(), "Success!\n\nYour filament should now be unloaded".Localize()) @@ -248,11 +244,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling this.AddPageAction(loadFilamentButton); } - public override void PageIsBecomingActive() + public override void OnLoad(EventArgs args) { - ShowWizardFinished(); - - base.PageIsBecomingActive(); + this.ShowWizardFinished(); + base.OnLoad(args); } } } diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/PrinterSetupWizardPage.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPage.cs similarity index 78% rename from MatterControlLib/ConfigurationPage/PrintLeveling/PrinterSetupWizardPage.cs rename to MatterControlLib/ConfigurationPage/PrintLeveling/WizardPage.cs index f8abffe5f..8af7b5004 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/PrinterSetupWizardPage.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPage.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -35,20 +35,22 @@ using MatterHackers.MatterControl.CustomWidgets; namespace MatterHackers.MatterControl { - public class PrinterSetupWizardPage : DialogPage + public class WizardPage : DialogPage { public TextButton NextButton { get; } protected PrinterConfig printer; - public Action BecomingActive; - public Action BecomingInactive; - protected PrinterSetupWizard wizardContext; + public Action PageLoad { get; set; } - public PrinterSetupWizardPage(PrinterSetupWizard wizardContext, string headerText, string instructionsText) + public Action PageClose { get; set; } + + protected PrinterSetupWizard setupWizard; + + public WizardPage(PrinterSetupWizard setupWizard, string headerText, string instructionsText) { - this.wizardContext = wizardContext; - this.printer = wizardContext.Printer; - this.WindowTitle = wizardContext.WindowTitle; + this.setupWizard = setupWizard; + this.printer = setupWizard.Printer; + this.WindowTitle = setupWizard.WindowTitle; this.HeaderText = headerText; if (!string.IsNullOrEmpty(instructionsText)) @@ -64,26 +66,12 @@ namespace MatterHackers.MatterControl }; NextButton.Click += (s, e) => { - wizardContext.ShowNextPage(this.DialogWindow); + setupWizard.ShowNextPage(this.DialogWindow); }; this.AddPageAction(NextButton); } - public GuiWidget ContentRow => contentRow; - - public override void PageIsBecomingActive() - { - BecomingActive?.Invoke(); - base.PageIsBecomingActive(); - } - - public override void PageIsBecomingInactive() - { - BecomingInactive?.Invoke(); - base.PageIsBecomingInactive(); - } - protected GuiWidget CreateTextField(string text) { return new WrappedTextWidget(text) @@ -94,6 +82,18 @@ namespace MatterHackers.MatterControl }; } + public override void OnLoad(EventArgs args) + { + this.PageLoad?.Invoke(this); + base.OnLoad(args); + } + + public override void OnClosed(EventArgs e) + { + this.PageClose?.Invoke(); + base.OnClosed(e); + } + public void ShowWizardFinished() { var doneButton = new TextButton("Done".Localize(), theme) diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/AutoProbeFeedback.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/AutoProbeFeedback.cs index 0d3bed5b1..29081d926 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/AutoProbeFeedback.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/AutoProbeFeedback.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,16 +31,14 @@ using System; using System.Collections.Generic; using System.Linq; using MatterControl.Printing; -using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.MatterControl.PrinterCommunication; -using MatterHackers.MatterControl.PrinterCommunication.Io; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { - public class AutoProbeFeedback : PrinterSetupWizardPage + public class AutoProbeFeedback : WizardPage { private Vector3 lastReportedPosition; private List probePositions; @@ -119,13 +117,11 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling private Vector3 feedRates; private Vector3 adjustedProbePosition; - public override void PageIsBecomingActive() + public override void OnLoad(EventArgs args) { // always make sure we don't have print leveling turned on printer.Connection.AllowLeveling = false; - base.PageIsBecomingActive(); - if (printer.Settings.GetValue(SettingsKey.has_z_probe) && printer.Settings.GetValue(SettingsKey.use_z_probe) && printer.Settings.GetValue(SettingsKey.has_z_servo)) @@ -160,12 +156,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { printer.Connection.LineReceived += GetZProbeHeight; } + + base.OnLoad(args); } - public override void PageIsBecomingInactive() + public override void OnClosed(EventArgs e) { printer.Connection.LineReceived -= GetZProbeHeight; - base.PageIsBecomingInactive(); + base.OnClosed(e); } } } \ No newline at end of file diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPagelInstructions.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs similarity index 90% rename from MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPagelInstructions.cs rename to MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs index e688957e5..9cb717173 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPagelInstructions.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -28,7 +28,6 @@ either expressed or implied, of the FreeBSD Project. */ using System; -using System.Collections.Generic; using System.IO; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; @@ -38,11 +37,11 @@ using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { - public class CalibrateProbeLastPagelInstructions : PrinterSetupWizardPage + public class CalibrateProbeLastPageInstructions : WizardPage { private bool pageWasActive = false; - public CalibrateProbeLastPagelInstructions(PrinterSetupWizard context, string headerText) + public CalibrateProbeLastPageInstructions(PrinterSetupWizard context, string headerText) : base(context, headerText, "") { var calibrated = "Your Probe is now calibrated.".Localize() + "\n" @@ -63,7 +62,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling this.ShowWizardFinished(); } - public override void PageIsBecomingActive() + public override void OnLoad(EventArgs args) { if (printer.Settings.GetValue(SettingsKey.z_homes_to_max)) { @@ -72,7 +71,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling pageWasActive = true; - base.PageIsBecomingActive(); + base.OnLoad(args); } public override void OnClosed(EventArgs e) diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/FindBedHeight.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/FindBedHeight.cs index 5523df7b7..a866c5f9d 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/FindBedHeight.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/FindBedHeight.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -34,12 +34,11 @@ using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.PrinterCommunication; -using MatterHackers.MatterControl.PrinterCommunication.Io; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { - public class FindBedHeight : PrinterSetupWizardPage + public class FindBedHeight : WizardPage { private Vector3 lastReportedPosition; private List probePositions; @@ -90,17 +89,15 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling this.CreateTextField(setZHeightCoarseInstruction2)); } - public override void PageIsBecomingActive() + public override void OnLoad(EventArgs args) { + this.Parents().First().KeyDown -= TopWindowKeyDown; + probePositions[probePositionsBeingEditedIndex].position = printer.Connection.LastReportedPosition; + // always make sure we don't have print leveling turned on printer.Connection.AllowLeveling = false; NextButton.ToolTipText = string.Format("[{0}]", "Right Arrow".Localize()); - base.PageIsBecomingActive(); - } - - public override void OnLoad(EventArgs args) - { this.DialogWindow.KeyDown += TopWindowKeyDown; base.OnLoad(args); } @@ -114,15 +111,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling base.OnClosed(e); } - public override void PageIsBecomingInactive() - { - this.Parents().First().KeyDown -= TopWindowKeyDown; - probePositions[probePositionsBeingEditedIndex].position = printer.Connection.LastReportedPosition; - base.PageIsBecomingInactive(); - - NextButton.ToolTipText = ""; - } - private FlowLayoutWidget CreateZButtons() { FlowLayoutWidget zButtons = JogControls.CreateZButtons(printer, 4, out zPlusControl, out zMinusControl, new PrinterControls.XYZColors(theme), theme, true); diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetCoarseBedHeight.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetCoarseBedHeight.cs index de51f2a16..84d18dc85 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetCoarseBedHeight.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetCoarseBedHeight.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -48,10 +48,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling this.probeStartPosition = probeStartPosition; } - public override void PageIsBecomingActive() + public override void OnLoad(EventArgs args) { - base.PageIsBecomingActive(); - // make sure the probe is not deployed if (printer.Settings.GetValue(SettingsKey.has_z_probe) && printer.Settings.GetValue(SettingsKey.use_z_probe) @@ -72,18 +70,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling zPlusControl.Click += zControl_Click; zMinusControl.Click += zControl_Click; + + base.OnLoad(args); } protected void zControl_Click(object sender, EventArgs mouseEvent) { NextButton.Enabled = true; } - - public override void PageIsBecomingInactive() - { - NextButton.Enabled = true; - - base.PageIsBecomingInactive(); - } } } \ No newline at end of file diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetFineBedHeight.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetFineBedHeight.cs index 61ad81735..e19c80a63 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetFineBedHeight.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetFineBedHeight.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetUltraFineBedHeight.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetUltraFineBedHeight.cs index 5b4ad75a5..1d73fa80c 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetUltraFineBedHeight.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GetUltraFineBedHeight.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -28,16 +28,12 @@ either expressed or implied, of the FreeBSD Project. */ using System.Collections.Generic; -using MatterHackers.Agg; using MatterHackers.Localizations; -using MatterHackers.MatterControl.PrinterCommunication; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { public class GetUltraFineBedHeight : FindBedHeight { - private bool haveDrawn = false; - public GetUltraFineBedHeight(PrinterSetupWizard context, string pageDescription, List probePositions, int probePositionsBeingEditedIndex, LevelingStrings levelingStrings) : base( @@ -50,21 +46,5 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling probePositionsBeingEditedIndex) { } - - public override void OnDraw(Graphics2D graphics2D) - { - haveDrawn = true; - base.OnDraw(graphics2D); - } - - public override void PageIsBecomingInactive() - { - // TODO: Why conditional on haveDrawn? - if (haveDrawn) - { - printer.Connection.MoveRelative(PrinterConnection.Axis.Z, 2, printer.Settings.Helpers.ManualMovementSpeeds().Z); - } - base.PageIsBecomingInactive(); - } } } \ No newline at end of file diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GettingThirdPointFor2PointCalibration.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GettingThirdPointFor2PointCalibration.cs index 030e2b0d8..f26e147e6 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GettingThirdPointFor2PointCalibration.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/GettingThirdPointFor2PointCalibration.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -35,7 +35,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { - public class GettingThirdPointFor2PointCalibration : PrinterSetupWizardPage + public class GettingThirdPointFor2PointCalibration : WizardPage { protected Vector3 probeStartPosition; private ProbePosition probePosition; @@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling base.OnClosed(e); } - public override void PageIsBecomingActive() + public override void OnLoad(EventArgs args) { // first make sure there is no leftover FinishedProbe event printer.Connection.LineReceived += FinishedProbe; @@ -67,9 +67,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling printer.Connection.QueueLine("G30"); printer.Connection.LineReceived += FinishedProbe; - base.PageIsBecomingActive(); - NextButton.Enabled = false; + + base.OnLoad(args); } private void FinishedProbe(object sender, string line) diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/HomePrinterPage.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/HomePrinterPage.cs index a4d1129e2..4bfdd3f08 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/HomePrinterPage.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/HomePrinterPage.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -34,7 +34,7 @@ using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { - public class HomePrinterPage : PrinterSetupWizardPage + public class HomePrinterPage : WizardPage { private bool autoAdvance; @@ -52,7 +52,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling base.OnClosed(e); } - public override void PageIsBecomingActive() + public override void OnLoad(EventArgs args) { printer.Connection.CommunicationStateChanged += CheckHomeFinished; @@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling NextButton.Enabled = false; } - base.PageIsBecomingActive(); + base.OnLoad(args); } private void CheckHomeFinished(object sender, EventArgs e) @@ -84,12 +84,5 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } } } - - public override void PageIsBecomingInactive() - { - NextButton.Enabled = true; - - base.PageIsBecomingInactive(); - } } } \ No newline at end of file diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs index f3a9737b0..4f453bfbf 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/LastPageInstructions.cs @@ -34,12 +34,11 @@ using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.PrinterCommunication; -using MatterHackers.MatterControl.PrinterCommunication.Io; using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { - public class LastPageInstructions : PrinterSetupWizardPage + public class LastPageInstructions : WizardPage { private List probePositions; @@ -66,7 +65,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling this.ShowWizardFinished(); } - public override void PageIsBecomingActive() + public override void OnLoad(EventArgs args) { PrintLevelingData levelingData = printer.Settings.Helpers.GetPrintLevelingData(); levelingData.SampledPositions.Clear(); @@ -105,7 +104,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, theme); }; - base.PageIsBecomingActive(); + base.OnLoad(args); } } } \ No newline at end of file diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs index d01b4270c..3551b50fc 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs @@ -34,7 +34,7 @@ using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { - public class SelectMaterialPage : PrinterSetupWizardPage + public class SelectMaterialPage : WizardPage { public SelectMaterialPage(PrinterSetupWizard context, string headerText, string instructionsText, string nextButtonText, int extruderIndex, bool showLoadFilamentButton, bool showAlreadyLoadedButton) : base(context, headerText, instructionsText) @@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling }; loadFilamentButton.Click += (s, e) => { - wizardContext.ShowNextPage(this.DialogWindow); + setupWizard.ShowNextPage(this.DialogWindow); }; this.AddPageAction(loadFilamentButton); @@ -93,10 +93,5 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling this.AddPageAction(alreadyLoadedButton); } } - - public override void PageIsBecomingInactive() - { - base.PageIsBecomingInactive(); - } } } \ No newline at end of file diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WaitForTempPage.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WaitForTempPage.cs index cebe3902a..4e674ef2a 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WaitForTempPage.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WaitForTempPage.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -38,7 +38,7 @@ using MatterHackers.MatterControl.SlicerConfiguration; namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { - public class WaitForTempPage : PrinterSetupWizardPage + public class WaitForTempPage : WizardPage { private ProgressBar bedProgressBar; private TextWidget bedProgressBarText; @@ -167,13 +167,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } } - public override void OnLoad(EventArgs args) - { - // hook our parent so we can turn off the bed when we are done with leveling - this.DialogWindow.Closed += WizardWindow_Closed; - base.OnLoad(args); - } - private void WizardWindow_Closed(object sender, EventArgs e) { // Make sure when the wizard closes we turn off the bed heating @@ -181,8 +174,11 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling this.DialogWindow.Closed -= WizardWindow_Closed; } - public override void PageIsBecomingActive() + public override void OnLoad(EventArgs args) { + // hook our parent so we can turn off the bed when we are done with leveling + this.DialogWindow.Closed += WizardWindow_Closed; + bedStartingTemp = printer.Connection.ActualBedTemperature; runningInterval = UiThread.SetInterval(ShowTempChangeProgress, 1); @@ -205,21 +201,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling NextButton.Enabled = false; // if we are trying to go to a temp of 0 than just move on to next window - if(bedTargetTemp == 0 + if (bedTargetTemp == 0 && targetHotendTemps.All(i => i == 0)) { // advance to the next page UiThread.RunOnIdle(() => NextButton.InvokeClick()); } - base.PageIsBecomingActive(); - } - - public override void PageIsBecomingInactive() - { - NextButton.Enabled = true; - - base.PageIsBecomingInactive(); + base.OnLoad(args); } public override void OnClosed(EventArgs e) diff --git a/MatterControlLib/SetupWizard/DialogPage.cs b/MatterControlLib/SetupWizard/DialogPage.cs index 4016c48ed..db1a4a6bb 100644 --- a/MatterControlLib/SetupWizard/DialogPage.cs +++ b/MatterControlLib/SetupWizard/DialogPage.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -223,13 +223,5 @@ namespace MatterHackers.MatterControl { abortCancel = false; } - - public virtual void PageIsBecomingActive() - { - } - - public virtual void PageIsBecomingInactive() - { - } } } \ No newline at end of file