public void OkDialog() { var helper = new MessageBoxHelper(this); var isotopeModification = _driverIsotopeModification.SelectedItem; if (isotopeModification == null) { helper.ShowTextBoxError(comboIsotopeModification, Resources.MessageBoxHelper_ValidateNameTextBox__0__cannot_be_empty); return; } lock (SkylineWindow.GetDocumentChangeLock()) { var originalDocument = SkylineWindow.Document; var deferSettingsChangeDoc = originalDocument.BeginDeferSettingsChanges(); var globalStaticMods = Settings.Default.StaticModList.ToList(); var globalIsotopeMods = Settings.Default.HeavyModList.ToList(); var newDocument = deferSettingsChangeDoc; var simplePermutation = SimplePermutation; using (var longWaitDlg = new LongWaitDlg() { Text = Resources.PermuteIsotopeModificationsDlg_OkDialog_Permuting_Isotope_Modifications }) { longWaitDlg.PerformWork(this, 1000, progressMonitor => { var isotopePermuter = new IsotopeModificationPermuter(isotopeModification, simplePermutation, IsotopeLabelType.heavy, globalStaticMods, globalIsotopeMods); newDocument = isotopePermuter.PermuteIsotopeModifications(progressMonitor, newDocument); if (!ReferenceEquals(newDocument, deferSettingsChangeDoc)) { var settingsChangeMonitor = new SrmSettingsChangeMonitor(progressMonitor, Resources.PermuteIsotopeModificationsDlg_OkDialog_Updating_settings); newDocument = newDocument.EndDeferSettingsChanges(originalDocument, settingsChangeMonitor); } }); if (longWaitDlg.IsCanceled) { return; } } if (!ReferenceEquals(newDocument, deferSettingsChangeDoc)) { SkylineWindow.ModifyDocument(Resources.PermuteIsotopeModificationsDlg_OkDialog_Permute_isotope_modifications, doc => { // This will be true because we have acquired the lock on SkylineWindow.DocumentChangeLock() Assume.IsTrue(ReferenceEquals(doc, originalDocument)); return(newDocument); }, docPair => GetAuditLogEntry(docPair, isotopeModification, simplePermutation)); } DialogResult = DialogResult.OK; } }