Example #1
0
        private void SaveGCodeToSDCard()
        {
            PrinterObject selectedPrinter1 = m_oSpoolerConnection.SelectedPrinter;

            if (selectedPrinter1 == null || !selectedPrinter1.IsConnected())
            {
                return;
            }

            var sourceFileName = OpenModelFileDialog.RunOpenModelDialog(OpenModelFileDialog.FileType.GCode);

            if (string.IsNullOrEmpty(sourceFileName))
            {
                return;
            }

            var str = Path.Combine(Paths.PublicDataFolder, "Working", "m3doutput.gcode");

            if (sourceFileName != str)
            {
                try
                {
                    File.Copy(sourceFileName, str, true);
                }
                catch (Exception ex)
                {
                    m_oMessagebox.AddMessageToQueue("Unable to send gcode file. " + ex.Message);
                    return;
                }
            }
            var UserJob = new JobParams(str, "User Job", "", selectedPrinter1.GetCurrentFilament().filament_type, 0.0f, 0.0f);

            UserJob.options.autostart_ignorewarnings = true;
            UserJob.options.turn_on_fan_before_print = true;
            UserJob.preprocessor         = selectedPrinter1.MyFilamentProfile.preprocessor;
            UserJob.filament_temperature = selectedPrinter1.MyFilamentProfile.Temperature;
            UserJob.jobMode = JobParams.Mode.SavingToSDCard;
            PrinterObject selectedPrinter2 = m_oSpoolerConnection.SelectedPrinter;

            if (selectedPrinter2 == null || !selectedPrinter2.IsConnected())
            {
                m_oMessagebox.AddMessageToQueue("Printer Disconnected", PopupMessageBox.MessageBoxButtons.OK);
            }
            else if (selectedPrinter2.PrinterState != PrinterObject.State.IsPrinting)
            {
                selectedPrinter2.AutoLockAndPrint(UserJob);
            }
            else
            {
                m_oMessagebox.AddMessageToQueue("Printer Busy", PopupMessageBox.MessageBoxButtons.OK);
            }
        }