/// <summary> /// Opens a dialog for tuning the selected isotope concentration to find the /// value that produces a theoretical isotopic distribution that best fits /// the observed peak list. /// Implementation of <see cref="TuneConcentrationCommand" />. /// </summary> private void TuneConcentration() { var selectedProportion = this.SelectedElement.IsotopeRatios.FirstOrDefault(ir => ir.IsSelected); if (selectedProportion == null) { // There was not a selected isotope proportion. this.dialogService.MessageBox("Please select an isotope proportion to manipulate."); return; } // Set up concentration tuner. var concentrationTuner = new IsotopicConcentrationTuner { Mass = this.Mass, Charge = this.Charge, Element = this.SelectedElement.Atom, IsotopeIndex = selectedProportion.IsotopeIndex, ObservedPeaks = this.ObservedPeaks.Select(peakDataPoint => new Peak(peakDataPoint.Item.X, peakDataPoint.Item.Y)).ToList(), RelativeIntensityThreshold = this.RelativeIntensityThreshold, Tolerance = new Tolerance(this.ToleranceValue, this.ToleranceUnit) }; var concentrationTunerViewModel = new IsotopicConcentrationTunerViewModel(concentrationTuner); this.dialogService.OpenIsotopicConcentrationTuner(concentrationTunerViewModel); }
/// <summary> /// Opens a window displaying the isotopic profile tuner tool. /// </summary> /// <param name="viewModel">The view model for the window.</param> public void OpenIsotopicConcentrationTuner(IsotopicConcentrationTunerViewModel viewModel) { var dialog = new IsotopicConcentrationTuner { DataContext = viewModel }; dialog.ShowDialog(); }
/// <summary> /// Initializes a new instance of the <see cref="IsotopicConcentrationTunerViewModel" /> class. /// </summary> public IsotopicConcentrationTunerViewModel(IsotopicConcentrationTuner tuner) { this.tuner = tuner ?? new IsotopicConcentrationTuner(); RunTuningCommand = ReactiveCommand.CreateFromTask(async _ => await RunTuning()); // Set default values StatusMessage = "Running..."; StepSize = 0.2; MaxConcentration = this.tuner.MaxConcentration; Title = string.Format( "Tune {0}{1}", this.tuner.Element.Code, this.tuner.Element.NominalMass + this.tuner.IsotopeIndex); }