private void buttonOK_Click(object sender, EventArgs e) { var flag = false; var num1 = float.Parse(textBoxFilamentTemp.Text); FilamentConstants.Temperature.MaxMin maxMin = FilamentConstants.Temperature.MaxMinForFilamentType(options.type); if (num1 >= (double)maxMin.Min && num1 <= (double)maxMin.Max) { flag = true; } if (flag) { options.use_preprocessors = checkBoxUsePreprocessors.Checked; options.calibrateZ = checkBoxCalibrate.Checked; options.temperature = Convert.ToInt32(textBoxFilamentTemp.Text); ok = true; Close(); } else { var num2 = (int)MessageBox.Show("Please enter a temperature from " + maxMin.Min + " to " + maxMin.Max, "Temperature Invalid"); ok = false; } switch (comboBoxJobMode.SelectedIndex) { case 1: options.jobMode = JobParams.Mode.SavingToSDCard; break; case 2: options.jobMode = JobParams.Mode.SavingToSDCardAutoStartPrint; break; default: options.jobMode = JobParams.Mode.DirectPrinting; break; } }
public void CustomTempButtonCallback(ButtonWidget button) { switch (button.ID) { case 1005: Enabled = false; addfilament_frame.Visible = true; addfilament_frame.Enabled = true; host.GlobalChildDialog += addfilament_frame; prevSelectedProfile = -1; break; case 1006: if (filamentprofile_list.Items.Count >= 0 && filamentprofile_list.Selected < filamentprofile_list.Items.Count) { var obj = filamentprofile_list.Items[filamentprofile_list.Selected]; if (obj is FilamentProfilePage.FilamentOptions) { if (spooler_connection.FilamentSpoolLoaded(((FilamentProfilePage.FilamentOptions)obj).Key, new FilamentProfile.CustomOptions()) && settingsManager.ShowAllWarnings) { messagebox.AddMessageToQueue("Warning: Filament profile in use. Deleting custom profile will not reset temperature to default..", PopupMessageBox.MessageBoxButtons.OKCANCEL, new PopupMessageBox.OnUserSelectionDel(OnUserSelection), spooler_connection.SelectedPrinter); } else { RemoveFilamentProfile(); } } } prevSelectedProfile = -1; break; case 1007: messagebox.AddMessageToQueue(new SpoolerMessage(MessageType.UserDefined, "Warning. Changing the temperature can cause permanent damage to your printer. This will change the temperature for all filaments of this type and color.")); temperature_edit.Enabled = true; TemperatureEditButton.Visible = false; TemperatureSaveButton.Visible = true; TemperatureSaveButton.Enabled = true; TemperatureResetButton.Enabled = false; break; case 1008: try { if (filamentprofile_list.Selected >= 0 && filamentprofile_list.Selected < filamentprofile_list.Items.Count) { var obj = filamentprofile_list.Items[filamentprofile_list.Selected]; if (obj is FilamentProfilePage.FilamentOptions filamentOptions) { var num = float.Parse(temperature_edit.Text); FilamentConstants.Temperature.MaxMin maxMin = FilamentConstants.Temperature.MaxMinForFilamentType(filamentOptions.Key.type); if (num >= (double)maxMin.Min && num <= (double)maxMin.Max) { UpdateTemperature((int)num); temperature_edit.Enabled = false; TemperatureEditButton.Visible = true; TemperatureSaveButton.Visible = false; TemperatureResetButton.Visible = true; } else { messagebox.AddMessageToQueue(new SpoolerMessage(MessageType.UserDefined, "Please enter a temperature from " + maxMin.Min + " to " + maxMin.Max)); } } } UpdateProfileList(filamentprofile_list.Selected); break; } catch (Exception ex) { messagebox.AddMessageToQueue(new SpoolerMessage(MessageType.UserDefined, "Sorry. The temperature you entered is invalid.")); break; } case 1010: var temperature = FilamentConstants.Temperature.Default(spooler_connection.SelectedPrinter.GetCurrentFilament().filament_type); UpdateTemperature(temperature); temperature_edit.Text = temperature.ToString(); break; } }
public bool ResolveToEncodedFilament(string toResolve, out Filament filament, out int temperature) { filament = null; temperature = -1; if (toResolve.Count <char>() != 3) { return(false); } var nullable1 = new FilamentSpool.TypeEnum?(); var nullable2 = new FilamentConstants.Branding?(); var nullable3 = new FilamentConstants.ColorsEnum?(); var num = 0; switch (char.ToLower(toResolve[0])) { case 'e': nullable1 = new FilamentSpool.TypeEnum?(FilamentSpool.TypeEnum.PLA); nullable2 = new FilamentConstants.Branding?(FilamentConstants.Branding.SolidInk); break; case 'k': nullable1 = new FilamentSpool.TypeEnum?(FilamentSpool.TypeEnum.ABS_R); nullable2 = new FilamentConstants.Branding?(FilamentConstants.Branding.Ink); break; case 'q': nullable1 = new FilamentSpool.TypeEnum?(FilamentSpool.TypeEnum.ABS); nullable2 = new FilamentConstants.Branding?(FilamentConstants.Branding.ExpertInk); break; case 'v': nullable1 = new FilamentSpool.TypeEnum?(FilamentSpool.TypeEnum.TGH); nullable2 = new FilamentConstants.Branding?(FilamentConstants.Branding.ToughInk); break; case 'x': nullable1 = new FilamentSpool.TypeEnum?(FilamentSpool.TypeEnum.PLA); nullable2 = new FilamentConstants.Branding?(FilamentConstants.Branding.Ink); break; } if (char.IsLetter(toResolve[1]) && nullable1.HasValue) { num = (char.ToLower(toResolve[1]) - 97) * 5 + 170; FilamentConstants.Temperature.MaxMin maxMin = FilamentConstants.Temperature.MaxMinForFilamentType(nullable1.Value); if (num < (double)maxMin.Min) { num = (int)maxMin.Min; } if (num > (double)maxMin.Max) { num = (int)maxMin.Max; } } if (char.IsLetter(toResolve[2])) { switch (char.ToLower(toResolve[2])) { case 's': case 't': case 'u': case 'v': nullable3 = new FilamentConstants.ColorsEnum?(FilamentConstants.ColorsEnum.Other); break; } } if (!nullable1.HasValue || !nullable2.HasValue || (!nullable3.HasValue || num == 0)) { return(false); } filament = new Filament(nullable1.Value, nullable3.Value, toResolve, nullable2.Value); temperature = num; return(true); }