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());
        }
Exemple #2
0
        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);
            }
        }