private ChromatogramLoadingStatus FindStatus(MultiProgressStatus status, MsDataFileUri filePath) { foreach (ChromatogramLoadingStatus loadingStatus in status.ProgressList) { if (loadingStatus.FilePath.Equals(filePath)) { return(loadingStatus); } } return(null); }
private void AddProgressControls(MultiProgressStatus status) { // Nothing to do if everything is already covered if (status.ProgressList.All(s => FindProgressControl(s.FilePath) != null)) { return; } // Match each file status with a progress control. bool first = true; var width = flowFileStatus.Width - 2 - (flowFileStatus.VerticalScroll.Visible ? SystemInformation.VerticalScrollBarWidth : 0); List <FileProgressControl> controlsToAdd = new List <FileProgressControl>(); foreach (var loadingStatus in status.ProgressList) { var filePath = loadingStatus.FilePath; var progressControl = FindProgressControl(filePath); if (progressControl != null) { continue; } // Create a progress control for new file. progressControl = new FileProgressControl { Number = flowFileStatus.Controls.Count + controlsToAdd.Count + 1, Width = width, Selected = first, BackColor = SystemColors.Control, FilePath = filePath }; progressControl.SetToolTip(toolTip1, filePath.GetFilePath()); int index = progressControl.Number - 1; progressControl.ControlMouseDown += (sender, args) => { Selected = index; }; var thisLoadingStatus = loadingStatus; progressControl.Retry += (sender, args) => Retry(thisLoadingStatus); progressControl.Cancel += (sender, args) => Cancel(thisLoadingStatus); progressControl.ShowGraph += (sender, args) => ShowGraph(); progressControl.ShowLog += (sender, args) => ShowLog(); controlsToAdd.Add(progressControl); _fileProgressControls.Add(filePath.GetLocation(), progressControl); first = false; } flowFileStatus.Controls.AddRange(controlsToAdd.ToArray()); }
private void AddProgressControls(MultiProgressStatus status) { // Match each file status with a progress control. bool first = true; foreach (var loadingStatus in status.ProgressList) { var filePath = loadingStatus.FilePath; var progressControl = FindProgressControl(filePath); if (progressControl != null) { continue; } // Create a progress control for new file. progressControl = new FileProgressControl { Number = flowFileStatus.Controls.Count + 1, FilePath = filePath }; progressControl.SetToolTip(toolTip1, filePath.GetFilePath()); int index = progressControl.Number - 1; progressControl.ControlMouseDown += (sender, args) => { Selected = index; }; var thisLoadingStatus = loadingStatus; progressControl.Retry += (sender, args) => Retry(thisLoadingStatus); progressControl.Cancel += (sender, args) => Cancel(thisLoadingStatus); progressControl.ShowGraph += (sender, args) => ShowGraph(); progressControl.ShowLog += (sender, args) => ShowLog(); flowFileStatus.Controls.Add(progressControl); progressControl.BackColor = SystemColors.Control; if (first) { first = false; progressControl.Selected = true; } } foreach (FileProgressControl progressControl in flowFileStatus.Controls) { progressControl.Width = flowFileStatus.Width - 2 - (flowFileStatus.VerticalScroll.Visible ? SystemInformation.VerticalScrollBarWidth : 0); } }
private void CancelMissingFiles(MultiProgressStatus status) { HashSet <MsDataFileUri> filesWithStatus = null; foreach (FileProgressControl progressControl in flowFileStatus.Controls) { if (!progressControl.IsComplete && !progressControl.IsCanceled) { if (filesWithStatus == null) { filesWithStatus = new HashSet <MsDataFileUri>(status.ProgressList .Select(loadingStatus => loadingStatus.FilePath)); } if (!filesWithStatus.Contains(progressControl.FilePath)) { progressControl.IsCanceled = true; } } } }
private void CancelMissingFiles(MultiProgressStatus status) { foreach (FileProgressControl progressControl in flowFileStatus.Controls) { if (!progressControl.IsComplete && !progressControl.IsCanceled) { bool found = false; foreach (var loadingStatus in status.ProgressList) { if (progressControl.FilePath.Equals(loadingStatus.FilePath)) { found = true; break; } } if (!found) { progressControl.IsCanceled = true; } } } }
/// <summary> /// Display chromatogram data. /// </summary> /// <param name="status"></param> public void UpdateStatus(MultiProgressStatus status) { // Update overall progress bar. if (_partialProgressList.Count == 0) { progressBarTotal.Value = status.PercentComplete; } else { int percentComplete = 0; foreach (var path in _partialProgressList) { var matchingStatus = FindStatus(status, path); if (matchingStatus != null) { percentComplete += matchingStatus.IsFinal ? 100 : matchingStatus.PercentComplete; } } progressBarTotal.Value = percentComplete / _partialProgressList.Count; } // Add any new files. AddProgressControls(status); // Cancel missing files. CancelMissingFiles(status); if (Selected < 0) { Selected = 0; } // Update progress control for each file. for (int i = 0; i < status.ProgressList.Count; i++) { var loadingStatus = status.ProgressList[i]; graphChromatograms.UpdateStatus(loadingStatus); var progressControl = FindProgressControl(loadingStatus.FilePath); bool wasError = progressControl.Error != null; progressControl.SetStatus(loadingStatus); if (loadingStatus.IsError && !wasError) { if (!_selectionIsSticky) { _selectionIsSticky = true; Selected = i; flowFileStatus.ScrollControlIntoView(progressControl); } RemoveFailedFile(loadingStatus); } } RefreshSelectedControl(); // Update status for a single file. if (flowFileStatus.Controls.Count == 1) { Width = _multiFileWindowWidth - panelFileList.Width; panelFileList.Visible = false; btnAutoScaleGraphs.Visible = false; return; } Width = _multiFileWindowWidth; panelFileList.Visible = true; btnAutoScaleGraphs.Visible = true; graphChromatograms.ScaleIsLocked = !Settings.Default.ImportResultsAutoScaleGraph; // If a file is successfully completed, automatically select another loading file. if (!_selectionIsSticky && (SelectedControl == null || SelectedControl.Progress == 100)) { for (int i = Selected + 1; i < flowFileStatus.Controls.Count; i++) { var control = (FileProgressControl)flowFileStatus.Controls[i]; if (!control.IsCanceled && control.Progress > 0 && control.Progress < 100) { Selected = i; flowFileStatus.ScrollControlIntoView(control); } } } if (!Finished) { btnCancel.Visible = true; btnHide.Text = Resources.AllChromatogramsGraph_UpdateStatus_Hide; progressBarTotal.Visible = true; _stopwatch.Start(); elapsedTimer.Start(); } }