コード例 #1
0
ファイル: DownloadDialog.cs プロジェクト: sixteentons/Tabster
        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);
        }
コード例 #2
0
ファイル: DownloadDialog.cs プロジェクト: sixteentons/Tabster
        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;
        }
コード例 #3
0
ファイル: DownloadDialog.cs プロジェクト: sixteentons/Tabster
 private void DownloadDialog_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!_completed)
     {
         DownloadBackgroundWorker.CancelAsync();
         Enabled       = false;
         e.Cancel      = true;
         _closePending = true;
     }
 }