예제 #1
0
        //// This event allows you to show the download progress to the user.

        //// e.BytesReceived = Bytes received so far.
        //// e.DownloadSpeedBytesPerSec = Download speed in bytes per second.
        //// e.DownloadTimeSeconds = Download time in seconds so far.
        //// e.ProgressPercentage = Percentage of the file downloaded.
        //// e.RemainingTimeSeconds = Remaining download time in seconds.
        //// e.TotalBytesToReceive = Total size of the file that is being downloaded.
        //// e.userToken = Usually the control(s) you wish to update.
        private void DownloadProgressChanged(object sender, FileDownloadProgressChangedEventArgs e)
        {
            //// Get the ListViewItem we passed as userToken parameter, so we can update it.
            ListViewItem lvw = (ListViewItem)e.userToken;

            //// Update the ListView items.
            lvw.SubItems[1].Text = ConvertBytes(e.TotalBytesToReceive);
            lvw.SubItems[2].Text = "Downloading";
            lvw.SubItems[3].Text = ConvertBytes(e.BytesReceived);
            lvw.SubItems[4].Text = System.Convert.ToString(e.ProgressPercentage);
            lvw.SubItems[5].Text = (e.DownloadSpeedBytesPerSec / 1024).ToString() + " kB/s";
            lvw.SubItems[6].Text = ConvertSeconds(e.DownloadTimeSeconds);
            lvw.SubItems[7].Text = ConvertSeconds(e.RemainingTimeSeconds);
            lvw.ImageKey         = "Downloading";
        }
예제 #2
0
 protected virtual void OnDownloadProgressChanged(FileDownloadProgressChangedEventArgs e)
 {
     if (this.SynchronizingObject != null && this.SynchronizingObject.InvokeRequired)
     {
         //Marshal the call to the thread that owns the synchronizing object.
         this.SynchronizingObject.Invoke(new DownloadProgressChangedEventInvoker(OnDownloadProgressChanged), new object[] { e });
     }
     else
     {
         DownloadProgressChanged(this, e);
         //RaiseEvent DownloadProgressChanged(Me, e);
         //if (DownloadProgressChangedEvent != null)
         //    DownloadProgressChangedEvent(this, e);
     }
 }