Beispiel #1
0
        public void RemovePeaks(SrmDocument.DOCUMENT_TYPE docType, BoundDataGridView dataGridView)
        {
            var parent        = FormUtil.FindTopLevelOwner(dataGridView);
            var selectedPeaks = GetSelectedPeaks(dataGridView).Distinct().ToArray();

            if (selectedPeaks.Length == 0)
            {
                MessageDlg.Show(parent, Resources.RemovePeaksAction_RemovePeaks_No_peaks_are_selected);
                return;
            }

            var    lookup  = selectedPeaks.ToLookup(tuple => tuple.Item1, tuple => tuple.Item2).ToArray();
            string message = GetConfirmRemoveMessage(docType, selectedPeaks.Length, lookup.Length);

            if (MultiButtonMsgDlg.Show(parent, message, MultiButtonMsgDlg.BUTTON_OK) != DialogResult.OK)
            {
                return;
            }

            var skylineWindow = GetSkylineWindow(dataGridView);

            lock (skylineWindow.GetDocumentChangeLock())
            {
                skylineWindow.ModifyDocument(Resources.RemovePeaksAction_RemovePeaks_Remove_peaks,
                                             doc =>
                {
                    var longOperationRunner = new LongOperationRunner
                    {
                        ParentControl = parent,
                        JobTitle      = Resources.RemovePeaksAction_RemovePeaks_Removing_Peaks
                    };
                    SrmDocument resultDocument = doc;
                    doc = doc.BeginDeferSettingsChanges();
                    longOperationRunner.Run(broker =>
                    {
                        for (int iGroup = 0; iGroup < lookup.Length; iGroup++)
                        {
                            broker.ProgressValue = iGroup * 100 / lookup.Length;
                            if (broker.IsCanceled)
                            {
                                return;
                            }
                            doc = RemovePeaks(doc, lookup[iGroup]);
                        }

                        resultDocument = doc.EndDeferSettingsChanges(resultDocument, null);
                    });
                    return(resultDocument);
                },
                                             docPair => AuditLogEntry.CreateSingleMessageEntry(
                                                 new MessageInfo(MessageType.removed_peaks, docPair.NewDocumentType, selectedPeaks.Length, lookup.Length)));
            }
        }
Beispiel #2
0
        public override bool RunOnThisThread(Control owner, Action <CancellationToken, IProgressMonitor> job)
        {
            var  longOperationRunner = new LongOperationRunner();
            bool finished            = false;

            longOperationRunner.Run(longWaitBroker =>
            {
                var progressWaitBroker = new ProgressWaitBroker(progressMonitor => job(longWaitBroker.CancellationToken, progressMonitor));
                progressWaitBroker.PerformWork(longWaitBroker);
                finished = !longWaitBroker.IsCanceled;
            });
            return(finished);
        }
Beispiel #3
0
        private void LaunchPeptideProteinsQuery()
        {
            using (var longWaitDlg = new LongWaitDlg
            {
                Text = Resources.UniquePeptidesDlg_LaunchPeptideProteinsQuery_Querying_Background_Proteome_Database,
                Message = Resources.UniquePeptidesDlg_LaunchPeptideProteinsQuery_Looking_for_proteins_with_matching_peptide_sequences
            })
            {
                try
                {
                    longWaitDlg.PerformWork(this, 1000, QueryPeptideProteins);
                }
                catch (Exception x)
                {
                    var message = TextUtil.LineSeparate(string.Format(Resources.UniquePeptidesDlg_LaunchPeptideProteinsQuery_Failed_querying_background_proteome__0__,
                                                                      BackgroundProteome.Name), x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                }
            }
            if (_peptideProteins == null)
            {
                Close();
                return;
            }

            var longOperationRunner = new LongOperationRunner
            {
                ParentControl = this
            };
            bool success = longOperationRunner.CallFunction(AddProteinRowsToGrid);

            if (!success)
            {
                Close();
            }
        }