public static bool ValidateAdductListTextBox(MessageBoxHelper helper, TextBox control, bool proteomic,
                                                     int minCharge, int maxCharge, out Adduct[] val)
        {
            val = proteomic ?
                  ArrayUtil.Parse(control.Text, Adduct.FromStringAssumeProtonated, TextUtil.SEPARATOR_CSV, new Adduct[0]) : // Treat "1" as protonated, proteomic [M+H]
                  ArrayUtil.Parse(control.Text, Adduct.FromStringAssumeChargeOnly, TextUtil.SEPARATOR_CSV, new Adduct[0]);  // Treat "1" as [M+]
            if (val.Length > 0 && val.All(adduct => TransitionFilter.IsChargeInRange(adduct, minCharge, maxCharge, proteomic)))
            {
                return(true);
            }

            string message;

            if (proteomic)
            {
                message = Resources.TransitionSettingsControl_ValidateAdductListTextBox__0__must_contain_a_comma_separated_list_of_integers_describing_charge_states_between__1__and__2__;
            }
            else
            {
                message = Resources
                          .MessageBoxHelper_ValidateAdductListTextBox__0__must_contain_a_comma_separated_list_of_adducts_or_integers_describing_charge_states_with_absolute_values_from__1__to__2__;
            }
            helper.ShowTextBoxError(control, message, null, minCharge, maxCharge);
            val = new Adduct[0];
            return(false);
        }
        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));
        }
        public TransitionSettingsControl(IModifyDocumentContainer documentContainer)
        {
            _documentContainer = documentContainer;
            InitializeComponent();

            foreach (string item in TransitionFilter.GetStartFragmentFinderLabels())
            {
                comboRangeFrom.Items.Add(item);
            }
            foreach (string item in TransitionFilter.GetEndFragmentFinderLabels())
            {
                comboRangeTo.Items.Add(item);
            }

            SetFields(_documentContainer.Document.Settings.TransitionSettings);
            PeptideIonTypes        = PeptideIonTypes.Union(new[] { IonType.precursor, IonType.y }).ToArray(); // Add p, y if not already set
            InitialPeptideIonTypes = PeptideIonTypes.ToArray();
        }
Example #4
0
        private void Validate()
        {
            TransitionFilter.ValidateCharges(Resources.TransitionFilter_ProductCharges_Product_ion_charges, new[] { Charge },
                                             Transition.MIN_PRODUCT_CHARGE, Transition.MAX_PRODUCT_CHARGE);

            if (IsFragment)
            {
                if (string.IsNullOrEmpty(Fragment))
                {
                    throw new InvalidDataException(Resources.MeasuredIon_Validate_Special_fragment_ions_must_have_at_least_one_fragmentation_residue);
                }
                AminoAcid.ValidateAAList(Fragment);
                if (!string.IsNullOrEmpty(Restrict))
                {
                    AminoAcid.ValidateAAList(Restrict);
                }
                if (!Terminus.HasValue)
                {
                    throw new InvalidDataException(Resources.MeasuredIon_Validate_Special_fragment_ions_must_specify_the_terminal_side_of_the_amino_acid_residue_on_which_fragmentation_occurs);
                }
                if (MIN_MIN_FRAGMENT_LENGTH > MinFragmentLength || MinFragmentLength > MAX_MIN_FRAGMENT_LENGTH)
                {
                    throw new InvalidDataException(string.Format(Resources.MeasuredIon_Validate_The_minimum_length__0__must_be_between__1__and__2__,
                                                                 MinFragmentLength, MIN_MIN_FRAGMENT_LENGTH, MAX_MIN_FRAGMENT_LENGTH));
                }
            }
            else
            {
                if (SettingsCustomIon.MonoisotopicMass == 0 || SettingsCustomIon.AverageMass == 0)
                {
                    throw new InvalidDataException(Resources.MeasuredIon_Validate_Reporter_ions_must_specify_a_formula_or_valid_monoisotopic_and_average_masses);
                }
                if (SettingsCustomIon.MonoisotopicMass < MIN_REPORTER_MASS || SettingsCustomIon.AverageMass < MIN_REPORTER_MASS)
                {
                    throw new InvalidDataException(string.Format(Resources.MeasuredIon_Validate_Reporter_ion_masses_must_be_greater_than_or_equal_to__0__, MIN_REPORTER_MASS));
                }
                if (SettingsCustomIon.MonoisotopicMass > MAX_REPORTER_MASS || SettingsCustomIon.AverageMass > MAX_REPORTER_MASS)
                {
                    throw new InvalidDataException(string.Format(Resources.MeasuredIon_Validate_Reporter_ion_masses_must_be_less_than_or_equal_to__0__, MAX_REPORTER_MASS));
                }
            }
        }
Example #5
0
        private void comboRangeTo_SelectedIndexChanged(object sender, EventArgs e)
        {
            // If nothing is checked yet, start with what is in the settings
            if (!radioAll.Checked && !radioAllAndFiltered.Checked && !radioFiltered.Checked)
            {
                switch (Libraries.Pick)
                {
                case TransitionLibraryPick.all:
                    radioAll.Checked = true;
                    break;

                case TransitionLibraryPick.all_plus:
                    radioAllAndFiltered.Checked = true;
                    break;

                default:
                    radioFiltered.Checked = true;
                    break;
                }
            }

            string fragmentRangeLastLabel = comboRangeTo.SelectedItem.ToString();
            string fragmentRangeLastName  = TransitionFilter.GetEndFragmentNameFromLabel(fragmentRangeLastLabel);
            var    countFinder            = TransitionFilter.GetEndFragmentFinder(fragmentRangeLastName) as IEndCountFragmentFinder;

            if (countFinder != null)
            {
                textIonCount.Text = countFinder.Count.ToString(LocalizationHelper.CurrentCulture);
                if (!radioAllAndFiltered.Checked)
                {
                    radioAll.Checked = true;
                }
                radioFiltered.Enabled = false;
            }
            else
            {
                textIonCount.Text     = Libraries.IonCount.ToString(LocalizationHelper.CurrentCulture);
                radioFiltered.Enabled = true;
            }
        }
Example #6
0
        public TransitionSettings GetTransitionSettings(Form parent)
        {
            var helper = new MessageBoxHelper(parent);
            TransitionSettings settings = _documentContainer.Document.Settings.TransitionSettings;

            // Validate and store filter settings
            Adduct[] peptidePrecursorCharges;
            if (!ValidateAdductListTextBox(helper, txtPeptidePrecursorCharges, true, TransitionGroup.MIN_PRECURSOR_CHARGE, TransitionGroup.MAX_PRECURSOR_CHARGE, out peptidePrecursorCharges))
            {
                return(null);
            }
            peptidePrecursorCharges = peptidePrecursorCharges.Distinct().ToArray();

            Adduct[] peptideProductCharges;
            if (!ValidateAdductListTextBox(helper, txtPrecursorIonCharges, true, Transition.MIN_PRODUCT_CHARGE, Transition.MAX_PRODUCT_CHARGE, out peptideProductCharges))
            {
                return(null);
            }
            peptideProductCharges = peptideProductCharges.Distinct().ToArray();

            IonType[] peptideIonTypes = PeptideIonTypes;
            if (peptideIonTypes.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);
            }
            peptideIonTypes = peptideIonTypes.Distinct().ToArray();

            bool exclusionUseDIAWindow = cbExclusionUseDIAWindow.Visible && cbExclusionUseDIAWindow.Checked;
            var  filter = new TransitionFilter(peptidePrecursorCharges, peptideProductCharges, peptideIonTypes,
                                               settings.Filter.SmallMoleculePrecursorAdducts, settings.Filter.SmallMoleculeFragmentAdducts, settings.Filter.SmallMoleculeIonTypes,
                                               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 minIonCount = settings.Libraries.MinIonCount;

            if (string.IsNullOrEmpty(txtMinIonCount.Text))
            {
                minIonCount = 0;
            }
            else if (!helper.ValidateNumberTextBox(txtMinIonCount, 0, TransitionLibraries.MAX_ION_COUNT, out minIonCount))
            {
                return(null);
            }

            int ionCount = settings.Libraries.IonCount;

            if (!helper.ValidateNumberTextBox(txtIonCount, TransitionLibraries.MIN_ION_COUNT, TransitionLibraries.MAX_ION_COUNT, out ionCount))
            {
                return(null);
            }

            if (minIonCount > ionCount)
            {
                helper.ShowTextBoxError(txtIonCount, string.Format(Resources.TransitionLibraries_DoValidate_Library_ion_count_value__0__must_not_be_less_than_min_ion_count_value__1__,
                                                                   ionCount, minIonCount));
                return(null);
            }

            TransitionLibraryPick pick = settings.Libraries.Pick != TransitionLibraryPick.none ? settings.Libraries.Pick : TransitionLibraryPick.all;
            var libraries = new TransitionLibraries(ionMatchTolerance, minIonCount, ionCount, pick);

            Helpers.AssignIfEquals(ref libraries, settings.Libraries);

            return(new TransitionSettings(settings.Prediction, filter, libraries, settings.Integration, settings.Instrument, settings.FullScan));
        }
Example #7
0
        private bool UpdateFullScanSettings()
        {
            var helper = new MessageBoxHelper(this);

            // Validate and store MS1 full-scan settings

            // If high resolution MS1 filtering is enabled, make sure precursor m/z type
            // is monoisotopic and isotope enrichments are set
            var precursorIsotopes     = FullScanSettingsControl.PrecursorIsotopesCurrent;
            var precursorAnalyzerType = FullScanSettingsControl.PrecursorMassAnalyzer;
            var precursorMassType     = TransitionSettings.Prediction.PrecursorMassType;

            if (precursorIsotopes == FullScanPrecursorIsotopes.None)
            {
                if (WorkflowType != Workflow.dia)
                {
                    MessageDlg.Show(this, Resources.ImportPeptideSearchDlg_UpdateFullScanSettings_Full_scan_MS1_filtering_must_be_enabled_in_order_to_import_a_peptide_search_);
                    return(false);
                }
                else if (FullScanSettingsControl.AcquisitionMethod == FullScanAcquisitionMethod.None)
                {
                    MessageDlg.Show(this, Resources.ImportPeptideSearchDlg_UpdateFullScanSettings_Full_scan_MS1_or_MS_MS_filtering_must_be_enabled_in_order_to_import_a_peptide_search_);
                    return(false);
                }
            }
            else if (precursorAnalyzerType != FullScanMassAnalyzerType.qit)
            {
                precursorMassType = MassType.Monoisotopic;
                if (FullScanSettingsControl.Enrichments == null)
                {
                    MessageDlg.Show(GetParentForm(this), Resources.TransitionSettingsUI_OkDialog_Isotope_enrichment_settings_are_required_for_MS1_filtering_on_high_resolution_mass_spectrometers);
                    return(false);
                }
            }

            if (FullScanSettingsControl.IsolationScheme == null && FullScanSettingsControl.AcquisitionMethod == FullScanAcquisitionMethod.DIA)
            {
                MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_An_isolation_scheme_is_required_to_match_multiple_precursors);
                return(false);
            }

            TransitionFilter filter = TransitionSettings.Filter;

            if (FullScanSettingsControl.PrecursorChargesTextBox.Visible)
            {
                Adduct[] precursorCharges;
                if (!TransitionSettingsControl.ValidateAdductListTextBox(helper, FullScanSettingsControl.PrecursorChargesTextBox, true, TransitionGroup.MIN_PRECURSOR_CHARGE, TransitionGroup.MAX_PRECURSOR_CHARGE, out precursorCharges))
                {
                    return(false);
                }
                precursorCharges = precursorCharges.Distinct().ToArray();
                FullScanSettingsControl.PrecursorChargesString = TransitionFilter.AdductListToString(precursorCharges);
                filter = TransitionSettings.Filter.ChangePeptidePrecursorCharges(precursorCharges);
            }
            if (WorkflowType == Workflow.dda && !filter.PeptideIonTypes.Contains(IonType.precursor))
            {
                filter = filter.ChangePeptideIonTypes(new[] { IonType.precursor });
            }
            if (!filter.AutoSelect)
            {
                filter = filter.ChangeAutoSelect(true);
            }
            Helpers.AssignIfEquals(ref filter, TransitionSettings.Filter);

            if (FullScanSettingsControl.IsDIA() && filter.ExclusionUseDIAWindow)
            {
                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_);
                    return(false);
                }
                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_);
                    return(false);
                }
            }

            TransitionFullScan fullScan;

            if (!FullScanSettingsControl.ValidateFullScanSettings(helper, out fullScan))
            {
                return(false);
            }

            Helpers.AssignIfEquals(ref fullScan, TransitionSettings.FullScan);

            var prediction = TransitionSettings.Prediction.ChangePrecursorMassType(precursorMassType);

            Helpers.AssignIfEquals(ref prediction, TransitionSettings.Prediction);

            TransitionSettings settings;

            try
            {
                settings = new TransitionSettings(prediction, filter,
                                                  TransitionSettings.Libraries, TransitionSettings.Integration, TransitionSettings.Instrument, fullScan);
            }
            catch (Exception x)
            {
                MessageDlg.Show(this, x.Message);
                return(false);
            }

            // Did user change the "use spectral libary ion mobility" values?
            PeptidePrediction updatedPeptidePrediction;
            bool peptidePredictionChanged = false;

            try
            {
                updatedPeptidePrediction =
                    FullScanSettingsControl.UseSpectralLibraryIonMobilityValuesControl.ValidateNewSettings(true);
                if (updatedPeptidePrediction == null)
                {
                    return(false);
                }

                peptidePredictionChanged = !Equals(Document.Settings.PeptideSettings.Prediction, updatedPeptidePrediction);
            }
            catch (Exception)
            {
                return(false);
            }


            // Only update, if anything changed
            if (Equals(settings, TransitionSettings) && !peptidePredictionChanged)
            {
                return(true);
            }

            ModifyDocumentNoUndo(doc => doc.ChangeSettings(doc.Settings.ChangeTransitionSettings(settings).ChangePeptideSettings(doc.Settings.PeptideSettings.ChangePrediction(updatedPeptidePrediction))));
            _fullScanSettingsChanged = true;
            return(true);
        }
Example #8
0
        public TransitionSettingsUI(SkylineWindow parent)
        {
            InitializeComponent();

            // Populate the fragment finder combo boxes
            foreach (string item in TransitionFilter.GetStartFragmentFinderLabels())
            {
                comboRangeFrom.Items.Add(item);
            }
            foreach (string item in TransitionFilter.GetEndFragmentFinderLabels())
            {
                comboRangeTo.Items.Add(item);
            }

            _parent             = parent;
            _transitionSettings = _parent.DocumentUI.Settings.TransitionSettings;

            // Initialize prediction settings
            comboPrecursorMass.SelectedItem = Prediction.PrecursorMassType.GetLocalizedString();
            comboIonMass.SelectedItem       = Prediction.FragmentMassType.GetLocalizedString();

            _driverCE = new SettingsListComboDriver <CollisionEnergyRegression>(comboCollisionEnergy,
                                                                                Settings.Default.CollisionEnergyList);
            string sel = (Prediction.CollisionEnergy == null ? null : Prediction.CollisionEnergy.Name);

            _driverCE.LoadList(sel);

            _driverDP = new SettingsListComboDriver <DeclusteringPotentialRegression>(comboDeclusterPotential,
                                                                                      Settings.Default.DeclusterPotentialList);
            sel = (Prediction.DeclusteringPotential == null ? null : Prediction.DeclusteringPotential.Name);
            _driverDP.LoadList(sel);

            _driverCoV = new SettingsListComboDriver <CompensationVoltageParameters>(comboCompensationVoltage,
                                                                                     Settings.Default.CompensationVoltageList);
            _driverCoV.LoadList(Prediction.CompensationVoltage == null ? null : Prediction.CompensationVoltage.Name);

            _driverOptimizationLibrary = new SettingsListComboDriver <OptimizationLibrary>(comboOptimizationLibrary,
                                                                                           Settings.Default.OptimizationLibraryList);
            _driverOptimizationLibrary.LoadList(Prediction.OptimizedLibrary == null ? null : Prediction.OptimizedLibrary.Name);

            if (Prediction.OptimizedMethodType == OptimizedMethodType.None)
            {
                comboOptimizeType.SelectedIndex = 0;
            }
            else
            {
                cbUseOptimized.Checked         = true;
                comboOptimizeType.SelectedItem = Prediction.OptimizedMethodType.GetLocalizedString();
            }

            // Initialize filter settings
            textPrecursorCharges.Text   = Filter.PrecursorCharges.ToArray().ToString(", "); // Not L10N? Internationalization of comma?
            textIonCharges.Text         = Filter.ProductCharges.ToArray().ToString(", ");   // Not L10N? Internationalization of comma?
            textIonTypes.Text           = TransitionFilter.ToStringIonTypes(Filter.IonTypes, true);
            comboRangeFrom.SelectedItem = Filter.FragmentRangeFirst.Label;
            comboRangeTo.SelectedItem   = Filter.FragmentRangeLast.Label;
            textExclusionWindow.Text    = Filter.PrecursorMzWindow != 0
                                           ? Filter.PrecursorMzWindow.ToString(LocalizationHelper.CurrentCulture)
                                           : string.Empty;
            cbExclusionUseDIAWindow.Checked = Filter.ExclusionUseDIAWindow;
            cbAutoSelect.Checked            = Filter.AutoSelect;

            _driverIons = new MeasuredIonListBoxDriver(listAlwaysAdd, Settings.Default.MeasuredIonList);
            _driverIons.LoadList(Filter.MeasuredIons);

            // Initialize library settings
            cbLibraryPick.Checked = (Libraries.Pick != TransitionLibraryPick.none);
            panelPick.Visible     = cbLibraryPick.Checked;
            textTolerance.Text    = Libraries.IonMatchTolerance.ToString(LocalizationHelper.CurrentCulture);
            textIonCount.Text     = Libraries.IonCount.ToString(LocalizationHelper.CurrentCulture);
            if (Libraries.Pick == TransitionLibraryPick.filter)
            {
                radioFiltered.Checked = true;
            }
            else if (Libraries.Pick == TransitionLibraryPick.all_plus)
            {
                radioAllAndFiltered.Checked = true;
            }

            // Initialize instrument settings
            textMinMz.Text            = Instrument.MinMz.ToString(LocalizationHelper.CurrentCulture);
            textMaxMz.Text            = Instrument.MaxMz.ToString(LocalizationHelper.CurrentCulture);
            cbDynamicMinimum.Checked  = Instrument.IsDynamicMin;
            textMzMatchTolerance.Text = Instrument.MzMatchTolerance.ToString(LocalizationHelper.CurrentCulture);
            if (Instrument.MaxTransitions.HasValue)
            {
                textMaxTrans.Text = Instrument.MaxTransitions.Value.ToString(LocalizationHelper.CurrentCulture);
            }
            if (Instrument.MaxInclusions.HasValue)
            {
                textMaxInclusions.Text = Instrument.MaxInclusions.Value.ToString(LocalizationHelper.CurrentCulture);
            }
            if (Instrument.MinTime.HasValue)
            {
                textMinTime.Text = Instrument.MinTime.Value.ToString(LocalizationHelper.CurrentCulture);
            }
            if (Instrument.MaxTime.HasValue)
            {
                textMaxTime.Text = Instrument.MaxTime.Value.ToString(LocalizationHelper.CurrentCulture);
            }

            // Initialize full-scan settings
            FullScanSettingsControl = new FullScanSettingsControl(_parent)
            {
                Anchor   = (AnchorStyles.Top | AnchorStyles.Left),
                Location = new Point(0, 0),
                Size     = new Size(363, 491)
            };
            FullScanSettingsControl.IsolationSchemeChangedEvent += IsolationSchemeChanged;
            tabFullScan.Controls.Add(FullScanSettingsControl);

            // VISUAL:
            // - Store the distance between the cbExclusionDIAWindow and the lower end of the box (to use as margin later)
            // - Shift the cbExclusionDIAWindow down (it is only higher in the designer for better manipulation)
            _lower_margin = groupBox1.Height - textExclusionWindow.Location.Y - textExclusionWindow.Height;
            int pixelShift = cbExclusionUseDIAWindow.Location.Y - lbPrecursorMzWindow.Location.Y;

            cbExclusionUseDIAWindow.Location = new Point(cbExclusionUseDIAWindow.Location.X, cbExclusionUseDIAWindow.Location.Y - pixelShift);

            DoIsolationSchemeChanged();
        }
Example #9
0
        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);

            // 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 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);
        }