Add buttons to calibration page to make it easier to run them

issue: MatterHackers/MCCentral#5998
Have 'Do It' button on each calibration type
This commit is contained in:
Lars Brubaker 2020-08-13 11:15:30 -07:00
parent 87c3aeab2e
commit d8375572ba
3 changed files with 45 additions and 33 deletions

View file

@ -43,6 +43,8 @@ namespace MatterHackers.MatterControl
bool AutoAdvance { get; set; }
StagedSetupWindow StagedSetupWindow { get; set; }
Func<DialogPage> HomePageGenerator { get; }
}
}

View file

@ -27,9 +27,6 @@ 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 System.Linq;
using MatterHackers.Agg;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
@ -40,11 +37,15 @@ using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.MatterControl.PrinterControls;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.VectorMath;
using System;
using System.Collections.Generic;
using System.Linq;
namespace MatterHackers.MatterControl
{
public class PrinterCalibrationWizard : IStagedSetupWizard
{
private PrinterConfig printer;
private RoundedToggleSwitch printLevelingSwitch;
public PrinterCalibrationWizard(PrinterConfig printer, ThemeConfig theme)
@ -105,8 +106,7 @@ namespace MatterHackers.MatterControl
MinimumSize = new Vector2(125, 0)
});
column.AddChild(new HorizontalSpacer());
column.AddChild(new TextButton("Run Z Calibration".Localize(), theme));
AddRunStageButton("Run Z Calibration".Localize(), theme, stage, column);
widget = column;
}
@ -124,7 +124,6 @@ namespace MatterHackers.MatterControl
var levelingSolution = printer.Settings.GetValue(SettingsKey.print_leveling_solution);
column.AddChild(
new ValueTag(
"Leveling Solution".Localize(),
@ -204,11 +203,7 @@ namespace MatterHackers.MatterControl
};
leftToRight.AddChild(probeWidget);
leftToRight.AddChild(new HorizontalSpacer());
leftToRight.AddChild(new TextButton("Run Print Leveling".Localize(), theme)
{
VAnchor = VAnchor.Bottom
});
AddRunStageButton("Run Print Leveling".Localize(), theme, stage, leftToRight);
}
else if (!printer.Settings.GetValue<bool>(SettingsKey.print_leveling_required_to_print))
{
@ -260,11 +255,7 @@ namespace MatterHackers.MatterControl
MinimumSize = new Vector2(125, 0)
});
row.AddChild(new HorizontalSpacer());
row.AddChild(new TextButton("Run Nozzle Alignment".Localize(), theme)
{
VAnchor = VAnchor.Bottom
});
AddRunStageButton("Run Nozzle Alignment".Localize(), theme, stage, row);
widget = row;
}
@ -299,36 +290,38 @@ namespace MatterHackers.MatterControl
};
}
private void Settings_PrintLevelingEnabledChanged(object sender, EventArgs e)
private void AddRunStageButton(string title, ThemeConfig theme, ISetupWizard stage, FlowLayoutWidget leftToRight)
{
if (printLevelingSwitch != null)
leftToRight.AddChild(new HorizontalSpacer());
var runStage = leftToRight.AddChild(new TextButton(title, theme)
{
printLevelingSwitch.Checked = printer.Settings.GetValue<bool>(SettingsKey.print_leveling_enabled);
}
}
VAnchor = VAnchor.Bottom
});
private static FlowLayoutWidget CreateColumn(ThemeConfig theme)
{
return new FlowLayoutWidget(FlowDirection.TopToBottom)
runStage.Click += (s, e) =>
{
Margin = new BorderDouble(theme.DefaultContainerPadding, theme.DefaultContainerPadding, theme.DefaultContainerPadding, 4)
// Only allow leftnav when not running SetupWizard
if (StagedSetupWindow?.ActiveStage == null)
{
StagedSetupWindow.ActiveStage = stage;
}
};
}
public bool AutoAdvance { get; set; }
public string Title { get; } = "Printer Calibration".Localize();
public Vector2 WindowSize { get; } = new Vector2(1200, 700);
public IEnumerable<ISetupWizard> Stages { get; }
private PrinterConfig printer;
public Func<DialogPage> HomePageGenerator { get; }
public bool ReturnedToHomePage { get; set; } = false;
public StagedSetupWindow StagedSetupWindow { get; set; }
public IEnumerable<ISetupWizard> Stages { get; }
public string Title { get; } = "Printer Calibration".Localize();
public Vector2 WindowSize { get; } = new Vector2(1200, 700);
public static bool SetupRequired(PrinterConfig printer, bool requiresLoadedFilament)
{
return printer == null
@ -338,5 +331,21 @@ namespace MatterHackers.MatterControl
|| (requiresLoadedFilament && LoadFilamentWizard.NeedsToBeRun1(printer))
|| XyCalibrationWizard.NeedsToBeRun(printer);
}
private static FlowLayoutWidget CreateColumn(ThemeConfig theme)
{
return new FlowLayoutWidget(FlowDirection.TopToBottom)
{
Margin = new BorderDouble(theme.DefaultContainerPadding, theme.DefaultContainerPadding, theme.DefaultContainerPadding, 4)
};
}
private void Settings_PrintLevelingEnabledChanged(object sender, EventArgs e)
{
if (printLevelingSwitch != null)
{
printLevelingSwitch.Checked = printer.Settings.GetValue<bool>(SettingsKey.print_leveling_enabled);
}
}
}
}

View file

@ -93,6 +93,7 @@ namespace MatterHackers.MatterControl
var instanceIndex = 0;
var wizardWindow = new StagedSetupWindow(setupWizard);
setupWizard.StagedSetupWindow = wizardWindow;
wizardWindow.Closed += (s, e) => allWindows.Remove((type, instanceIndex));
allWindows[(type, instanceIndex)] = wizardWindow;