Example #1
0
 public ImportDocResultsSettings(ImportDocResultsDlg dlg) : this(dlg.Action, dlg.IsMergePeptides)
 {
 }
Example #2
0
        public void ImportFiles(params string[] filePaths)
        {
            var resultsAction = MeasuredResults.MergeAction.remove;
            var mergePeptides = false;
            if (HasResults(filePaths))
            {
                using (var dlgResults = new ImportDocResultsDlg(!string.IsNullOrEmpty(DocumentFilePath)))
                {
                    if (dlgResults.ShowDialog(this) != DialogResult.OK)
                        return;
                    resultsAction = dlgResults.Action;
                    mergePeptides = dlgResults.IsMergePeptides;
                }
            }
            SrmTreeNode nodeSel = SequenceTree.SelectedNode as SrmTreeNode;
            IdentityPath selectPath = null;

            var docCurrent = DocumentUI;
            SrmDocument docNew = null;
            using (var longWaitDlg = new LongWaitDlg(this)
                {
                    Text = Resources.SkylineWindow_ImportFiles_Import_Skyline_document_data,
                })
            {
                longWaitDlg.PerformWork(this, 1000, longWaitBroker =>
                    docNew = ImportFiles(docCurrent,
                                         longWaitBroker,
                                         filePaths,
                                         resultsAction,
                                         mergePeptides,
                                         nodeSel != null ? nodeSel.Path : null,
                                         out selectPath));

                if (docNew == null || ReferenceEquals(docNew, docCurrent))
                    return;

                if (longWaitDlg.IsDocumentChanged(docCurrent))
                {
                    MessageDlg.Show(this, Resources.SkylineWindow_ImportFasta_Unexpected_document_change_during_operation);
                    return;
                }
            }

            ModifyDocument(Resources.SkylineWindow_ImportFiles_Import_Skyline_document_data, doc =>
            {
                docNew.ValidateResults();
                if (!ReferenceEquals(doc, docCurrent))
                    throw new InvalidDataException(Resources.SkylineWindow_ImportFasta_Unexpected_document_change_during_operation);
                return docNew;
            });

            if (selectPath != null)
                SequenceTree.SelectedPath = selectPath;
        }