Example #1
0
 public DownloadListItem(DownloadTask downloadTask)
     : this()
 {
     this.downloadTask = downloadTask;
     downloadTask.DownloadProgressChanged += DownloadProgressChanged;
     downloadTask.DownloadStatusChanged += DownloadStatusChanged;
 }
Example #2
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            string uriName = urlInput.Text;
            Uri uriResult;
            bool result = Uri.TryCreate(uriName, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp;
            if (result)
            {
                if(!Directory.Exists(downloadDirectory))
                {
                    Directory.CreateDirectory(downloadDirectory);
                }
                string outfileName = GetAvailableOutputName(downloadDirectory + Path.DirectorySeparatorChar + Path.GetFileName(uriResult.LocalPath));
                Console.WriteLine("outfile " + outfileName);

                DownloadTask downloadTask = new DownloadTask(uriName, outfileName);
                downloadTasks.Add(downloadTask);

                DownloadListItem downloadListItem = new DownloadListItem(downloadTask);
                downloadListItem.Text = Path.GetFileName(outfileName);
                downloadListItem.DownloadItemRemoved += downloadListItem_DownloadItemRemoved;
                flowLayoutPanel1.Controls.Add(downloadListItem);
                downloadTask.StartDownload();
            }
            else
            {
                MessageBox.Show("Invalid Url");
            }
            urlInput.Text = "";
        }
 public DownloadListItem(DownloadTask downloadTask) : this()
 {
     this.downloadTask = downloadTask;
     downloadTask.DownloadProgressChanged += DownloadProgressChanged;
     downloadTask.DownloadStatusChanged   += DownloadStatusChanged;
 }