Ejemplo n.º 1
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            DisplayDownloadList();

            var urls = GetUrls();

            txtUrls.Clear();

            var queuedDownloads = urls.Select(url => new DownloadProcedure(url)
            {
                Parser = _importers.Find(x => x.IsUrlParsable(url))
            }).ToList();

            foreach (
                var lvi in
                queuedDownloads.Select(queuedDownload => new ListViewItem {
                Text = queuedDownload.Url.ToString()
            }))
            {
                lvi.SubItems.Add(Resources.Idle);
                listDownloads.Items.Add(lvi);
            }

            progressBar1.Maximum = queuedDownloads.Count;

            btnCancel.BringToFront();
            progressBar1.Visible = true;

            _completed = false;

            DownloadBackgroundWorker.RunWorkerAsync(queuedDownloads);
        }
Ejemplo n.º 2
0
        private void DownloadBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var queuedDownloads = (List <DownloadProcedure>)e.Argument;

            var count = 0;

            var proxy = TabsterSettingsUtilities.ProxySettings.Proxy;

            foreach (var queuedDownload in queuedDownloads)
            {
                if (DownloadBackgroundWorker.CancellationPending)
                {
                    queuedDownload.State = DownloadState.Cancelled;
                }

                else if (queuedDownload.Parser == null)
                {
                    queuedDownload.State = DownloadState.MissingParser;
                }

                else
                {
                    PerformQueuedDownload(queuedDownload, proxy);
                }

                count++;
                DownloadBackgroundWorker.ReportProgress(count, queuedDownload);
            }

            e.Result = queuedDownloads;
        }
Ejemplo n.º 3
0
 private void DownloadDialog_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!_completed)
     {
         DownloadBackgroundWorker.CancelAsync();
         Enabled       = false;
         e.Cancel      = true;
         _closePending = true;
     }
 }