Convert custom WizardPage actions/events to existing ones
- Remove PageIsBecomingActive, prefer existing OnLoad - Remove PageIsBecomingInactive, prefer existing OnClosed - Rename BecomingActive action to PageLoad, used for inline defs - Rename BecomingInactive action to PageClose, used for inline defs - Fire PageLoad/PageClose from page base OnLoad/OnClosed
This commit is contained in:
parent
ec826abd39
commit
1b463ffaa7
15 changed files with 65 additions and 136 deletions
|
|
@ -104,12 +104,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
// show the trim filament message
|
||||
{
|
||||
PrinterSetupWizardPage trimFilamentPage = null;
|
||||
trimFilamentPage = new PrinterSetupWizardPage(
|
||||
this,
|
||||
"Trim Filament".Localize(),
|
||||
"")
|
||||
trimFilamentPage = new PrinterSetupWizardPage(this, "Trim Filament".Localize(), "")
|
||||
{
|
||||
BecomingActive = () =>
|
||||
PageLoad = () =>
|
||||
{
|
||||
// start heating up the extruder
|
||||
printer.Connection.SetTargetHotendTemperature(extruderIndex, printer.Settings.GetValue<double>(SettingsKey.temperature));
|
||||
|
|
@ -136,12 +133,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
RunningInterval runningGCodeCommands = null;
|
||||
PrinterSetupWizardPage insertFilamentPage = null;
|
||||
insertFilamentPage = new PrinterSetupWizardPage(
|
||||
this,
|
||||
"Insert Filament".Localize(),
|
||||
"")
|
||||
insertFilamentPage = new PrinterSetupWizardPage(this, "Insert Filament".Localize(), "")
|
||||
{
|
||||
BecomingActive = () =>
|
||||
PageLoad = () =>
|
||||
{
|
||||
var markdownText = printer.Settings.GetValue(SettingsKey.insert_filament_markdown2);
|
||||
if(extruderIndex == 1)
|
||||
|
|
@ -175,7 +169,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
},
|
||||
.1);
|
||||
},
|
||||
BecomingInactive = () =>
|
||||
PageClose = () =>
|
||||
{
|
||||
if (runningGCodeCommands != null)
|
||||
{
|
||||
|
|
@ -198,12 +192,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
RunningInterval runningGCodeCommands = null;
|
||||
PrinterSetupWizardPage loadingFilamentPage = null;
|
||||
loadingFilamentPage = new PrinterSetupWizardPage(
|
||||
this,
|
||||
"Loading Filament".Localize(),
|
||||
"")
|
||||
loadingFilamentPage = new PrinterSetupWizardPage(this, "Loading Filament".Localize(), "")
|
||||
{
|
||||
BecomingActive = () =>
|
||||
PageLoad = () =>
|
||||
{
|
||||
loadingFilamentPage.NextButton.Enabled = false;
|
||||
|
||||
|
|
@ -279,7 +270,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
},
|
||||
.1);
|
||||
},
|
||||
BecomingInactive = () =>
|
||||
PageClose = () =>
|
||||
{
|
||||
UiThread.ClearInterval(runningGCodeCommands);
|
||||
}
|
||||
|
|
@ -313,12 +304,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
RunningInterval runningGCodeCommands = null;
|
||||
PrinterSetupWizardPage runningCleanPage = null;
|
||||
runningCleanPage = new PrinterSetupWizardPage(
|
||||
this,
|
||||
"Wait For Running Clean".Localize(),
|
||||
"")
|
||||
runningCleanPage = new PrinterSetupWizardPage(this, "Wait For Running Clean".Localize(), "")
|
||||
{
|
||||
BecomingActive = () =>
|
||||
PageLoad = () =>
|
||||
{
|
||||
var markdownText = printer.Settings.GetValue(SettingsKey.running_clean_markdown2);
|
||||
if(extruderIndex == 1)
|
||||
|
|
@ -346,7 +334,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
},
|
||||
.1);
|
||||
},
|
||||
BecomingInactive = () =>
|
||||
PageClose = () =>
|
||||
{
|
||||
UiThread.ClearInterval(runningGCodeCommands);
|
||||
}
|
||||
|
|
@ -413,11 +401,11 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
}
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
ShowWizardFinished();
|
||||
this.ShowWizardFinished();
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
base.OnLoad(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,8 @@ 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
|
||||
{
|
||||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ namespace MatterHackers.MatterControl
|
|||
public TextButton NextButton { get; }
|
||||
protected PrinterConfig printer;
|
||||
|
||||
public Action BecomingActive;
|
||||
public Action BecomingInactive;
|
||||
public Action PageLoad;
|
||||
public Action PageClose;
|
||||
protected PrinterSetupWizard wizardContext;
|
||||
|
||||
public PrinterSetupWizardPage(PrinterSetupWizard wizardContext, string headerText, string instructionsText)
|
||||
|
|
@ -72,18 +72,6 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
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();
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -110,12 +110,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
RunningInterval runningGCodeCommands = null;
|
||||
PrinterSetupWizardPage unloadingFilamentPage = null;
|
||||
unloadingFilamentPage = new PrinterSetupWizardPage(
|
||||
this,
|
||||
"Unloading Filament".Localize(),
|
||||
"")
|
||||
unloadingFilamentPage = new PrinterSetupWizardPage(this, "Unloading Filament".Localize(), "")
|
||||
{
|
||||
BecomingActive = () =>
|
||||
PageLoad = () =>
|
||||
{
|
||||
unloadingFilamentPage.NextButton.Enabled = false;
|
||||
|
||||
|
|
@ -204,7 +201,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
},
|
||||
.1);
|
||||
},
|
||||
BecomingInactive = () =>
|
||||
PageClose = () =>
|
||||
{
|
||||
UiThread.ClearInterval(runningGCodeCommands);
|
||||
}
|
||||
|
|
@ -248,11 +245,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,13 +119,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<bool>(SettingsKey.has_z_probe)
|
||||
&& printer.Settings.GetValue<bool>(SettingsKey.use_z_probe)
|
||||
&& printer.Settings.GetValue<bool>(SettingsKey.has_z_servo))
|
||||
|
|
@ -160,12 +158,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
this.ShowWizardFinished();
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
if (printer.Settings.GetValue<bool>(SettingsKey.z_homes_to_max))
|
||||
{
|
||||
|
|
@ -72,7 +72,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
pageWasActive = true;
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
base.OnLoad(args);
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
|
|
|
|||
|
|
@ -90,17 +90,15 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
this.CreateTextField(setZHeightCoarseInstruction2));
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
this.Parents<SystemWindow>().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 +112,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
this.Parents<SystemWindow>().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);
|
||||
|
|
|
|||
|
|
@ -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<bool>(SettingsKey.has_z_probe)
|
||||
&& printer.Settings.GetValue<bool>(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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ 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;
|
||||
|
|
@ -57,14 +58,15 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
base.OnDraw(graphics2D);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
// TODO: Why conditional on haveDrawn?
|
||||
if (haveDrawn)
|
||||
{
|
||||
printer.Connection.MoveRelative(PrinterConnection.Axis.Z, 2, printer.Settings.Helpers.ManualMovementSpeeds().Z);
|
||||
}
|
||||
base.PageIsBecomingInactive();
|
||||
|
||||
base.OnLoad(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -66,7 +66,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 +105,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
ApplicationController.Instance.RunAnyRequiredPrinterSetup(printer, theme);
|
||||
};
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
base.OnLoad(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -93,10 +93,5 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
this.AddPageAction(alreadyLoadedButton);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -223,13 +223,5 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
abortCancel = false;
|
||||
}
|
||||
|
||||
public virtual void PageIsBecomingActive()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void PageIsBecomingInactive()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue