Example #1
0
        public void MyButtonCallback(ButtonWidget button)
        {
            PrinterObject printer = m_oSpoolerConnection.SelectedPrinter;

            switch (button.ID)
            {
            case 2:
                if (printer == null || printer.Info.InBootloaderMode)
                {
                    break;
                }

                var num1 = (int)printer.AcquireLock(ar =>
                {
                    if (ar.CallResult == CommandResult.Failed_PrinterAlreadyLocked)
                    {
                        m_oMessagebox.AddMessageToQueue("Unable to calibrate the printer because it is being used by another process.");
                    }
                    else if (ar.CallResult != CommandResult.Success_LockAcquired)
                    {
                        m_oMessagebox.AddMessageToQueue("There was a problem sending data to the printer. Please try again");
                    }
                    else
                    {
                        printer.CalibrateBed(new M3D.Spooling.Client.AsyncCallback(ReleaseAfterOperation), (object)printer, PrinterObject.CalibrationType.CalibrateQuick_G30);
                    }
                }, printer);
                break;

            case 3:
                if (printer == null || printer.Info.InBootloaderMode)
                {
                    break;
                }

                var num2 = (int)printer.AcquireLock(ar =>
                {
                    if (ar.CallResult == CommandResult.Failed_PrinterAlreadyLocked)
                    {
                        m_oMessagebox.AddMessageToQueue("Unable to calibrate the printer because it is being used by another process.");
                    }
                    else if (ar.CallResult != CommandResult.Success_LockAcquired)
                    {
                        m_oMessagebox.AddMessageToQueue("There was a problem sending data to the printer. Please try again");
                    }
                    else
                    {
                        printer.CalibrateBed(new M3D.Spooling.Client.AsyncCallback(ReleaseAfterOperation), (object)printer, PrinterObject.CalibrationType.CalibrateFull_G32);
                    }
                }, printer);
                break;

            case 4:
                var fileName = Paths.DebugLogPath(DateTime.Now.Ticks / 10000L);
                Form1.debugLogger.Print(fileName);
                break;

            case 5:
                if (printer.GetCurrentFilament() == null)
                {
                    m_oMessagebox.AddMessageToQueue("Please insert filament into your printer.");
                    break;
                }
                if (!printer.Info.extruder.Z_Valid || !printer.Info.calibration.Calibration_Valid)
                {
                    m_oMessagebox.AddMessageToQueue(Locale.GlobalLocale.T("T_PrinterViewError_NotCalibrated"));
                }

                ShowBusyIfPrinterIsWorking(true);
                var num3 = (int)printer.AcquireLock(new M3D.Spooling.Client.AsyncCallback(DoTestBorderPrintOnLock), printer);
                break;

            case 6:
                ShowGantryCalibrationG32Page();
                break;

            case 10:
                OnApplyBacklashSettings();
                break;

            case 11:
                if (printer == null || printer.Info.InBootloaderMode)
                {
                    break;
                }

                m_oebwBacklashSpeed_edit.Text = printer.MyPrinterProfile.SpeedLimitConstants.DefaultBacklashSpeed.ToString();
                break;

            case 12:
                if (printer == null || printer.Info.InBootloaderMode)
                {
                    break;
                }

                m_oebwBacklashSpeed_edit.Text = printer.MyPrinterProfile.SpeedLimitConstants.FastestPossible.ToString();
                break;

            case 13:
                ShowBasicCalibrationPage(printer);
                break;

            case 16:
                OnApplyCalibrationOffset();
                break;
            }
        }