コード例 #1
0
        public static void ShowProbeCalibrationWizard(PrinterConfig printer, ThemeConfig theme)
        {
            // turn off print leveling
            PrintLevelingStream.AllowLeveling = false;

            var levelingContext = new ProbeCalibrationWizard(printer)
            {
                WindowTitle = $"{ApplicationController.Instance.ProductName} - " + "Probe Calibration Wizard".Localize()
            };

            var probeCalibrationWizardWindow = DialogWindow.Show(new LevelingWizardRootPage(levelingContext)
            {
                WindowTitle = levelingContext.WindowTitle
            });

            probeCalibrationWizardWindow.Closed += (s, e) =>
            {
                // If leveling was on when we started, make sure it is on when we are done.
                PrintLevelingStream.AllowLeveling = true;

                probeCalibrationWizardWindow = null;

                // make sure we raise the probe on close
                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))
                {
                    // make sure the servo is retracted
                    var servoRetract = printer.Settings.GetValue <double>(SettingsKey.z_servo_retracted_angle);
                    printer.Connection.QueueLine($"M280 P0 S{servoRetract}");
                }
            };
        }
コード例 #2
0
        protected void SetButtonStates()
        {
            // If we don't have leveling data and we need it
            bool showSetupButton = PrintLevelingData.NeedsToBeRun(printer) ||
                                   ProbeCalibrationWizard.NeedsToBeRun(printer) ||
                                   LoadFilamentWizard.NeedsToBeRun(printer);

            switch (printer.Connection.CommunicationState)
            {
            case CommunicationStates.FinishedPrint:
            case CommunicationStates.Connected:
                if (showSetupButton)
                {
                    startPrintButton.Visible  = false;
                    finishSetupButton.Visible = true;
                    finishSetupButton.Enabled = true;
                    theme.ApplyPrimaryActionStyle(finishSetupButton);
                }
                else
                {
                    startPrintButton.Visible  = true;
                    startPrintButton.Enabled  = true;
                    finishSetupButton.Visible = false;
                    theme.ApplyPrimaryActionStyle(startPrintButton);
                }
                break;

            case CommunicationStates.PrintingFromSd:
            case CommunicationStates.Printing:
            case CommunicationStates.Paused:
            default:
                if (showSetupButton)
                {
                    startPrintButton.Visible  = false;
                    finishSetupButton.Visible = true;
                    finishSetupButton.Enabled = false;
                    theme.RemovePrimaryActionStyle(finishSetupButton);
                }
                else
                {
                    startPrintButton.Visible  = true;
                    startPrintButton.Enabled  = false;
                    finishSetupButton.Visible = false;
                    theme.RemovePrimaryActionStyle(startPrintButton);
                }
                break;
            }
        }
コード例 #3
0
 public static bool SetupRequired(PrinterConfig printer)
 {
     return(LevelingValidation.NeedsToBeRun(printer) ||          // PrintLevelingWizard
            ProbeCalibrationWizard.NeedsToBeRun(printer) ||
            FilamentSetupWizard.SetupRequired(printer));
 }
コード例 #4
0
        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(() =>
                    {
                        PrintLevelingWizard.Start(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
                    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);
                    };

                    // TODO: Why is this listener conditional? If the leveling changes somehow, shouldn't we be updated the UI to reflect that?
                    // Register listeners
                    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(() =>
                        {
                            ProbeCalibrationWizard.Start(printer, theme);
                        });
                    };

                    settingsRow.BorderColor = Color.Transparent;
                    settingsRow.AddChild(runCalibrateProbeButton);
                }
            }

            // Register listeners
            printer.Connection.CommunicationStateChanged += PrinterStatusChanged;
            printer.Connection.EnableChanged             += PrinterStatusChanged;

            SetVisibleControls();
        }