public void AddTask(DownloadItem downloadItem) { IDownloadTask downloadTask = new HttpDownloadTask(downloadItem); downloadTask.ReportProgress += new Action<DownloadItem>(downloadTask_ReportProgress); downloadTaskList.Add(downloadTask); GetDownloadTaskState.Invoke(DownloadList); }
private void tastListDataGridView_Click(object sender, EventArgs e) { if (tastListDataGridView.SelectedRows.Count > 0) { dataGridViewSelectedItem = (DownloadItem)tastListDataGridView.SelectedRows[0].DataBoundItem; httpDownloadManager.SelectedItem = dataGridViewSelectedItem; } }
private void addToDownloadListButton_Click(object sender, EventArgs e) { // add file to download list //TODO: check for input data DownloadItem downloadItem = new DownloadItem(); downloadItem.SourceName = this.sourceFileNameTextBox.Text; downloadItem.DestinationName = this.destFileTextBox.Text; downloadItem.Persentage = 0; downloadItem.State = TaskState.Start; httpDownloadManager.AddTask(downloadItem); }
private void downloadTask_ReportProgress(DownloadItem downloadItem) { for (int i = 0; i < downloadTaskList.Count; i++) { if (downloadTaskList[i].CurrentDownloadItem.ID.Equals(downloadItem.ID)) { downloadTaskList[i].CurrentDownloadItem = downloadItem; break; } } GetDownloadTaskState.Invoke(DownloadList); }
public HttpDownloadTask(DownloadItem downloadItem) { this.downloadItem = downloadItem; backgroundWorker = new BackgroundFileLoader(Download); backgroundWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(backgroundWorker_ProgressChanged); }