public UpdateList(ManageResultsDlg dlg, ListBox list) { _dlg = dlg; _list = list; _dlg.InListUpdate = true; _list.BeginUpdate(); }
public UpdateList(ManageResultsDlg dlg, ListBox list) { _dlg = dlg; _list = list; _dlg.InListUpdate = true; _list.BeginUpdate(); }
public void ManageResults() { var documentUI = DocumentUI; if (!documentUI.Settings.HasResults && !documentUI.Settings.HasDocumentLibrary) { MessageDlg.Show(this, Resources.SkylineWindow_ManageResults_The_document_must_contain_mass_spec_data_to_manage_results_); return; } using (ManageResultsDlg dlg = new ManageResultsDlg(this, _libraryManager)) { if (dlg.ShowDialog(this) == DialogResult.OK) { // Remove from the cache chromatogram data to be reimported. This done before changing // anything else to avoid making other changes to the results cause cache changes before // the document is saved. try { ReimportChromatograms(documentUI, dlg.ReimportChromatograms); } catch (Exception) { MessageDlg.Show(this, Resources.SkylineWindow_ManageResults_A_failure_occurred_attempting_to_reimport_results); } // And update the document to reflect real changes to the results structure ModifyDocument(Resources.SkylineWindow_ManageResults_Manage_results, doc => { if (dlg.IsRemoveAllLibraryRuns) { doc = doc.ChangeSettings(doc.Settings.ChangePeptideLibraries(lib => { var libSpecs = new List<LibrarySpec>(lib.LibrarySpecs); var libs = new List<Library>(lib.Libraries); for (int i = 0; i < libSpecs.Count; i++) { if (libSpecs[i].IsDocumentLibrary) { libSpecs.RemoveAt(i); libs.RemoveAt(i); } } return lib.ChangeDocumentLibrary(false) .ChangeLibraries(libSpecs.ToArray(), libs.ToArray()); })); } else if (dlg.LibraryRunsRemovedList.Count > 0) { BiblioSpecLiteLibrary docBlib; if (DocumentUI.Settings.PeptideSettings.Libraries.TryGetDocumentLibrary(out docBlib)) { try { docBlib.DeleteDataFiles(dlg.LibraryRunsRemovedList.ToArray(), this); _libraryManager.ReloadLibrary(this, dlg.DocumentLibrarySpec); } catch (Exception x) { throw new IOException(TextUtil.LineSeparate(Resources.SkylineWindow_ManageResults_Failed_to_remove_library_runs_from_the_document_library_, x.Message)); } } } var results = doc.Settings.MeasuredResults; if (results == null) return doc; var listChrom = new List<ChromatogramSet>(dlg.Chromatograms); if (ArrayUtil.ReferencesEqual(results.Chromatograms, listChrom)) return doc; results = listChrom.Count > 0 ? results.ChangeChromatograms(listChrom.ToArray()) : null; doc = doc.ChangeMeasuredResults(results); doc.ValidateResults(); return doc; }); // Modify document will have closed the streams by now. So, it is safe to delete the files. if (dlg.IsRemoveAllLibraryRuns) { try { string docLibPath = BiblioSpecLiteSpec.GetLibraryFileName(DocumentFilePath); FileEx.SafeDelete(docLibPath); string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(docLibPath); FileEx.SafeDelete(redundantDocLibPath); string docLibCachePath = BiblioSpecLiteLibrary.GetLibraryCachePath(docLibPath); FileEx.SafeDelete(docLibCachePath); } catch (FileEx.DeleteException deleteException) { MessageDlg.ShowException(this, deleteException); } } } } }