bool Happened = false; //Supposedly, The OnDownloadCompleted repeats. Well each time, it repeats one more time than //it previously repeated. Nothing bad about this, except that tyhe ShowCompleteDownloadDialog //gets called as well. We don't want that. So I have this variable to keep track of everything. //Event fires when the Download has completed. void FtpClient_OnDownloadCompleted(object sender, DownloadCompletedArgs e) { if (e.DownloadCompleted) { if (!Happened) { //Display the appropriate information to the User regarding the Download. this.Text = "Download Completed!"; lblDownloadStatus.Text = "Downloaded File Successfully!"; progressBar1.Value = progressBar1.Maximum; btnCancel.Text = "Exit"; //Display the TaskDialog, which will ask the user about what he/she needs to do with the file. ShowCompleteDownloadDialog(); } Happened = true; } else { lblDownloadStatus.Text = "Download Status: " + e.DownloadStatus; this.Text = "Download Error"; btnCancel.Text = "Exit"; HelperClasses.TaskBarManager.SetTaskBarProgressState(Microsoft.WindowsAPICodePack.Taskbar.TaskbarProgressBarState.Error); TaskDialog.Show("Error: " + e.DownloadStatus); } Happened = true; }
private void packsDownloader_DownloadCompleted(object sender, DownloadCompletedArgs e) { Label label = this.lblMessage; Label label1 = this.lblStatus; string empty = string.Empty; string str = empty; label1.Text = empty; label.Text = str; if (!e.Cancelled && e.Error == null) { if (MsgBox.Question(gPatcher.Localization.Text.Question_Text_DownloadCompleted, gPatcher.Localization.Text.Question_Caption_DownloadCompleted) == System.Windows.Forms.DialogResult.Yes) { base.Close(); } } else if (e.Error != null) { MsgBox.Error(gPatcher.Localization.Text.Error_Downloading, e.Error); } this.UpdateState(); }