private CalibrationControls(PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.printer = printer; // add in the controls for configuring auto leveling { SettingsRow settingsRow; this.AddChild(settingsRow = new SettingsRow( "Print Leveling Plane".Localize(), null, theme, AggContext.StaticData.LoadIcon("leveling_32x32.png", 16, 16, theme.InvertIcons))); // run leveling button var runWizardButton = new IconButton(AggContext.StaticData.LoadIcon("fa-cog_16.png", theme.InvertIcons), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, ToolTipText = "Print Leveling Wizard - Can be re-calculated anytime there seems to be a problem with initial layer consistency".Localize() }; runWizardButton.Click += (s, e) => { UiThread.RunOnIdle(() => { LevelingWizard.ShowPrintLevelWizard(printer, theme); }); }; settingsRow.AddChild(runWizardButton); // only show the switch if leveling can be turned off (it can't if it is required). if (!printer.Settings.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { // put in the switch var printLevelingSwitch = new RoundedToggleSwitch(theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(left: 16), Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled) }; printLevelingSwitch.CheckedStateChanged += (sender, e) => { printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; printer.Settings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) => { printLevelingSwitch.Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled); }, ref unregisterEvents); settingsRow.AddChild(printLevelingSwitch); } // add in the controls for configuring probe offset if (printer.Settings.GetValue <bool>(SettingsKey.has_z_probe) && printer.Settings.GetValue <bool>(SettingsKey.use_z_probe)) { this.AddChild(settingsRow = new SettingsRow( "Print Leveling Probe".Localize(), null, theme, AggContext.StaticData.LoadIcon("probing_32x32.png", 16, 16, theme.InvertIcons))); var runCalibrateProbeButton = new IconButton(AggContext.StaticData.LoadIcon("fa-cog_16.png", theme.InvertIcons), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, ToolTipText = "Probe Calibration Wizard - needed for initial setup - normally should remain calibrated unless there are changes to hardware.".Localize() }; runCalibrateProbeButton.Click += (s, e) => { UiThread.RunOnIdle(() => { LevelingWizard.ShowProbeCalibrationWizard(printer, theme); }); }; settingsRow.BorderColor = Color.Transparent; settingsRow.AddChild(runCalibrateProbeButton); } } printer.Connection.CommunicationStateChanged.RegisterEvent(PrinterStatusChanged, ref unregisterEvents); printer.Connection.EnableChanged.RegisterEvent(PrinterStatusChanged, ref unregisterEvents); SetVisibleControls(); }
private CalibrationControls(PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.printer = printer; // add in the controls for configuring auto leveling { SettingsRow settingsRow; this.AddChild(settingsRow = new SettingsRow( "Bed Leveling".Localize(), null, theme, AggContext.StaticData.LoadIcon("leveling_32x32.png", 16, 16, theme.InvertIcons))); // run leveling button var runWizardButton = new IconButton(AggContext.StaticData.LoadIcon("fa-cog_16.png", theme.InvertIcons), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, Name = "Run Leveling Button", ToolTipText = "Run Calibration".Localize() }; runWizardButton.Click += (s, e) => { UiThread.RunOnIdle(() => { LevelingWizard.ShowPrintLevelWizard(printer, theme); }); }; settingsRow.AddChild(runWizardButton); // only show the switch if leveling can be turned off (it can't if it is required). if (!printer.Settings.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { // put in the switch var printLevelingSwitch = new RoundedToggleSwitch(theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(left: 16), Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled) }; printLevelingSwitch.CheckedStateChanged += (sender, e) => { printer.Settings.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; void Settings_PrintLevelingEnabledChanged(object sender, EventArgs e) { printLevelingSwitch.Checked = printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled); } printer.Settings.PrintLevelingEnabledChanged += Settings_PrintLevelingEnabledChanged; this.Closed += (s, e) => { printer.Settings.PrintLevelingEnabledChanged -= Settings_PrintLevelingEnabledChanged; }; settingsRow.AddChild(printLevelingSwitch); } // add in the controls for configuring probe offset if (printer.Settings.GetValue <bool>(SettingsKey.has_z_probe) && printer.Settings.GetValue <bool>(SettingsKey.use_z_probe)) { this.AddChild(settingsRow = new SettingsRow( "Calibrate Probe Offset".Localize(), null, theme, AggContext.StaticData.LoadIcon("probing_32x32.png", 16, 16, theme.InvertIcons))); var runCalibrateProbeButton = new IconButton(AggContext.StaticData.LoadIcon("fa-cog_16.png", theme.InvertIcons), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, ToolTipText = "Run Calibration".Localize() }; runCalibrateProbeButton.Click += (s, e) => { UiThread.RunOnIdle(() => { LevelingWizard.ShowProbeCalibrationWizard(printer, theme); }); }; settingsRow.BorderColor = Color.Transparent; settingsRow.AddChild(runCalibrateProbeButton); } } printer.Connection.CommunicationStateChanged.RegisterEvent(PrinterStatusChanged, ref unregisterEvents); printer.Connection.EnableChanged.RegisterEvent(PrinterStatusChanged, ref unregisterEvents); SetVisibleControls(); }