void IDownloadObserver.onMessage(DownloadArgument e) { if (mIDownloadObserver != null) { mIDownloadObserver.onMessage(e); } }
void IDownloadObserver.onComplete(DownloadArgument e) { if (e.Downloader.Tag != null) { Button btn = (Button)e.Downloader.Tag; if (e.AsyncCompletedEventArgs.Cancelled) { btn.Enabled = true; btn.Text = "Download"; } else if (e.AsyncCompletedEventArgs.Error != null) { // Error in Completion... } else { //Normal Complete..We can check Downloded Size and Remote Size to verify... btn.Text = "Completed"; btn.Enabled = false; e.Downloader.DownloadObserver = null; mIDownloadObserver = null; } } if (mIDownloadObserver != null) { mIDownloadObserver.onComplete(e); } // //this.Remove(e.Downloader); //e.Downloader = null; }
void IDownloadObserver.onContinue(DownloadArgument e) { if (mIDownloadObserver != null) { mIDownloadObserver.onContinue(e); } }
// public void onContinue(object sender, DownloadProgressChangedEventArgs e) { this.downloadStatus = "Continue"; // if (e.ProgressPercentage > 0) { TimeSpan tss = DateTime.Now - start; long percent = e.ProgressPercentage; long remaining = ((e.TotalBytesToReceive - e.BytesReceived) * Convert.ToInt32(tss.Milliseconds) / e.BytesReceived); // TODO has problem need to FIX it... string result = "N/A"; Console.WriteLine("Remaining time:" + result); if (this.DownloadObserver != null) { this.uodateStatus("Percent: " + e.ProgressPercentage); DownloadArgument dArgument = new DownloadArgument(e, this); dArgument.RemainingTime = result; DownloadObserver.onContinue(dArgument); } } Console.WriteLine($"Download status: {e.ProgressPercentage}%."); }
// public void onComplete(object sender, AsyncCompletedEventArgs e) { DownloadArgument dArgument = new DownloadArgument(e, this); if (e.Error != null) { if (e.Cancelled) { uodateStatus("Cancelled"); downloadStatus = "Cancelled"; } else { uodateStatus(e.Error.Message); downloadStatus = "Error"; } Console.WriteLine(e.Error.Message); } else { downloadStatus = "Completed"; Console.WriteLine("Completed.."); } if (DownloadObserver != null) { DownloadObserver.onComplete(dArgument); } //DownloadObserver = null; }
public void onMessage(DownloadArgument e) { if (e.Message == "NetworkFailed") { MessageBox.Show("No internet available !"); } }
public void onContinue(DownloadArgument e) { }
public void onComplete(DownloadArgument e) { }