private MeasuredIon ValidateCustomIon(string name) { var helper = new MessageBoxHelper(this); string formula = _formulaBox.Formula.ToString(LocalizationHelper.CurrentCulture); var charge = ValidateCharge(); if (!charge.HasValue) { return null; } double monoMass; double avgMass; if (!string.IsNullOrEmpty(formula)) { // Mass is specified by chemical formula try { monoMass = SequenceMassCalc.ParseModMass(BioMassCalc.MONOISOTOPIC, formula); avgMass = SequenceMassCalc.ParseModMass(BioMassCalc.AVERAGE, formula); } catch (ArgumentException x) { helper.ShowTextBoxError(_formulaBox, x.Message); return null; } } else if (_formulaBox.MonoMass != null || _formulaBox.AverageMass != null) { // Mass is specified by combination of mz and charge formula = null; if (!_formulaBox.ValidateMonoText(helper)) return null; if (!_formulaBox.ValidateAverageText(helper)) return null; _formulaBox.Charge = charge; // This provokes calculation of mass from displayed mz values monoMass = _formulaBox.MonoMass.Value; avgMass = _formulaBox.AverageMass.Value; } else { // User hasn't fully specified either way _formulaBox.ShowTextBoxErrorFormula(helper, Resources.EditMeasuredIonDlg_OkDialog_Please_specify_a_formula_or_constant_masses); return null; } if (MeasuredIon.MIN_REPORTER_MASS > monoMass || MeasuredIon.MIN_REPORTER_MASS > avgMass) { _formulaBox.ShowTextBoxErrorMonoMass(helper, string.Format(Resources.EditMeasuredIonDlg_OkDialog_Reporter_ion_masses_must_be_less_than_or_equal_to__0__, MeasuredIon.MAX_REPORTER_MASS)); return null; } if (monoMass > MeasuredIon.MAX_REPORTER_MASS || avgMass > MeasuredIon.MAX_REPORTER_MASS) { _formulaBox.ShowTextBoxErrorAverageMass(helper, string.Format(Resources.EditMeasuredIonDlg_OkDialog_Reporter_ion_masses_must_be_less_than_or_equal_to__0__, MeasuredIon.MAX_REPORTER_MASS)); return null; } return new MeasuredIon(name, formula, monoMass, avgMass, charge.Value); }
public void OkDialog() { var helper = new MessageBoxHelper(this); var charge = 0; if (textCharge.Visible && !helper.ValidateSignedNumberTextBox(textCharge, _minCharge, _maxCharge, out charge)) return; if (RetentionTimeWindow.HasValue && !RetentionTime.HasValue) { helper.ShowTextBoxError(textRetentionTimeWindow, Resources.Peptide_ExplicitRetentionTimeWindow_Explicit_retention_time_window_requires_an_explicit_retention_time_value_); return; } Charge = charge; // Note: order matters here, this settor indirectly updates _formulaBox.MonoMass when formula is empty if (string.IsNullOrEmpty(_formulaBox.Formula)) { // Can the text fields be understood as mz? if (!_formulaBox.ValidateAverageText(helper)) return; if (!_formulaBox.ValidateMonoText(helper)) return; } var formula = _formulaBox.Formula; var monoMass = _formulaBox.MonoMass ?? 0; var averageMass = _formulaBox.AverageMass ?? 0; if (monoMass < CustomIon.MIN_MASS || averageMass < CustomIon.MIN_MASS) { _formulaBox.ShowTextBoxErrorFormula(helper, string.Format(Resources.EditCustomMoleculeDlg_OkDialog_Custom_molecules_must_have_a_mass_greater_than_or_equal_to__0__, CustomIon.MIN_MASS)); return; } if (monoMass > CustomIon.MAX_MASS || averageMass > CustomIon.MAX_MASS) { _formulaBox.ShowTextBoxErrorFormula(helper, string.Format(Resources.EditCustomMoleculeDlg_OkDialog_Custom_molecules_must_have_a_mass_less_than_or_equal_to__0__, CustomIon.MAX_MASS)); return; } if ((_transitionSettings != null) && (!_transitionSettings.IsMeasurablePrecursor(BioMassCalc.CalculateIonMz(monoMass, charge)) || !_transitionSettings.IsMeasurablePrecursor(BioMassCalc.CalculateIonMz(averageMass, charge)))) { _formulaBox.ShowTextBoxErrorFormula(helper, Resources.SkylineWindow_AddMolecule_The_precursor_m_z_for_this_molecule_is_out_of_range_for_your_instrument_settings_); return; } if (!string.IsNullOrEmpty(_formulaBox.Formula)) { try { ResultCustomIon = new DocNodeCustomIon(formula, textName.Text); } catch (InvalidDataException x) { _formulaBox.ShowTextBoxErrorFormula(helper, x.Message); return; } } else { ResultCustomIon = new DocNodeCustomIon(monoMass, averageMass, textName.Text); } // Did user change the list of heavy labels? if (_driverLabelType != null) { PeptideModifications modifications = new PeptideModifications( _peptideSettings.Modifications.StaticModifications, _peptideSettings.Modifications.MaxVariableMods, _peptideSettings.Modifications.MaxNeutralLosses, _driverLabelType.GetHeavyModifications(), // This is the only thing the user may have altered _peptideSettings.Modifications.InternalStandardTypes); var settings = _peptideSettings.ChangeModifications(modifications); // Only update if anything changed if (!Equals(settings, _peptideSettings)) { SrmSettings newSettings = _parent.DocumentUI.Settings.ChangePeptideSettings(settings); if (!_parent.ChangeSettings(newSettings, true)) { return; } _peptideSettings = newSettings.PeptideSettings; } } // See if this combination of charge and label would conflict with any existing transition groups if (_existingIds != null && _existingIds.Any(t => { var transitionGroup = t as TransitionGroup; return transitionGroup != null && Equals(transitionGroup.LabelType, IsotopeLabelType) && Equals(transitionGroup.PrecursorCharge, Charge) && !ReferenceEquals(t, _initialId); })) { helper.ShowTextBoxError(textName, Resources.EditCustomMoleculeDlg_OkDialog_A_precursor_with_that_charge_and_label_type_already_exists_, textName.Text); return; } // See if this would conflict with any existing transitions if (_existingIds != null && (_existingIds.Any(t => { var transition = t as Transition; return transition != null && ((transition.Charge == Charge) && Equals(transition.CustomIon, ResultCustomIon)) && !ReferenceEquals(t, _initialId); }))) { helper.ShowTextBoxError(textName, Resources.EditCustomMoleculeDlg_OkDialog_A_similar_transition_already_exists_, textName.Text); return; } DialogResult = DialogResult.OK; }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(textName, out name)) return; if (_existing.Contains(exc => !ReferenceEquals(_exclusion, exc) && Equals(name, exc.Name))) { helper.ShowTextBoxError(textName, Resources.EditExclusionDlg_OkDialog_The_peptide_exclusion__0__already_exists, name); return; } string exRegex = textExclusionRegex.Text.Trim(); if (string.IsNullOrEmpty(exRegex)) { helper.ShowTextBoxError(textExclusionRegex, Resources.EditExclusionDlg_OkDialog__0__must_contain_a_valid_regular_expression_); return; } try { // ReSharper disable ObjectCreationAsStatement new Regex(exRegex); // ReSharper restore ObjectCreationAsStatement } catch (Exception) { helper.ShowTextBoxError(textExclusionRegex, Resources.EditExclusionDlg_OkDialog_The_text__0__is_not_a_valid_regular_expression, exRegex); return; } bool includeMatch = radioNotMatching.Checked; bool matchMod = radioModSequence.Checked; PeptideExcludeRegex exclusion = new PeptideExcludeRegex(name, exRegex, includeMatch, matchMod); _exclusion = exclusion; DialogResult = DialogResult.OK; }
private static bool ValidateAATextBox(MessageBoxHelper helper, TextBox control, bool allowEmpty, out string aaText) { aaText = control.Text.Trim().ToUpperInvariant(); if (aaText.Length == 0) { if (!allowEmpty) { helper.ShowTextBoxError(control, Resources.EditMeasuredIonDlg_ValidateAATextBox__0__must_contain_at_least_one_amino_acid); return false; } } else { StringBuilder aaBuilder = new StringBuilder(); HashSet<char> setAA = new HashSet<char>(); foreach (char c in aaText) { if (!AminoAcid.IsAA(c)) { helper.ShowTextBoxError(control, Resources.EditMeasuredIonDlg_ValidateAATextBox_The_character__0__is_not_a_valid_amino_acid, c); return false; } // Silently strip duplicates. if (!setAA.Contains(c)) { aaBuilder.Append(c); setAA.Add(c); } } aaText = aaBuilder.ToString(); } return true; }
/// <summary> /// This function will validate all the settings required for exporting a method, /// placing the values on the ExportDlgProperties _exportProperties. It returns /// boolean whether or not it succeeded. It can show MessageBoxes or not based /// on a parameter. /// </summary> public bool ValidateSettings(MessageBoxHelper helper) { // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if (radioSingle.Checked) _exportProperties.ExportStrategy = ExportStrategy.Single; else if (radioProtein.Checked) _exportProperties.ExportStrategy = ExportStrategy.Protein; else _exportProperties.ExportStrategy = ExportStrategy.Buckets; // ReSharper restore ConvertIfStatementToConditionalTernaryExpression _exportProperties.IgnoreProteins = cbIgnoreProteins.Checked; _exportProperties.FullScans = _document.Settings.TransitionSettings.FullScan.IsEnabledMsMs; _exportProperties.AddEnergyRamp = panelThermoColumns.Visible && cbEnergyRamp.Checked; _exportProperties.UseSlens = cbSlens.Checked; _exportProperties.AddTriggerReference = panelThermoColumns.Visible && cbTriggerRefColumns.Checked; _exportProperties.ExportMultiQuant = panelAbSciexTOF.Visible && cbExportMultiQuant.Checked; _exportProperties.RetentionStartAndEnd = panelThermoRt.Visible && cbUseStartAndEndRts.Checked; _exportProperties.ExportEdcMass = panelWaters.Visible && cbExportEdcMass.Checked; _exportProperties.Ms1Scan = _document.Settings.TransitionSettings.FullScan.IsEnabledMs && _document.Settings.TransitionSettings.FullScan.IsEnabledMsMs; _exportProperties.InclusionList = IsInclusionListMethod; _exportProperties.MsAnalyzer = TransitionFullScan.MassAnalyzerToString( _document.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer); _exportProperties.MsMsAnalyzer = TransitionFullScan.MassAnalyzerToString( _document.Settings.TransitionSettings.FullScan.ProductMassAnalyzer); _exportProperties.OptimizeType = comboOptimizing.SelectedItem == null ? ExportOptimize.NONE : comboOptimizing.SelectedItem.ToString(); var prediction = _document.Settings.TransitionSettings.Prediction; if (Equals(_exportProperties.OptimizeType, ExportOptimize.CE)) { var regression = prediction.CollisionEnergy; _exportProperties.OptimizeStepSize = regression.StepSize; _exportProperties.OptimizeStepCount = regression.StepCount; } else if (Equals(_exportProperties.OptimizeType, ExportOptimize.DP)) { var regression = prediction.DeclusteringPotential; _exportProperties.OptimizeStepSize = regression.StepSize; _exportProperties.OptimizeStepCount = regression.StepCount; } else if (Equals(_exportProperties.OptimizeType, ExportOptimize.COV)) { string tuning = comboTuning.SelectedItem.ToString(); _exportProperties.OptimizeType = tuning; var compensationVoltage = prediction.CompensationVoltage; var tuneLevel = CompensationVoltageParameters.GetTuneLevel(tuning); if (helper.ShowMessages) { if (tuneLevel.Equals(CompensationVoltageParameters.Tuning.medium)) { var missing = _document.GetMissingCompensationVoltages(CompensationVoltageParameters.Tuning.rough).ToList(); if (missing.Any()) { missing.Insert(0, Resources.ExportMethodDlg_ValidateSettings_Cannot_export_medium_tune_transition_list__The_following_precursors_are_missing_rough_tune_results_); helper.ShowTextBoxError(comboTuning, TextUtil.LineSeparate(missing)); return false; } } else if (tuneLevel.Equals(CompensationVoltageParameters.Tuning.fine)) { var missing = _document.GetMissingCompensationVoltages(CompensationVoltageParameters.Tuning.medium).ToList(); if (missing.Any()) { missing.Insert(0, Resources.ExportMethodDlg_ValidateSettings_Cannot_export_fine_tune_transition_list__The_following_precursors_are_missing_medium_tune_results_); helper.ShowTextBoxError(comboTuning, TextUtil.LineSeparate(missing)); return false; } } } _exportProperties.OptimizeStepSize = compensationVoltage.GetStepSize(tuneLevel); _exportProperties.OptimizeStepCount = compensationVoltage.GetStepCount(tuneLevel); _exportProperties.PrimaryTransitionCount = 1; } else { _exportProperties.OptimizeType = null; _exportProperties.OptimizeStepSize = _exportProperties.OptimizeStepCount = _exportProperties.PrimaryTransitionCount = 0; } string maxTran = textMaxTransitions.Text; if (string.IsNullOrEmpty(maxTran)) { if (_exportProperties.ExportStrategy == ExportStrategy.Buckets) { helper.ShowTextBoxError(textMaxTransitions, Resources.ExportMethodDlg_ValidateSettings__0__must_contain_a_value); return false; } _exportProperties.MaxTransitions = null; } int maxVal; // CONSIDER: Better error message when instrument limitation encountered? int maxInstrumentTrans = _document.Settings.TransitionSettings.Instrument.MaxTransitions ?? TransitionInstrument.MAX_TRANSITION_MAX; int minTrans = IsFullScanInstrument ? AbstractMassListExporter.MAX_TRANS_PER_INJ_MIN : MethodExporter.MAX_TRANS_PER_INJ_MIN_TLTQ; if (_exportProperties.ExportStrategy != ExportStrategy.Buckets) maxVal = maxInstrumentTrans; else if (!helper.ValidateNumberTextBox(textMaxTransitions, minTrans, maxInstrumentTrans, out maxVal)) return false; // Make sure all the transitions of all precursors can fit into a single document, // but not if this is a full-scan instrument, because then the maximum is refering // to precursors and not transitions. if (!IsFullScanInstrument && !ValidatePrecursorFit(_document, maxVal, helper.ShowMessages)) return false; _exportProperties.MaxTransitions = maxVal; _exportProperties.MethodType = ExportMethodTypeExtension.GetEnum(comboTargetType.SelectedItem.ToString()); if (textPrimaryCount.Visible) { int primaryCount; if (!helper.ValidateNumberTextBox(textPrimaryCount, AbstractMassListExporter.PRIMARY_COUNT_MIN, AbstractMassListExporter.PRIMARY_COUNT_MAX, out primaryCount)) return false; _exportProperties.PrimaryTransitionCount = primaryCount; } if (textDwellTime.Visible) { int dwellTime; if (!helper.ValidateNumberTextBox(textDwellTime, AbstractMassListExporter.DWELL_TIME_MIN, AbstractMassListExporter.DWELL_TIME_MAX, out dwellTime)) return false; _exportProperties.DwellTime = dwellTime; } if (textRunLength.Visible) { double runLength; if (!helper.ValidateDecimalTextBox(textRunLength, AbstractMassListExporter.RUN_LENGTH_MIN, AbstractMassListExporter.RUN_LENGTH_MAX, out runLength)) return false; _exportProperties.RunLength = runLength; } // If export method type is scheduled, and allows multiple scheduling options // ask the user which to use. if (_exportProperties.MethodType != ExportMethodType.Standard && HasMultipleSchedulingOptions(_document)) { if (!helper.ShowMessages) { // CONSIDER: Kind of a hack, but pick some reasonable defaults. The user // may decide otherwise later, but this is the best we can do // without asking. if (!_document.Settings.HasResults || Settings.Default.ScheduleAvergeRT) SchedulingAlgorithm = ExportSchedulingAlgorithm.Average; else { SchedulingAlgorithm = ExportSchedulingAlgorithm.Single; SchedulingReplicateNum = _document.Settings.MeasuredResults.Chromatograms.Count - 1; } } else { using (var schedulingOptionsDlg = new SchedulingOptionsDlg(_document, i => _exportProperties.MethodType != ExportMethodType.Triggered || CanTriggerReplicate(i))) { if (schedulingOptionsDlg.ShowDialog(this) != DialogResult.OK) return false; SchedulingAlgorithm = schedulingOptionsDlg.Algorithm; SchedulingReplicateNum = schedulingOptionsDlg.ReplicateNum; } } } if (ExportOptimize.CompensationVoltageTuneTypes.Contains(_exportProperties.OptimizeType)) { var precursorsMissingRanks = _document.GetPrecursorsWithoutTopRank(0, _exportProperties.SchedulingReplicateNum).ToArray(); if (precursorsMissingRanks.Any()) { if (helper.ShowMessages) { if (DialogResult.Cancel == MultiButtonMsgDlg.Show(this, TextUtil.LineSeparate( Resources.ExportMethodDlg_OkDialog_Compensation_voltage_optimization_should_be_run_on_one_transition_per_peptide__and_the_best_transition_cannot_be_determined_for_the_following_precursors_, TextUtil.LineSeparate(precursorsMissingRanks), Resources.ExportMethodDlg_OkDialog_Provide_transition_ranking_information_through_imported_results__a_spectral_library__or_choose_only_one_target_transition_per_precursor_), Resources.ExportMethodDlg_OkDialog_OK)) { return false; } } _exportProperties.PrimaryTransitionCount = 0; } } return true; }
public void OkDialog() { var messageBoxHelper = new MessageBoxHelper(this); string name; if (!messageBoxHelper.ValidateNameTextBox(tbxName, out name)) { return; } if (_annotationDef == null || name != _annotationDef.Name) { foreach (var annotationDef in _existing) { if (annotationDef.Name == name) { messageBoxHelper.ShowTextBoxError(tbxName, Resources.DefineAnnotationDlg_OkDialog_There_is_already_an_annotation_defined_named__0__, name); return; } } } if (checkedListBoxAppliesTo.CheckedItems.Count == 0) { MessageBox.Show(this, Resources.DefineAnnotationDlg_OkDialog_Choose_at_least_one_type_for_this_annotation_to_apply_to, Program.Name); checkedListBoxAppliesTo.Focus(); return; } DialogResult = DialogResult.OK; Close(); }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(textName, out name)) return; if (_columns.Count == 0) { MessageBox.Show(this, Resources.PivotReportDlg_OkDialog_A_report_must_have_at_least_one_column, Program.Name); return; } ReportSpec reportSpec = GetReport().GetReportSpec(name); if ((_reportSpec == null || !Equals(reportSpec.Name, _reportSpec.Name)) && _existing.Contains(reportSpec, new NameComparer<ReportSpec>())) { helper.ShowTextBoxError(textName, Resources.PivotReportDlg_OkDialog_The_report__0__already_exists, name); return; } _reportSpec = reportSpec; DialogResult = DialogResult.OK; Close(); }
public void ShowTextBoxErrorMonoMass(MessageBoxHelper helper, string message) { helper.ShowTextBoxError(textMono, message); }
public bool ValidatePrecursorRes(MessageBoxHelper helper, double? precursorIsotopeFilter, out double? precursorRes, TabControl tabControl = null, int tabIndex = -1) { precursorRes = null; FullScanPrecursorIsotopes precursorIsotopes = PrecursorIsotopesCurrent; FullScanMassAnalyzerType precursorAnalyzerType = PrecursorMassAnalyzer; if (precursorIsotopes != FullScanPrecursorIsotopes.None) { if (precursorAnalyzerType == FullScanMassAnalyzerType.qit) { if (precursorIsotopes != FullScanPrecursorIsotopes.Count || precursorIsotopeFilter != 1) { if (null != tabControl) { helper.ShowTextBoxError(tabControl, tabIndex, textPrecursorIsotopeFilter, Resources. TransitionSettingsUI_OkDialog_For_MS1_filtering_with_a_QIT_mass_analyzer_only_1_isotope_peak_is_supported); } else { helper.ShowTextBoxError(textPrecursorIsotopeFilter, Resources. TransitionSettingsUI_OkDialog_For_MS1_filtering_with_a_QIT_mass_analyzer_only_1_isotope_peak_is_supported); } return false; } } double minFilt, maxFilt; GetFilterMinMax(PrecursorMassAnalyzer, out minFilt, out maxFilt); double precRes; bool valid; if (null != tabControl) { valid = helper.ValidateDecimalTextBox(tabControl, tabIndex, textPrecursorRes, minFilt, maxFilt, out precRes); } else { valid = helper.ValidateDecimalTextBox(textPrecursorRes, minFilt, maxFilt, out precRes); } if (!valid) return false; precursorRes = precRes; } return true; }
public void OkDialog() { var helper = new MessageBoxHelper(this); if (NamedPathSets == null) { if (radioAddExisting.Checked) { if (comboName.SelectedIndex == -1) { MessageBox.Show(this, Resources.ImportResultsDlg_OkDialog_You_must_select_an_existing_set_of_results_to_which_to_append_new_data, Program.Name); comboName.Focus(); return; } if (!CanCreateMultiInjectionMethods()) return; NamedPathSets = GetDataSourcePathsFile(comboName.SelectedItem.ToString()); } else if (radioCreateMultiple.Checked) { NamedPathSets = GetDataSourcePathsFile(null); } else if (radioCreateMultipleMulti.Checked) { if (!CanCreateMultiInjectionMethods()) return; NamedPathSets = GetDataSourcePathsDir(); } else { string name; if (!helper.ValidateNameTextBox(textName, out name)) return; if (name.IndexOfAny(Path.GetInvalidFileNameChars()) != -1) { helper.ShowTextBoxError(textName, Resources.ImportResultsDlg_OkDialog_A_result_name_may_not_contain_any_of_the_characters___0___, Path.GetInvalidFileNameChars()); return; } if (ResultsExist(name)) { helper.ShowTextBoxError(textName, Resources.ImportResultsDlg_OkDialog_The_specified_name_already_exists_for_this_document); return; } NamedPathSets = GetDataSourcePathsFile(name); if (NamedPathSets == null) return; foreach (var namedPathSet in NamedPathSets) { // Look for a multiple injection replicate if (namedPathSet.Value.Length > 1) { // Make sure they are allowed if (!CanCreateMultiInjectionMethods()) return; // If so, then no need to check any others break; } } } } if (NamedPathSets == null) return; if (NamedPathSets.Length > 1) { string prefix = GetCommonPrefix(Array.ConvertAll(NamedPathSets, ns => ns.Key)); if (prefix.Length >= MIN_COMMON_PREFIX_LENGTH) { using (var dlgName = new ImportResultsNameDlg(prefix)) { var result = dlgName.ShowDialog(this); if (result == DialogResult.Cancel) { return; } if (result == DialogResult.Yes) { // Rename all the replicates to remove the specified prefix. for (int i = 0; i < NamedPathSets.Length; i++) { var namedSet = NamedPathSets[i]; NamedPathSets[i] = new KeyValuePair<string, MsDataFileUri[]>( namedSet.Key.Substring(dlgName.Prefix.Length), namedSet.Value); } } } } } // Always make sure multiple replicates have unique names. For single // replicate, the user will get an error. if (IsMultiple) EnsureUniqueNames(); DialogResult = DialogResult.OK; }
public void OkDialog() { var helper = new MessageBoxHelper(this); // Validate and store prediction settings string massType = comboPrecursorMass.SelectedItem.ToString(); MassType precursorMassType = MassTypeExtension.GetEnum(massType); massType = comboIonMass.SelectedItem.ToString(); MassType fragmentMassType = MassTypeExtension.GetEnum(massType); string nameCE = comboCollisionEnergy.SelectedItem.ToString(); CollisionEnergyRegression collisionEnergy = Settings.Default.GetCollisionEnergyByName(nameCE); string nameDP = comboDeclusterPotential.SelectedItem.ToString(); DeclusteringPotentialRegression declusteringPotential = Settings.Default.GetDeclusterPotentialByName(nameDP); string nameCoV = comboCompensationVoltage.SelectedItem.ToString(); CompensationVoltageParameters compensationVoltage = Settings.Default.GetCompensationVoltageByName(nameCoV); string nameOptLib = comboOptimizationLibrary.SelectedItem.ToString(); OptimizationLibrary optimizationLibrary = Settings.Default.GetOptimizationLibraryByName(nameOptLib); OptimizedMethodType optimizedMethodType = OptimizedMethodType.None; if (cbUseOptimized.Checked) { optimizedMethodType = OptimizedMethodTypeExtension.GetEnum(comboOptimizeType.SelectedItem.ToString()); } TransitionPrediction prediction = new TransitionPrediction(precursorMassType, fragmentMassType, collisionEnergy, declusteringPotential, compensationVoltage, optimizationLibrary, optimizedMethodType); Helpers.AssignIfEquals(ref prediction, Prediction); // Validate and store filter settings int[] precursorCharges; int min = TransitionGroup.MIN_PRECURSOR_CHARGE; int max = TransitionGroup.MAX_PRECURSOR_CHARGE; if (!helper.ValidateNumberListTextBox(tabControl1, (int) TABS.Filter, textPrecursorCharges, min, max, out precursorCharges)) return; precursorCharges = precursorCharges.Distinct().ToArray(); int[] productCharges; min = Transition.MIN_PRODUCT_CHARGE; max = Transition.MAX_PRODUCT_CHARGE; if (!helper.ValidateNumberListTextBox(tabControl1, (int) TABS.Filter, textIonCharges, min, max, out productCharges)) return; productCharges = productCharges.Distinct().ToArray(); IonType[] types = TransitionFilter.ParseTypes(textIonTypes.Text, new IonType[0]); if (types.Length == 0) { helper.ShowTextBoxError(tabControl1, (int) TABS.Filter, textIonTypes, Resources.TransitionSettingsUI_OkDialog_Ion_types_must_contain_a_comma_separated_list_of_ion_types_a_b_c_x_y_z_and_p_for_precursor); return; } types = types.Distinct().ToArray(); double exclusionWindow = 0; if (!string.IsNullOrEmpty(textExclusionWindow.Text) && !Equals(textExclusionWindow.Text, exclusionWindow.ToString(LocalizationHelper.CurrentCulture))) { if (!helper.ValidateDecimalTextBox(tabControl1, (int)TABS.Filter, textExclusionWindow, TransitionFilter.MIN_EXCLUSION_WINDOW, TransitionFilter.MAX_EXCLUSION_WINDOW, out exclusionWindow)) { return; } } string fragmentRangeFirst = TransitionFilter.GetStartFragmentNameFromLabel(comboRangeFrom.SelectedItem.ToString()); string fragmentRangeLast = TransitionFilter.GetEndFragmentNameFromLabel(comboRangeTo.SelectedItem.ToString()); var measuredIons = _driverIons.Chosen; bool autoSelect = cbAutoSelect.Checked; bool exclusionUseDIAWindow = FullScanSettingsControl.IsDIA() && cbExclusionUseDIAWindow.Checked; var filter = new TransitionFilter(precursorCharges, productCharges, types, fragmentRangeFirst, fragmentRangeLast, measuredIons, exclusionWindow, exclusionUseDIAWindow, autoSelect); Helpers.AssignIfEquals(ref filter, Filter); // Validate and store library settings TransitionLibraryPick pick = TransitionLibraryPick.none; if (cbLibraryPick.Checked) { if (radioAll.Checked) pick = TransitionLibraryPick.all; else if (radioAllAndFiltered.Checked) pick = TransitionLibraryPick.all_plus; else pick = TransitionLibraryPick.filter; } double ionMatchTolerance; double minTol = TransitionLibraries.MIN_MATCH_TOLERANCE; double maxTol = TransitionLibraries.MAX_MATCH_TOLERANCE; if (!helper.ValidateDecimalTextBox(tabControl1, (int) TABS.Library, textTolerance, minTol, maxTol, out ionMatchTolerance)) return; int ionCount = Libraries.IonCount; if (pick != TransitionLibraryPick.none) { min = TransitionLibraries.MIN_ION_COUNT; max = TransitionLibraries.MAX_ION_COUNT; if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Library, textIonCount, min, max, out ionCount)) return; } TransitionLibraries libraries = new TransitionLibraries(ionMatchTolerance, ionCount, pick); Helpers.AssignIfEquals(ref libraries, Libraries); // This dialog does not yet change integration settings TransitionIntegration integration = _transitionSettings.Integration; // Validate and store instrument settings int minMz; min = TransitionInstrument.MIN_MEASUREABLE_MZ; max = TransitionInstrument.MAX_MEASURABLE_MZ - TransitionInstrument.MIN_MZ_RANGE; if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Instrument, textMinMz, min, max, out minMz)) return; int maxMz; min = minMz + TransitionInstrument.MIN_MZ_RANGE; max = TransitionInstrument.MAX_MEASURABLE_MZ; if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Instrument, textMaxMz, min, max, out maxMz)) return; bool isDynamicMin = cbDynamicMinimum.Checked; double mzMatchTolerance; minTol = TransitionInstrument.MIN_MZ_MATCH_TOLERANCE; maxTol = TransitionInstrument.MAX_MZ_MATCH_TOLERANCE; if (!helper.ValidateDecimalTextBox(tabControl1, (int) TABS.Instrument, textMzMatchTolerance, minTol, maxTol, out mzMatchTolerance)) return; int? maxTrans = null; if (!string.IsNullOrEmpty(textMaxTrans.Text)) { int maxTransTemp; min = TransitionInstrument.MIN_TRANSITION_MAX; max = TransitionInstrument.MAX_TRANSITION_MAX; if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Instrument, textMaxTrans, min, max, out maxTransTemp)) return; maxTrans = maxTransTemp; } int? maxInclusions = null; if (!string.IsNullOrEmpty(textMaxInclusions.Text)) { int maxInclusionsTemp; min = TransitionInstrument.MIN_INCLUSION_MAX; max = TransitionInstrument.MAX_INCLUSION_MAX; if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Instrument, textMaxInclusions, min, max, out maxInclusionsTemp)) return; maxInclusions = maxInclusionsTemp; } int? minTime = null, maxTime = null; min = TransitionInstrument.MIN_TIME; max = TransitionInstrument.MAX_TIME; if (!string.IsNullOrEmpty(textMinTime.Text)) { int minTimeTemp; if (!helper.ValidateNumberTextBox(tabControl1, (int)TABS.Instrument, textMinTime, min, max, out minTimeTemp)) return; minTime = minTimeTemp; } if (!string.IsNullOrEmpty(textMaxTime.Text)) { int maxTimeTemp; if (!helper.ValidateNumberTextBox(tabControl1, (int)TABS.Instrument, textMaxTime, min, max, out maxTimeTemp)) return; maxTime = maxTimeTemp; } if (minTime.HasValue && maxTime.HasValue && maxTime.Value - minTime.Value < TransitionInstrument.MIN_TIME_RANGE) { helper.ShowTextBoxError(tabControl1, (int) TABS.Instrument, textMaxTime, string.Format(Resources.TransitionSettingsUI_OkDialog_The_allowable_retention_time_range__0__to__1__must_be_at_least__2__minutes_apart, minTime, maxTime, TransitionInstrument.MIN_TIME_RANGE)); return; } TransitionInstrument instrument = new TransitionInstrument(minMz, maxMz, isDynamicMin, mzMatchTolerance, maxTrans, maxInclusions, minTime, maxTime); Helpers.AssignIfEquals(ref instrument, Instrument); // Validate and store full-scan settings // If high resolution MS1 filtering is enabled, make sure precursor m/z type // is monoisotopic and isotope enrichments are set FullScanPrecursorIsotopes precursorIsotopes = PrecursorIsotopesCurrent; FullScanMassAnalyzerType precursorAnalyzerType = PrecursorMassAnalyzer; if (precursorIsotopes != FullScanPrecursorIsotopes.None && precursorAnalyzerType != FullScanMassAnalyzerType.qit) { if (precursorMassType != MassType.Monoisotopic) { MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_High_resolution_MS1_filtering_requires_use_of_monoisotopic_precursor_masses); tabControl1.SelectedIndex = (int)TABS.Prediction; comboPrecursorMass.Focus(); return; } if (FullScanSettingsControl.Enrichments == null) { tabControl1.SelectedIndex = (int) TABS.FullScan; MessageDlg.Show(GetParentForm(this), Resources.TransitionSettingsUI_OkDialog_Isotope_enrichment_settings_are_required_for_MS1_filtering_on_high_resolution_mass_spectrometers); FullScanSettingsControl.ComboEnrichmentsSetFocus(); return; } } IsolationScheme isolationScheme = FullScanSettingsControl.IsolationScheme; FullScanAcquisitionMethod acquisitionMethod = AcquisitionMethod; if (isolationScheme == null && acquisitionMethod == FullScanAcquisitionMethod.DIA) { tabControl1.SelectedIndex = (int)TABS.FullScan; MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_An_isolation_scheme_is_required_to_match_multiple_precursors); FullScanSettingsControl.ComboIsolationSchemeSetFocus(); return; } if (isolationScheme != null && isolationScheme.WindowsPerScan.HasValue && !maxInclusions.HasValue) { MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_Before_performing_a_multiplexed_DIA_scan_the_instrument_s_firmware_inclusion_limit_must_be_specified); tabControl1.SelectedIndex = (int)TABS.Instrument; textMaxInclusions.Focus(); return; } if (FullScanSettingsControl.IsDIA() && cbExclusionUseDIAWindow.Checked) { if (FullScanSettingsControl.IsolationScheme.IsAllIons) { MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_Cannot_use_DIA_window_for_precusor_exclusion_when__All_Ions__is_selected_as_the_isolation_scheme___To_use_the_DIA_window_for_precusor_exclusion__change_the_isolation_scheme_in_the_Full_Scan_settings_); tabControl1.SelectedIndex = (int)TABS.Filter; cbExclusionUseDIAWindow.Focus(); return; } if (FullScanSettingsControl.IsolationScheme.FromResults) { MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_Cannot_use_DIA_window_for_precursor_exclusion_when_isolation_scheme_does_not_contain_prespecified_windows___Please_select_an_isolation_scheme_with_prespecified_windows_); tabControl1.SelectedIndex = (int)TABS.Filter; cbExclusionUseDIAWindow.Focus(); return; } } TransitionFullScan fullScan; if (!FullScanSettingsControl.ValidateFullScanSettings(helper, out fullScan, tabControl1, (int)TABS.FullScan)) return; Helpers.AssignIfEquals(ref fullScan, FullScan); TransitionSettings settings = new TransitionSettings(prediction, filter, libraries, integration, instrument, fullScan); // Only update, if anything changed if (!Equals(settings, _transitionSettings)) { if (!_parent.ChangeSettingsMonitored(this, Resources.TransitionSettingsUI_OkDialog_Changing_transition_settings, s => s.ChangeTransitionSettings(settings))) { return; } _transitionSettings = settings; } DialogResult = DialogResult.OK; }
public void OkDialog() { var helper = new MessageBoxHelper(this); int? minPeptidesPerProtein = null; if (!string.IsNullOrEmpty(textMinPeptides.Text)) { int minVal; if (!helper.ValidateNumberTextBox(tabControl1, 0, textMinPeptides, 0, 10, out minVal)) return; minPeptidesPerProtein = minVal; } int? minTransitionsPerPrecursor = null; if (!string.IsNullOrEmpty(textMinTransitions.Text)) { int minVal; if (!helper.ValidateNumberTextBox(tabControl1, 0, textMinTransitions, 0, 100, out minVal)) return; minTransitionsPerPrecursor = minVal; } bool removeDuplicatePeptides = cbRemoveDuplicatePeptides.Checked; bool removeRepeatedPeptides = cbRemoveRepeatedPeptides.Checked; IsotopeLabelType refineLabelType = RefineLabelType; bool addLabelType = cbAdd.Checked; // If adding, make sure there is something to add if (addLabelType && refineLabelType != null && !CanAddLabelType(refineLabelType)) { MessageDlg.Show(this, string.Format(Resources.RefineDlg_OkDialog_The_label_type__0__cannot_be_added_There_are_no_modifications_for_this_type, refineLabelType.Name)); tabControl1.SelectedIndex = 0; comboRefineLabelType.Focus(); return; } double? minPeakFoundRatio = null, maxPeakFoundRatio = null; if (!string.IsNullOrEmpty(textMinPeakFoundRatio.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(tabControl1, 1, textMinPeakFoundRatio, 0, 1, out minVal)) return; minPeakFoundRatio = minVal; } if (!string.IsNullOrEmpty(textMaxPeakFoundRatio.Text)) { double maxVal; if (!helper.ValidateDecimalTextBox(tabControl1, 1, textMaxPeakFoundRatio, 0, 1, out maxVal)) return; maxPeakFoundRatio = maxVal; } if (minPeakFoundRatio.HasValue && maxPeakFoundRatio.HasValue && minPeakFoundRatio.Value > maxPeakFoundRatio.Value) { helper.ShowTextBoxError(textMaxPeakFoundRatio, Resources.RefineDlg_OkDialog__0__must_be_less_than_min_peak_found_ratio); return; } int? maxPepPeakRank = null; if (!string.IsNullOrEmpty(textMaxPepPeakRank.Text)) { int maxVal; if (!helper.ValidateNumberTextBox(tabControl1, 1, textMaxPepPeakRank, 1, 10, out maxVal)) return; maxPepPeakRank = maxVal; } int? maxPeakRank = null; if (!string.IsNullOrEmpty(textMaxPeakRank.Text)) { int maxVal; if (!helper.ValidateNumberTextBox(tabControl1, 1, textMaxPeakRank, 1, 10, out maxVal)) return; maxPeakRank = maxVal; } bool removeMissingResults = radioRemoveMissing.Checked; double? rtRegressionThreshold = null; if (!string.IsNullOrEmpty(textRTRegressionThreshold.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(tabControl1, 1, textRTRegressionThreshold, 0, 1, out minVal)) return; rtRegressionThreshold = minVal; } double? dotProductThreshold = null; if (!string.IsNullOrEmpty(textMinDotProduct.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(tabControl1, 1, textMinDotProduct, 0, 1, out minVal)) return; dotProductThreshold = minVal; } double? idotProductThreshold = null; if (!string.IsNullOrEmpty(textMinIdotProduct.Text)) { double minVal; if (!helper.ValidateDecimalTextBox(tabControl1, 1, textMinIdotProduct, 0, 1, out minVal)) return; idotProductThreshold = minVal; } bool useBestResult = comboReplicateUse.SelectedIndex > 0; RefinementSettings = new RefinementSettings { MinPeptidesPerProtein = minPeptidesPerProtein, RemoveDuplicatePeptides = removeDuplicatePeptides, RemoveRepeatedPeptides = removeRepeatedPeptides, MinTransitionsPepPrecursor = minTransitionsPerPrecursor, RefineLabelType = refineLabelType, AddLabelType = addLabelType, MinPeakFoundRatio = minPeakFoundRatio, MaxPeakFoundRatio = maxPeakFoundRatio, MaxPepPeakRank = maxPepPeakRank, MaxPeakRank = maxPeakRank, PreferLargeIons = cbPreferLarger.Checked, RemoveMissingResults = removeMissingResults, RTRegressionThreshold = rtRegressionThreshold, DotProductThreshold = dotProductThreshold, IdotProductThreshold = idotProductThreshold, UseBestResult = useBestResult, AutoPickChildrenAll = (cbAutoPeptides.Checked ? PickLevel.peptides : 0) | (cbAutoPrecursors.Checked ? PickLevel.precursors : 0) | (cbAutoTransitions.Checked ? PickLevel.transitions : 0) }; DialogResult = DialogResult.OK; Close(); }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(textName, out name)) return; // Allow updating the original modification if (LibrarySpec == null || !Equals(name, LibrarySpec.Name)) { // But not any other existing modification foreach (LibrarySpec mod in _existing) { if (Equals(name, mod.Name)) { helper.ShowTextBoxError(textName, Resources.EditLibraryDlg_OkDialog_The_library__0__already_exists, name); return; } } } String path = textPath.Text; if (!File.Exists(path)) { MessageBox.Show(this, string.Format(Resources.EditLibraryDlg_OkDialog_The_file__0__does_not_exist, path), Program.Name); textPath.Focus(); return; } if (FileEx.IsDirectory(path)) { MessageBox.Show(this, string.Format(Resources.EditLibraryDlg_OkDialog_The_path__0__is_a_directory, path), Program.Name); textPath.Focus(); return; } // Display an error message if the user is trying to add a BiblioSpec library, // and the library has the text "redundant" in the file name. if (path.EndsWith(BiblioSpecLiteSpec.EXT_REDUNDANT)) { var message = TextUtil.LineSeparate(string.Format(Resources.EditLibraryDlg_OkDialog_The_file__0__appears_to_be_a_redundant_library, path), Resources.EditLibraryDlg_OkDialog_Please_choose_a_non_redundant_library); MessageDlg.Show(this, string.Format(message, path)); textPath.Focus(); return; } var librarySpec = LibrarySpec.CreateFromPath(name, path); if (librarySpec == null) { MessageDlg.Show(this, string.Format(Resources.EditLibraryDlg_OkDialog_The_file__0__is_not_a_supported_spectral_library_file_format, path)); textPath.Focus(); return; } if (librarySpec is ChromatogramLibrarySpec) { using (var longWait = new LongWaitDlg{ Text = Resources.EditLibraryDlg_OkDialog_Loading_chromatogram_library }) { Library lib = null; try { try { longWait.PerformWork(this, 800, monitor => lib = librarySpec.LoadLibrary(new DefaultFileLoadMonitor(monitor))); } // ReSharper disable once EmptyGeneralCatchClause catch { // Library failed to load } LibraryRetentionTimes libRts; if (lib != null && lib.TryGetIrts(out libRts) && Settings.Default.RTScoreCalculatorList.All(calc => calc.PersistencePath != path)) { using (var addPredictorDlg = new AddRetentionTimePredictorDlg(name, path)) { switch (addPredictorDlg.ShowDialog(this)) { case DialogResult.OK: Settings.Default.RTScoreCalculatorList.Add(addPredictorDlg.Calculator); Settings.Default.RetentionTimeList.Add(addPredictorDlg.Regression); Settings.Default.Save(); break; case DialogResult.No: break; default: return; } } } } finally { if (null != lib) { foreach (var pooledStream in lib.ReadStreams) { pooledStream.CloseStream(); } } } } } _librarySpec = librarySpec; DialogResult = DialogResult.OK; Close(); }
public void ShowTextBoxErrorAverageMass(MessageBoxHelper helper, string message) { helper.ShowTextBoxError(textAverage,message); }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(textName, out name)) return; string cleavageC; if (!helper.ValidateAATextBox(textCleavage, false, out cleavageC)) return; string restrictC; if (!helper.ValidateAATextBox(textRestrict, true, out restrictC)) return; string cleavageN; string restrictN; if (comboDirection.SelectedIndex == 2) { if (!helper.ValidateAATextBox(textCleavageN, false, out cleavageN)) return; if (!helper.ValidateAATextBox(textRestrictN, true, out restrictN)) return; } else if (comboDirection.SelectedIndex == 1) { cleavageN = cleavageC; cleavageC = null; restrictN = restrictC; restrictC = null; } else { cleavageN = null; restrictN = null; } Enzyme enzyme = new Enzyme(name, cleavageC, restrictC, cleavageN, restrictN); if (_enzyme == null && _existing.Contains(enzyme)) { helper.ShowTextBoxError(textName, Resources.EditEnzymeDlg_OnClosing_The_enzyme__0__already_exists, name); return; } _enzyme = enzyme; DialogResult = DialogResult.OK; }
public void ShowTextBoxErrorFormula(MessageBoxHelper helper, string message) { helper.ShowTextBoxError(textFormula, message); }
private PeptideSettings ValidateNewSettings(bool showMessages) { var helper = new MessageBoxHelper(this, showMessages); // Validate and hold digestion settings Enzyme enzyme = Settings.Default.GetEnzymeByName(comboEnzyme.SelectedItem.ToString()); Helpers.AssignIfEquals(ref enzyme, _peptideSettings.Enzyme); int maxMissedCleavages = int.Parse(comboMissedCleavages.SelectedItem.ToString()); bool excludeRaggedEnds = cbRaggedEnds.Checked; DigestSettings digest = new DigestSettings(maxMissedCleavages, excludeRaggedEnds); Helpers.AssignIfEquals(ref digest, Digest); var backgroundProteomeSpec = _driverBackgroundProteome.SelectedItem; BackgroundProteome backgroundProteome = BackgroundProteome.NONE; if (!backgroundProteomeSpec.IsNone) { backgroundProteome = new BackgroundProteome(backgroundProteomeSpec, true); if (backgroundProteome.DatabaseInvalid) { var message = TextUtil.LineSeparate(string.Format(Resources.PeptideSettingsUI_ValidateNewSettings_Failed_to_load_background_proteome__0__, backgroundProteomeSpec.Name), string.Format(Resources.PeptideSettingsUI_ValidateNewSettings_The_file__0__may_not_be_a_valid_proteome_file, backgroundProteomeSpec.DatabasePath)); MessageDlg.Show(this, message); tabControl1.SelectedIndex = 0; _driverBackgroundProteome.Combo.Focus(); return null; } } Helpers.AssignIfEquals(ref backgroundProteome, _peptideSettings.BackgroundProteome); // Validate and hold prediction settings string nameRT = comboRetentionTime.SelectedItem.ToString(); RetentionTimeRegression retentionTime = Settings.Default.GetRetentionTimeByName(nameRT); if (retentionTime != null && retentionTime.Calculator != null) { RetentionScoreCalculatorSpec retentionCalc = Settings.Default.GetCalculatorByName(retentionTime.Calculator.Name); // Just in case the calculator in use in the current documet got removed, // never set the calculator to null. Just keep using the one we have. if (retentionCalc != null && !ReferenceEquals(retentionCalc, retentionTime.Calculator)) retentionTime = retentionTime.ChangeCalculator(retentionCalc); } bool useMeasuredRT = cbUseMeasuredRT.Checked; double? measuredRTWindow = null; if (!string.IsNullOrEmpty(textMeasureRTWindow.Text)) { double measuredRTWindowOut; const double minWindow = PeptidePrediction.MIN_MEASURED_RT_WINDOW; const double maxWindow = PeptidePrediction.MAX_MEASURED_RT_WINDOW; if (!helper.ValidateDecimalTextBox(tabControl1, (int) TABS.Prediction, textMeasureRTWindow, minWindow, maxWindow, out measuredRTWindowOut)) return null; measuredRTWindow = measuredRTWindowOut; } string nameDt = comboDriftTimePredictor.SelectedItem.ToString(); DriftTimePredictor driftTimePredictor = Settings.Default.GetDriftTimePredictorByName(nameDt); if (driftTimePredictor != null && driftTimePredictor.IonMobilityLibrary != null) { IonMobilityLibrarySpec ionMobilityLibrary = Settings.Default.GetIonMobilityLibraryByName(driftTimePredictor.IonMobilityLibrary.Name); // Just in case the library in use in the current documet got removed, // never set the library to null. Just keep using the one we have. if (ionMobilityLibrary != null && !ReferenceEquals(ionMobilityLibrary, driftTimePredictor.IonMobilityLibrary)) driftTimePredictor = driftTimePredictor.ChangeLibrary(ionMobilityLibrary); } bool useLibraryDriftTime = cbUseSpectralLibraryDriftTimes.Checked; double? libraryDTResolvingPower = null; if (useLibraryDriftTime || !string.IsNullOrEmpty(textSpectralLibraryDriftTimesResolvingPower.Text)) { double libraryDTWindowOut; if (!helper.ValidateDecimalTextBox(tabControl1, (int)TABS.Prediction, textSpectralLibraryDriftTimesResolvingPower, null, null, out libraryDTWindowOut)) return null; string errmsg = EditDriftTimePredictorDlg.ValidateResolvingPower(libraryDTWindowOut); if (errmsg != null) { helper.ShowTextBoxError(tabControl1, (int)TABS.Prediction, textSpectralLibraryDriftTimesResolvingPower, errmsg); return null; } libraryDTResolvingPower = libraryDTWindowOut; } var prediction = new PeptidePrediction(retentionTime, driftTimePredictor, useMeasuredRT, measuredRTWindow, useLibraryDriftTime, libraryDTResolvingPower); Helpers.AssignIfEquals(ref prediction, Prediction); // Validate and hold filter settings int excludeNTermAAs; if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Filter, textExcludeAAs, PeptideFilter.MIN_EXCLUDE_NTERM_AA, PeptideFilter.MAX_EXCLUDE_NTERM_AA, out excludeNTermAAs)) return null; int minPeptideLength; if (!helper.ValidateNumberTextBox(tabControl1, (int) TABS.Filter, textMinLength, PeptideFilter.MIN_MIN_LENGTH, PeptideFilter.MAX_MIN_LENGTH, out minPeptideLength)) return null; int maxPeptideLength; if (!helper.ValidateNumberTextBox(tabControl1, (int)TABS.Filter, textMaxLength, Math.Max(PeptideFilter.MIN_MAX_LENGTH, minPeptideLength), PeptideFilter.MAX_MAX_LENGTH, out maxPeptideLength)) return null; PeptideExcludeRegex[] exclusions = _driverExclusion.Chosen; bool autoSelect = cbAutoSelect.Checked; PeptideFilter filter; try { filter = new PeptideFilter(excludeNTermAAs, minPeptideLength, maxPeptideLength, exclusions, autoSelect); } catch (InvalidDataException x) { if (showMessages) MessageDlg.ShowException(this, x); return null; } Helpers.AssignIfEquals(ref filter, Filter); // Validate and hold libraries PeptideLibraries libraries; IList<LibrarySpec> librarySpecs = _driverLibrary.Chosen; if (librarySpecs.Count == 0) libraries = new PeptideLibraries(PeptidePick.library, null, null, false, librarySpecs, new Library[0]); else { int? peptideCount = null; if (cbLimitPeptides.Checked) { int peptideCountVal; if (!helper.ValidateNumberTextBox(textPeptideCount, PeptideLibraries.MIN_PEPTIDE_COUNT, PeptideLibraries.MAX_PEPTIDE_COUNT, out peptideCountVal)) return null; peptideCount = peptideCountVal; } PeptidePick pick = (PeptidePick) comboMatching.SelectedIndex; IList<Library> librariesLoaded = new Library[librarySpecs.Count]; bool documentLibrary = false; if (Libraries != null) { // Use existing library spec's, if nothing was changed. // Avoid changing the libraries, just because the the picking // algorithm changed. if (ArrayUtil.EqualsDeep(librarySpecs, Libraries.LibrarySpecs)) { librarySpecs = Libraries.LibrarySpecs; librariesLoaded = Libraries.Libraries; } documentLibrary = Libraries.HasDocumentLibrary; // Otherwise, leave the list of loaded libraries empty, // and let the LibraryManager refill it. This ensures a // clean save of library specs only in the user config, rather // than a mix of library specs and libraries. } PeptideRankId rankId = (PeptideRankId) comboRank.SelectedItem; if (comboRank.SelectedIndex == 0) rankId = null; libraries = new PeptideLibraries(pick, rankId, peptideCount, documentLibrary, librarySpecs, librariesLoaded); } Helpers.AssignIfEquals(ref libraries, Libraries); // Validate and hold modifications int maxVariableMods; if (!helper.ValidateNumberTextBox(tabControl1, (int)TABS.Modifications, textMaxVariableMods, PeptideModifications.MIN_MAX_VARIABLE_MODS, PeptideModifications.MAX_MAX_VARIABLE_MODS, out maxVariableMods)) return null; int maxNeutralLosses; if (!helper.ValidateNumberTextBox(tabControl1, (int)TABS.Modifications, textMaxNeutralLosses, PeptideModifications.MIN_MAX_NEUTRAL_LOSSES, PeptideModifications.MAX_MAX_NEUTRAL_LOSSES, out maxNeutralLosses)) return null; var standardTypes = _driverLabelType.InternalStandardTypes; PeptideModifications modifications = new PeptideModifications( _driverStaticMod.Chosen, maxVariableMods, maxNeutralLosses, _driverLabelType.GetHeavyModifications(), standardTypes); // Should not be possible to change explicit modifications in the background, // so this should be safe. CONSIDER: Document structure because of a library load? modifications = modifications.DeclareExplicitMods(_parent.DocumentUI, Settings.Default.StaticModList, Settings.Default.HeavyModList); Helpers.AssignIfEquals(ref modifications, _peptideSettings.Modifications); PeptideIntegration integration = new PeptideIntegration(_driverPeakScoringModel.SelectedItem); Helpers.AssignIfEquals(ref integration, Integration); QuantificationSettings quantification = QuantificationSettings.DEFAULT .ChangeNormalizationMethod(comboNormalizationMethod.SelectedItem as NormalizationMethod ?? NormalizationMethod.NONE) .ChangeRegressionWeighting(comboWeighting.SelectedItem as RegressionWeighting) .ChangeRegressionFit(comboRegressionFit.SelectedItem as RegressionFit) .ChangeMsLevel(_quantMsLevels[comboQuantMsLevel.SelectedIndex]) .ChangeUnits(tbxQuantUnits.Text); return new PeptideSettings(enzyme, digest, prediction, filter, libraries, modifications, integration, backgroundProteome) .ChangeAbsoluteQuantification(quantification); }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(_editing ? (Control) textName : comboMod, out name)) return; // Allow updating the original modification if (!_editing || !Equals(name, Modification.Name)) { if(!ModNameAvailable(name)) { helper.ShowTextBoxError(_editing ? (Control)textName : comboMod, Resources.EditStaticModDlg_OkDialog_The_modification__0__already_exists, name); return; } } string aas = comboAA.Text; if (string.IsNullOrEmpty(aas)) aas = null; else { // Use the cleanest possible format. var sb = new StringBuilder(); foreach (string aaPart in aas.Split(SEPARATOR_AA)) { string aa = aaPart.Trim(); if (aa.Length == 0) continue; if (sb.Length > 0) sb.Append(", "); // Not L10N sb.Append(aa); } } string termString = comboTerm.SelectedItem.ToString(); ModTerminus? term = null; if (!string.IsNullOrEmpty(termString)) term = (ModTerminus) Enum.Parse(typeof (ModTerminus), termString); if (cbVariableMod.Checked && aas == null && term == null) { MessageDlg.Show(this, Resources.EditStaticModDlg_OkDialog_Variable_modifications_must_specify_amino_acid_or_terminus); comboAA.Focus(); return; } string formula = null; double? monoMass = null; double? avgMass = null; LabelAtoms labelAtoms = LabelAtoms.None; if (cbChemicalFormula.Checked) formula = Formula; else labelAtoms = LabelAtoms; // Get the losses to know whether any exist below IList<FragmentLoss> losses = null; if (listNeutralLosses.Items.Count > 0) { losses = Losses.ToArray(); } if (!string.IsNullOrEmpty(formula)) { try { SequenceMassCalc.ParseModMass(BioMassCalc.MONOISOTOPIC, formula); } catch (ArgumentException x) { _formulaBox.ShowTextBoxErrorFormula(helper, x.Message); return; } } else if (labelAtoms == LabelAtoms.None) { formula = null; // Allow formula and both masses to be empty, if losses are present if ( NotZero(_formulaBox.MonoMass) || NotZero(_formulaBox.AverageMass)|| losses == null) { // TODO: Maximum and minimum masses should be formalized and applied everywhere double mass; if (!_formulaBox.ValidateMonoText(helper, -1500, 5000, out mass)) return; monoMass = mass; if (!_formulaBox.ValidateAverageText(helper, -1500, 5000, out mass)) return; avgMass = mass; } // Loss-only modifications may not be variable else if (cbVariableMod.Checked) { MessageDlg.Show(this, Resources.EditStaticModDlg_OkDialog_The_variable_checkbox_only_applies_to_precursor_modification_Product_ion_losses_are_inherently_variable); cbVariableMod.Focus(); return; } } else if (aas == null && term.HasValue) { MessageDlg.Show(this, Resources.EditStaticModDlg_OkDialog_Labeled_atoms_on_terminal_modification_are_not_valid); return; } RelativeRT relativeRT = RelativeRT.Matching; if (comboRelativeRT.Visible && comboRelativeRT.SelectedItem != null) { relativeRT = RelativeRTExtension.GetEnum(comboRelativeRT.SelectedItem.ToString()); } // Store state of the chemical formula checkbox for next use. if (cbChemicalFormula.Visible) Settings.Default.ShowHeavyFormula = _formulaBox.FormulaVisible; var newMod = new StaticMod(name, aas, term, cbVariableMod.Checked, formula, labelAtoms, relativeRT, monoMass, avgMass, losses); foreach (StaticMod mod in _existing) { if (newMod.Equivalent(mod) && !(_editing && mod.Equals(_originalModification))) { if (DialogResult.OK == MultiButtonMsgDlg.Show( this, TextUtil.LineSeparate(Resources.EditStaticModDlg_OkDialog_There_is_an_existing_modification_with_the_same_settings, string.Format("'{0}'.", mod.Name), // Not L10N string.Empty, Resources.EditStaticModDlg_OkDialog_Continue), MultiButtonMsgDlg.BUTTON_OK)) { Modification = newMod; DialogResult = DialogResult.OK; } return; } } var uniMod = UniMod.GetModification(name, IsStructural); // If the modification name is not found in Unimod, check if there exists a modification in Unimod that matches // the dialog modification, and prompt the user to to use the Unimod modification instead. if (uniMod == null) { var matchingMod = UniMod.FindMatchingStaticMod(newMod, IsStructural); if (matchingMod != null && (ModNameAvailable(matchingMod.Name) || (_editing && Equals(matchingMod.Name, Modification.Name)))) { var result = MultiButtonMsgDlg.Show( this, TextUtil.LineSeparate(Resources.EditStaticModDlg_OkDialog_There_is_a_Unimod_modification_with_the_same_settings, string.Empty, string.Format(Resources.EditStaticModDlg_OkDialog_Click__Unimod__to_use_the_name___0___, matchingMod.Name), string.Format(Resources.EditStaticModDlg_OkDialog_Click__Custom__to_use_the_name___0___, name)), Resources.EditStaticModDlg_OkDialog_Unimod, Resources.EditStaticModDlg_OkDialog_Custom, true); if (result == DialogResult.Yes) newMod = matchingMod.MatchVariableAndLossInclusion(newMod); // Unimod if (result == DialogResult.Cancel) return; } } else { // If the dialog modification matches the modification of the same name in Unimod, // use the UnimodId. if (newMod.Equivalent(uniMod)) newMod = uniMod.MatchVariableAndLossInclusion(newMod); else { // Finally, if the modification name is found in Unimod, but the modification in Unimod does not // match the dialog modification, prompt the user to use the Unimod modification definition instead. if (DialogResult.OK != MultiButtonMsgDlg.Show( this, TextUtil.LineSeparate(string.Format(Resources.EditStaticModDlg_OkDialog_This_modification_does_not_match_the_Unimod_specifications_for___0___, name), string.Empty, Resources.EditStaticModDlg_OkDialog_Use_non_standard_settings_for_this_name), MultiButtonMsgDlg.BUTTON_OK)) { return; } } } _modification = newMod; DialogResult = DialogResult.OK; }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(textName, out name)) return; if (_existing.Contains(r => !ReferenceEquals(_parameters, r) && Equals(name, r.Name))) { helper.ShowTextBoxError(textName, Resources.EditCoVDlg_btnOk_Click_The_compensation_voltage_parameters___0___already_exist_, name); return; } double covMin; if (!helper.ValidateDecimalTextBox(textMin, 0, null, out covMin)) return; double covMax; if (!helper.ValidateDecimalTextBox(textMax, 0, null, out covMax)) return; if (covMax < covMin) { helper.ShowTextBoxError(textMax, Resources.EditCoVDlg_btnOk_Click_Maximum_compensation_voltage_cannot_be_less_than_minimum_compensation_volatage_); return; } int stepCountRough; if (!helper.ValidateNumberTextBox(textStepsRough, CompensationVoltageParameters.MIN_STEP_COUNT, CompensationVoltageParameters.MAX_STEP_COUNT, out stepCountRough)) return; int stepCountMedium; if (!helper.ValidateNumberTextBox(textStepsMedium, CompensationVoltageParameters.MIN_STEP_COUNT, CompensationVoltageParameters.MAX_STEP_COUNT, out stepCountMedium)) return; int stepCountFine; if (!helper.ValidateNumberTextBox(textStepsFine, CompensationVoltageParameters.MIN_STEP_COUNT, CompensationVoltageParameters.MAX_STEP_COUNT, out stepCountFine)) return; _parameters = new CompensationVoltageParameters(name, covMin, covMax, stepCountRough, stepCountMedium, stepCountFine); DialogResult = DialogResult.OK; }
public void OkDialog(string outputPath) { var helper = new MessageBoxHelper(this, true); _instrumentType = comboInstrument.SelectedItem.ToString(); // Use variable for document to export, since code below may modify the document. SrmDocument documentExport = _document; string templateName = null; if (_fileType == ExportFileType.Method) { // Check for instruments that cannot do DIA. if (IsDia) { if (Equals(InstrumentType, ExportInstrumentType.AGILENT_TOF) || Equals(InstrumentType, ExportInstrumentType.ABI_TOF) || Equals(InstrumentType, ExportInstrumentType.THERMO_LTQ)) { helper.ShowTextBoxError(textTemplateFile, Resources.ExportMethodDlg_OkDialog_Export_of_DIA_method_is_not_supported_for__0__, InstrumentType); return; } } templateName = textTemplateFile.Text; if (string.IsNullOrEmpty(templateName)) { helper.ShowTextBoxError(textTemplateFile, Resources.ExportMethodDlg_OkDialog_A_template_file_is_required_to_export_a_method); return; } if ((Equals(InstrumentType, ExportInstrumentType.AGILENT6400) || Equals(InstrumentType, ExportInstrumentType.BRUKER_TOF)) ? !Directory.Exists(templateName) : !File.Exists(templateName)) { helper.ShowTextBoxError(textTemplateFile, Resources.ExportMethodDlg_OkDialog_The_template_file__0__does_not_exist, templateName); return; } if (Equals(InstrumentType, ExportInstrumentType.AGILENT6400) && !AgilentMethodExporter.IsAgilentMethodPath(templateName)) { helper.ShowTextBoxError(textTemplateFile, Resources.ExportMethodDlg_OkDialog_The_folder__0__does_not_appear_to_contain_an_Agilent_QQQ_method_template_The_folder_is_expected_to_have_a_m_extension_and_contain_the_file_qqqacqmethod_xsd, templateName); return; } if (Equals(InstrumentType, ExportInstrumentType.BRUKER_TOF) && !BrukerMethodExporter.IsBrukerMethodPath(templateName)) { helper.ShowTextBoxError(textTemplateFile, Resources.ExportMethodDlg_OkDialog_The_folder__0__does_not_appear_to_contain_a_Bruker_TOF_method_template___The_folder_is_expected_to_have_a__m_extension__and_contain_the_file_submethods_xml_, templateName); return; } } if (Equals(InstrumentType, ExportInstrumentType.AGILENT_TOF) || Equals(InstrumentType, ExportInstrumentType.ABI_TOF)) { // Check that mass analyzer settings are set to TOF. if (documentExport.Settings.TransitionSettings.FullScan.IsEnabledMs && documentExport.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer != FullScanMassAnalyzerType.tof) { MessageDlg.Show(this, string.Format(Resources.ExportMethodDlg_OkDialog_The_precursor_mass_analyzer_type_is_not_set_to__0__in_Transition_Settings_under_the_Full_Scan_tab, Resources.ExportMethodDlg_OkDialog_TOF)); return; } if (documentExport.Settings.TransitionSettings.FullScan.IsEnabledMsMs && documentExport.Settings.TransitionSettings.FullScan.ProductMassAnalyzer != FullScanMassAnalyzerType.tof) { MessageDlg.Show(this, string.Format(Resources.ExportMethodDlg_OkDialog_The_product_mass_analyzer_type_is_not_set_to__0__in_Transition_Settings_under_the_Full_Scan_tab, Resources.ExportMethodDlg_OkDialog_TOF)); return; } } if (Equals(InstrumentType, ExportInstrumentType.THERMO_Q_EXACTIVE)) { // Check that mass analyzer settings are set to Orbitrap. if (documentExport.Settings.TransitionSettings.FullScan.IsEnabledMs && documentExport.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer != FullScanMassAnalyzerType.orbitrap) { MessageDlg.Show(this, string.Format(Resources.ExportMethodDlg_OkDialog_The_precursor_mass_analyzer_type_is_not_set_to__0__in_Transition_Settings_under_the_Full_Scan_tab, Resources.ExportMethodDlg_OkDialog_Orbitrap)); return; } if (documentExport.Settings.TransitionSettings.FullScan.IsEnabledMsMs && documentExport.Settings.TransitionSettings.FullScan.ProductMassAnalyzer != FullScanMassAnalyzerType.orbitrap) { MessageDlg.Show(this, string.Format(Resources.ExportMethodDlg_OkDialog_The_product_mass_analyzer_type_is_not_set_to__0__in_Transition_Settings_under_the_Full_Scan_tab, Resources.ExportMethodDlg_OkDialog_Orbitrap)); return; } } if (IsDia && _document.Settings.TransitionSettings.FullScan.IsolationScheme.FromResults) { MessageDlg.Show(this, Resources.ExportMethodDlg_OkDialog_The_DIA_isolation_list_must_have_prespecified_windows_); return; } if (!documentExport.HasAllRetentionTimeStandards() && DialogResult.Cancel == MultiButtonMsgDlg.Show( this, TextUtil.LineSeparate( Resources.ExportMethodDlg_OkDialog_The_document_does_not_contain_all_of_the_retention_time_standard_peptides, Resources.ExportMethodDlg_OkDialog_You_will_not_be_able_to_use_retention_time_prediction_with_acquired_results, Resources.ExportMethodDlg_OkDialog_Are_you_sure_you_want_to_continue), Resources.ExportMethodDlg_OkDialog_OK)) { return; } //This will populate _exportProperties if (!ValidateSettings(helper)) { return; } // Full-scan method building ignores CE and DP regression values if (!IsFullScanInstrument) { // Check to make sure CE and DP match chosen instrument, and offer to use // the correct version for the instrument, if not. var predict = documentExport.Settings.TransitionSettings.Prediction; var ce = predict.CollisionEnergy; string ceName = (ce != null ? ce.Name : null); string ceNameDefault = _instrumentType; if (ceNameDefault.IndexOf(' ') != -1) ceNameDefault = ceNameDefault.Substring(0, ceNameDefault.IndexOf(' ')); bool ceInSynch = ceName != null && ceName.StartsWith(ceNameDefault); var dp = predict.DeclusteringPotential; string dpName = (dp != null ? dp.Name : null); string dpNameDefault = _instrumentType; if (dpNameDefault.IndexOf(' ') != -1) dpNameDefault = dpNameDefault.Substring(0, dpNameDefault.IndexOf(' ')); bool dpInSynch = true; if (_instrumentType == ExportInstrumentType.ABI) dpInSynch = dpName != null && dpName.StartsWith(dpNameDefault); else dpNameDefault = null; // Ignored for all other types if ((!ceInSynch && Settings.Default.CollisionEnergyList.Keys.Any(name => name.StartsWith(ceNameDefault))) || (!dpInSynch && Settings.Default.DeclusterPotentialList.Keys.Any(name => name.StartsWith(dpNameDefault)))) { var sb = new StringBuilder(string.Format(Resources.ExportMethodDlg_OkDialog_The_settings_for_this_document_do_not_match_the_instrument_type__0__, _instrumentType)); sb.AppendLine().AppendLine(); if (!ceInSynch) sb.Append(Resources.ExportMethodDlg_OkDialog_Collision_Energy).Append(TextUtil.SEPARATOR_SPACE).AppendLine(ceName); if (!dpInSynch) { sb.Append(Resources.ExportMethodDlg_OkDialog_Declustering_Potential).Append(TextUtil.SEPARATOR_SPACE) .AppendLine(dpName ?? Resources.ExportMethodDlg_OkDialog_None); } sb.AppendLine().Append(Resources.ExportMethodDlg_OkDialog_Would_you_like_to_use_the_defaults_instead); var result = MultiButtonMsgDlg.Show(this, sb.ToString(), MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, true); if (result == DialogResult.Yes) { documentExport = ChangeInstrumentTypeSettings(documentExport, ceNameDefault, dpNameDefault); } else if (result == DialogResult.Cancel) { comboInstrument.Focus(); return; } } } if (documentExport.Settings.TransitionSettings.Prediction.CompensationVoltage != null && !Equals(comboOptimizing.SelectedItem.ToString(), ExportOptimize.COV)) { // Show warning if we don't have results for the highest tune level var highestCoV = documentExport.HighestCompensationVoltageTuning(); string message = null; switch (highestCoV) { case CompensationVoltageParameters.Tuning.fine: { var missing = documentExport.GetMissingCompensationVoltages(highestCoV).ToArray(); if (missing.Any()) { message = TextUtil.LineSeparate( Resources.ExportMethodDlg_OkDialog_You_are_missing_fine_tune_optimized_compensation_voltages_for_the_following_, TextUtil.LineSeparate(missing)); } break; } case CompensationVoltageParameters.Tuning.medium: { message = Resources.ExportMethodDlg_OkDialog_You_are_missing_fine_tune_optimized_compensation_voltages_; var missing = documentExport.GetMissingCompensationVoltages(highestCoV).ToArray(); if (missing.Any()) { message = TextUtil.LineSeparate(message, Resources.ExportMethodDlg_OkDialog_You_are_missing_medium_tune_optimized_compensation_voltages_for_the_following_, TextUtil.LineSeparate(missing)); } break; } case CompensationVoltageParameters.Tuning.rough: { message = Resources.ExportMethodDlg_OkDialog_You_have_only_rough_tune_optimized_compensation_voltages_; var missing = documentExport.GetMissingCompensationVoltages(highestCoV).ToArray(); if (missing.Any()) { message = TextUtil.LineSeparate(message, Resources.ExportMethodDlg_OkDialog_You_are_missing_any_optimized_compensation_voltages_for_the_following_, TextUtil.LineSeparate(missing)); } break; } case CompensationVoltageParameters.Tuning.none: { message = Resources.ExportMethodDlg_OkDialog_Your_document_does_not_contain_compensation_voltage_results__but_compensation_voltage_is_set_under_transition_settings_; break; } } if (message != null) { message = TextUtil.LineSeparate(message, Resources.ExportMethodDlg_OkDialog_Are_you_sure_you_want_to_continue_); if (DialogResult.Cancel == MultiButtonMsgDlg.Show(this, message, Resources.ExportMethodDlg_OkDialog_OK)) { return; } } } if (outputPath == null) { string title = Text; string ext = TextUtil.EXT_CSV; string filter = Resources.ExportMethodDlg_OkDialog_Method_File; switch (_fileType) { case ExportFileType.List: filter = Resources.ExportMethodDlg_OkDialog_Transition_List; ext = ExportInstrumentType.TransitionListExtension(_instrumentType); break; case ExportFileType.IsolationList: filter = Resources.ExportMethodDlg_OkDialog_Isolation_List; ext = ExportInstrumentType.IsolationListExtension(_instrumentType); break; case ExportFileType.Method: title = string.Format(Resources.ExportMethodDlg_OkDialog_Export__0__Method, _instrumentType); ext = ExportInstrumentType.MethodExtension(_instrumentType); break; } using (var dlg = new SaveFileDialog { Title = title, InitialDirectory = Settings.Default.ExportDirectory, OverwritePrompt = true, DefaultExt = ext, Filter = TextUtil.FileDialogFilterAll(filter, ext) }) { if (dlg.ShowDialog(this) == DialogResult.Cancel) { return; } outputPath = dlg.FileName; } } Settings.Default.ExportDirectory = Path.GetDirectoryName(outputPath); // Set ShowMessages property on ExportDlgProperties to true // so that we see the progress dialog during the export process var wasShowMessageValue = _exportProperties.ShowMessages; _exportProperties.ShowMessages = true; try { _exportProperties.ExportFile(_instrumentType, _fileType, outputPath, documentExport, templateName); } catch(UnauthorizedAccessException x) { MessageDlg.ShowException(this, x); _exportProperties.ShowMessages = wasShowMessageValue; return; } catch (IOException x) { MessageDlg.ShowException(this, x); _exportProperties.ShowMessages = wasShowMessageValue; return; } // Successfully completed dialog. Store the values in settings. Settings.Default.ExportInstrumentType = _instrumentType; Settings.Default.ExportMethodStrategy = ExportStrategy.ToString(); Settings.Default.ExportIgnoreProteins = IgnoreProteins; if (IsFullScanInstrument) { Settings.Default.ExportMethodMaxPrec = (MaxTransitions.HasValue ? MaxTransitions.Value.ToString(CultureInfo.InvariantCulture) : null); } else { Settings.Default.ExportMethodMaxTran = (MaxTransitions.HasValue ? MaxTransitions.Value.ToString(CultureInfo.InvariantCulture) : null); } Settings.Default.ExportMethodType = _exportProperties.MethodType.ToString(); if (textPrimaryCount.Visible) Settings.Default.PrimaryTransitionCount = PrimaryCount; if (textDwellTime.Visible) Settings.Default.ExportMethodDwellTime = DwellTime; if (textRunLength.Visible) Settings.Default.ExportMethodRunLength = RunLength; if (panelThermoColumns.Visible) { Settings.Default.ExportThermoEnergyRamp = AddEnergyRamp; Settings.Default.ExportThermoTriggerRef = AddTriggerReference; } if (_fileType == ExportFileType.Method) Settings.Default.ExportMethodTemplateList.SetValue(new MethodTemplateFile(_instrumentType, templateName)); if (cbExportMultiQuant.Visible) Settings.Default.ExportMultiQuant = ExportMultiQuant; if (cbExportEdcMass.Visible) Settings.Default.ExportEdcMass = ExportEdcMass; DialogResult = DialogResult.OK; Close(); }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(textName, out name)) return; if (_existing.Contains(m => !ReferenceEquals(_measuredIon, m) && Equals(name, m.Name))) { helper.ShowTextBoxError(textName, Resources.EditMeasuredIonDlg_OkDialog_The_special_ion__0__already_exists, name); return; } if (radioFragment.Checked) { string cleavage; if (!ValidateAATextBox(helper, textFragment, false, out cleavage)) return; string restrict; if (!ValidateAATextBox(helper, textRestrict, true, out restrict)) return; SequenceTerminus direction = (comboDirection.SelectedIndex == 0 ? SequenceTerminus.C : SequenceTerminus.N); int minAas; if (!helper.ValidateNumberTextBox(textMinAas, MeasuredIon.MIN_MIN_FRAGMENT_LENGTH, MeasuredIon.MAX_MIN_FRAGMENT_LENGTH, out minAas)) return; _measuredIon = new MeasuredIon(name, cleavage, restrict, direction, minAas); } else { var customIon = ValidateCustomIon(name); if (customIon == null) return; _measuredIon = customIon; } DialogResult = DialogResult.OK; }
public void OkDialog() { MessageBoxHelper helper = new MessageBoxHelper(this); string serverName; if (!helper.ValidateNameTextBox(textServerURL, out serverName)) return; Uri uriServer = PanoramaUtil.ServerNameToUri(serverName); if (uriServer == null) { helper.ShowTextBoxError(textServerURL, Resources.EditServerDlg_OkDialog_The_text__0__is_not_a_valid_server_name_, serverName); return; } var panoramaClient = PanoramaClient ?? new WebPanoramaClient(uriServer); using (var waitDlg = new LongWaitDlg { Text = Resources.EditServerDlg_OkDialog_Verifying_server_information }) { try { waitDlg.PerformWork(this, 1000, () => PanoramaUtil.VerifyServerInformation( panoramaClient, Username, Password)); } catch (Exception x) { helper.ShowTextBoxError(textServerURL, x.Message); return; } } Uri updatedUri = panoramaClient.ServerUri ?? uriServer; if (_existing.Contains(server => !ReferenceEquals(_server, server) && Equals(updatedUri, server.URI))) { helper.ShowTextBoxError(textServerURL, Resources.EditServerDlg_OkDialog_The_server__0__already_exists_, uriServer.Host); return; } _server = new Server(updatedUri, Username, Password); DialogResult = DialogResult.OK; }
public TransitionSettings GetTransitionSettings(Form parent) { var helper = new MessageBoxHelper(parent); TransitionSettings settings = SkylineWindow.DocumentUI.Settings.TransitionSettings; // Validate and store filter settings int[] precursorCharges; if (!helper.ValidateNumberListTextBox(txtPrecursorCharges, TransitionGroup.MIN_PRECURSOR_CHARGE, TransitionGroup.MAX_PRECURSOR_CHARGE, out precursorCharges)) return null; precursorCharges = precursorCharges.Distinct().ToArray(); int[] productCharges; if (!helper.ValidateNumberListTextBox(txtIonCharges, Transition.MIN_PRODUCT_CHARGE, Transition.MAX_PRODUCT_CHARGE, out productCharges)) return null; productCharges = productCharges.Distinct().ToArray(); IonType[] types = IonTypes; if (types.Length == 0) { helper.ShowTextBoxError(txtIonTypes, Resources.TransitionSettingsUI_OkDialog_Ion_types_must_contain_a_comma_separated_list_of_ion_types_a_b_c_x_y_z_and_p_for_precursor); return null; } types = types.Distinct().ToArray(); bool exclusionUseDIAWindow = cbExclusionUseDIAWindow.Visible && cbExclusionUseDIAWindow.Checked; var filter = new TransitionFilter(precursorCharges, productCharges, types, settings.Filter.FragmentRangeFirstName, settings.Filter.FragmentRangeLastName, settings.Filter.MeasuredIons, settings.Filter.PrecursorMzWindow, exclusionUseDIAWindow, settings.Filter.AutoSelect); Helpers.AssignIfEquals(ref filter, settings.Filter); // Validate and store library settings double ionMatchTolerance; if (!helper.ValidateDecimalTextBox(txtTolerance, TransitionLibraries.MIN_MATCH_TOLERANCE, TransitionLibraries.MAX_MATCH_TOLERANCE, out ionMatchTolerance)) return null; int ionCount = settings.Libraries.IonCount; if (!helper.ValidateNumberTextBox(txtIonCount, TransitionLibraries.MIN_ION_COUNT, TransitionLibraries.MAX_ION_COUNT, out ionCount)) return null; TransitionLibraryPick pick = (settings.Libraries.Pick != TransitionLibraryPick.none) ? settings.Libraries.Pick : TransitionLibraryPick.all; var libraries = new TransitionLibraries(ionMatchTolerance, ionCount, pick); Helpers.AssignIfEquals(ref libraries, settings.Libraries); return new TransitionSettings(settings.Prediction, filter, libraries, settings.Integration, settings.Instrument, settings.FullScan); }