Exemple #1
0
 void IDownloadObserver.onMessage(DownloadArgument e)
 {
     if (mIDownloadObserver != null)
     {
         mIDownloadObserver.onMessage(e);
     }
 }
Exemple #2
0
        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;
        }
Exemple #3
0
 void IDownloadObserver.onContinue(DownloadArgument e)
 {
     if (mIDownloadObserver != null)
     {
         mIDownloadObserver.onContinue(e);
     }
 }
Exemple #4
0
        //
        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}%.");
        }
Exemple #5
0
        //
        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;
        }
Exemple #6
0
 public void onMessage(DownloadArgument e)
 {
     if (e.Message == "NetworkFailed")
     {
         MessageBox.Show("No internet available !");
     }
 }
Exemple #7
0
 public void onContinue(DownloadArgument e)
 {
 }
Exemple #8
0
 public void onComplete(DownloadArgument e)
 {
 }