Ejemplo n.º 1
0
 public void GetDriftTimesFromResults()
 {
     try
     {
         var  driftTable             = new MeasuredDriftTimeTable(gridMeasuredDriftTimes, MeasuredDriftTimeSequence.TargetResolver);
         bool useHighEnergyOffset    = cbOffsetHighEnergySpectra.Checked;
         var  tempDriftTimePredictor = new IonMobilityPredictor(@"tmp", driftTable.GetTableMeasuredIonMobility(useHighEnergyOffset, Units), null, null, IonMobilityWindowWidthCalculator.IonMobilityPeakWidthType.resolving_power, 30, 0, 0);
         using (var longWaitDlg = new LongWaitDlg
         {
             Text = Resources.EditDriftTimePredictorDlg_GetDriftTimesFromResults_Finding_ion_mobility_values_for_peaks,
             Message = string.Empty,
             ProgressValue = 0
         })
         {
             longWaitDlg.PerformWork(this, 100, broker =>
             {
                 tempDriftTimePredictor = tempDriftTimePredictor.ChangeMeasuredIonMobilityValuesFromResults(Program.MainWindow.Document, Program.MainWindow.DocumentFilePath, useHighEnergyOffset, broker);
             });
             if (!longWaitDlg.IsCanceled && tempDriftTimePredictor != null)
             {
                 // Set display units based on what we found in the data
                 UpdateMeasuredDriftTimesControl(tempDriftTimePredictor);
             }
         }
     }
     catch (Exception ex)
     {
         MessageDlg.ShowException(this, ex);
     }
 }
 public void GetDriftTimesFromResults()
 {
     try
     {
         var driftTable             = new MeasuredDriftTimeTable(gridMeasuredDriftTimes);
         var tempDriftTimePredictor = new DriftTimePredictor("tmp", driftTable.GetTableMeasuredDriftTimes(cbOffsetHighEnergySpectra.Checked), null, null, 30); // Not L10N
         using (var longWaitDlg = new LongWaitDlg
         {
             Text = Resources.EditDriftTimePredictorDlg_btnGenerateFromDocument_Click_Finding_drift_time_values_for_peaks,
             Message = string.Empty,
             ProgressValue = 0
         })
         {
             longWaitDlg.PerformWork(this, 100, broker =>
             {
                 tempDriftTimePredictor = tempDriftTimePredictor.ChangeMeasuredDriftTimesFromResults(Program.MainWindow.Document, Program.MainWindow.DocumentFilePath, broker);
             });
             if (!longWaitDlg.IsCanceled && tempDriftTimePredictor != null)
             {
                 UpdateMeasuredDriftTimesControl(tempDriftTimePredictor);
             }
         }
     }
     catch (Exception ex)
     {
         MessageDlg.ShowException(this, ex);
     }
 }
Ejemplo n.º 3
0
        public void OkDialog(bool forceOverwrite = false)
        {
            var helper = new MessageBoxHelper(this);

            var driftTable = new MeasuredDriftTimeTable(gridMeasuredDriftTimes, MeasuredDriftTimeSequence.TargetResolver);

            var table = new ChargeRegressionTable(gridRegression);

            string name;

            if (!helper.ValidateNameTextBox(textName, out name))
            {
                return;
            }

            if (_existing.Contains(r => !Equals(_predictor, r) && Equals(name, r.Name)) && !forceOverwrite)
            {
                if (MessageBox.Show(this,
                                    TextUtil.LineSeparate(string.Format(Resources.EditDriftTimePredictorDlg_OkDialog_An_ion_mobility_predictor_with_the_name__0__already_exists_, name),
                                                          Resources.EditDriftTimePredictorDlg_OkDialog_Do_you_want_to_change_it_),
                                    Program.Name, MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }
            }
            if (driftTable.GetTableMeasuredIonMobility(cbOffsetHighEnergySpectra.Checked, Units) == null) // Some error detected in the measured drift times table
            {
                return;
            }
            if (table.GetTableChargeRegressionLines() == null) // Some error detected in the charged regression lines table
            {
                return;
            }
            double resolvingPower = 0;
            double widthAtDt0     = 0;
            double widthAtDtMax   = 0;

            IonMobilityWindowWidthCalculator.IonMobilityPeakWidthType peakWidthType;
            if (cbLinear.Checked)
            {
                if (!helper.ValidateDecimalTextBox(textWidthAtDt0, out widthAtDt0))
                {
                    return;
                }
                if (!helper.ValidateDecimalTextBox(textWidthAtDtMax, out widthAtDtMax))
                {
                    return;
                }
                var errmsg = ValidateWidth(widthAtDt0);
                if (errmsg != null)
                {
                    helper.ShowTextBoxError(textWidthAtDt0, errmsg);
                    return;
                }
                errmsg = ValidateWidth(widthAtDtMax);
                if (errmsg != null)
                {
                    helper.ShowTextBoxError(textWidthAtDtMax, errmsg);
                    return;
                }
                peakWidthType = IonMobilityWindowWidthCalculator.IonMobilityPeakWidthType.linear_range;
            }
            else
            {
                if (!helper.ValidateDecimalTextBox(textResolvingPower, out resolvingPower))
                {
                    return;
                }

                var errmsg = ValidateResolvingPower(resolvingPower);
                if (errmsg != null)
                {
                    helper.ShowTextBoxError(textResolvingPower, errmsg);
                    return;
                }
                peakWidthType = IonMobilityWindowWidthCalculator.IonMobilityPeakWidthType.resolving_power;
            }

            if ((comboLibrary.SelectedIndex > 0) && (comboLibrary.SelectedItem.ToString().Length == 0))
            {
                MessageBox.Show(this, Resources.EditDriftTimePredictorDlg_OkDialog_Drift_time_prediction_requires_an_ion_mobility_library_,
                                Program.Name);
                comboLibrary.Focus();
                return;
            }
            var ionMobilityLibrary = _driverIonMobilityLibraryListComboDriver.SelectedItem;

            IonMobilityPredictor predictor =
                new IonMobilityPredictor(name, driftTable.GetTableMeasuredIonMobility(cbOffsetHighEnergySpectra.Checked, Units),
                                         ionMobilityLibrary, table.GetTableChargeRegressionLines(), peakWidthType, resolvingPower, widthAtDt0, widthAtDtMax);

            _predictor = predictor;

            DialogResult = DialogResult.OK;
        }
        public void OkDialog()
        {
            var helper = new MessageBoxHelper(this);

            var driftTable = new MeasuredDriftTimeTable(gridMeasuredDriftTimes);

            var table = new ChargeRegressionTable(gridRegression);

            string name;

            if (!helper.ValidateNameTextBox(textName, out name))
            {
                return;
            }

            if (_existing.Contains(r => !ReferenceEquals(_predictor, r) && Equals(name, r.Name)))
            {
                if (MessageBox.Show(this,
                                    TextUtil.LineSeparate(string.Format(Resources.EditDriftTimePredictorDlg_OkDialog_A_drift_time_predictor_with_the_name__0__already_exists_, name),
                                                          Resources.EditDriftTimePredictorDlg_OkDialog_Do_you_want_to_change_it_),
                                    Program.Name, MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }
            }
            if (driftTable.GetTableMeasuredDriftTimes(cbOffsetHighEnergySpectra.Checked) == null) // Some error detected in the measured drift times table
            {
                return;
            }
            if (table.GetTableChargeRegressionLines() == null) // Some error detected in the charged regression lines table
            {
                return;
            }
            double resolvingPower;

            if (!helper.ValidateDecimalTextBox(textResolvingPower, out resolvingPower))
            {
                return;
            }

            var errmsg = ValidateResolvingPower(resolvingPower);

            if (errmsg != null)
            {
                helper.ShowTextBoxError(textResolvingPower, errmsg);
                return;
            }

            if ((comboLibrary.SelectedIndex > 0) && (comboLibrary.SelectedItem.ToString().Length == 0))
            {
                MessageBox.Show(this, Resources.EditDriftTimePredictorDlg_OkDialog_Drift_time_prediction_requires_an_ion_mobility_library_,
                                Program.Name);
                comboLibrary.Focus();
                return;
            }
            var ionMobilityLibrary = _driverIonMobilityLibraryListComboDriver.SelectedItem;

            DriftTimePredictor predictor =
                new DriftTimePredictor(name, driftTable.GetTableMeasuredDriftTimes(cbOffsetHighEnergySpectra.Checked),
                                       ionMobilityLibrary, table.GetTableChargeRegressionLines(), resolvingPower);

            _predictor = predictor;

            DialogResult = DialogResult.OK;
        }