Пример #1
0
 /// <summary>
 /// Report about progress
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void _downloader_OnReportProgress(object sender, DownloadProgressChangedEventArgs e)
 {
     Download_progressBar.Invoke((MethodInvoker)(() =>
     {
         if (e.TotalBytesToReceive != -1)
         {
             //Update progress bar
             Download_progressBar.Value = e.ProgressPercentage;
             Download_progressBar.Style = ProgressBarStyle.Blocks;
         }
         else
         {
             //If we not get size of file we switch to marquee mode
             Download_progressBar.Style = ProgressBarStyle.Marquee;
         }
     }));
 }
Пример #2
0
 /// <summary>
 /// Update progress bar
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
 {
     if (e.TotalBytesToReceive == -1)
     {
         Download_progressBar.Invoke((MethodInvoker)(() => { Download_progressBar.Style = ProgressBarStyle.Marquee; }));
         Status_label.Invoke((MethodInvoker)(() => { Status_label.Text = $"Downloading {SizeSuffix(e.BytesReceived)}..."; }));
     }
     else
     {
         Download_progressBar.Invoke((MethodInvoker)(() =>
         {
             Download_progressBar.Style = ProgressBarStyle.Blocks;
             Download_progressBar.Value = e.ProgressPercentage;
         }));
         Status_label.Invoke((MethodInvoker)(() => { Status_label.Text = $"Downloading {SizeSuffix(e.BytesReceived)} from {SizeSuffix(e.TotalBytesToReceive)}..."; }));
     }
 }