本文整理汇总了C#中System.Net.DownloadProgressChangedEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DownloadProgressChangedEventArgs类的具体用法?C# DownloadProgressChangedEventArgs怎么用?C# DownloadProgressChangedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DownloadProgressChangedEventArgs类属于System.Net命名空间,在下文中一共展示了DownloadProgressChangedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProgressChanged
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs downloadProgressChangedEventArgs)
{
progressBar1.Invoke(new Action(() =>
{
progressBar1.Value = downloadProgressChangedEventArgs.ProgressPercentage;
}));
}
示例2: DownloadProgressChanged
/// <summary>Updates the download visuals (progress bar, text %, etc.)</summary>
private void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
int index = GetDownloadFromWebClient((WebClient)sender);
Download dld = (Download)clients[index]; //is this creating a copy?
if (!dld.accountedFor)
{
dld.totalSize = e.TotalBytesToReceive;
totalUpdateSize += e.TotalBytesToReceive;
dld.accountedFor = true;
}
dld.completed = e.BytesReceived;
clients[index] = dld; // put the copy into the array
long tempTotal = 0;
lstDownloadProgress.Items.Clear();
//Should I make this next part thread safe? It isn't really an exact science, so I don't think it matters
foreach (Download dl in clients)
{
tempTotal += dl.completed;
lstDownloadProgress.Items.Add(dl);
}
totalUpdateRecieved = tempTotal;
pbarDownload.Value = (int)(((double)totalUpdateRecieved / (double)totalUpdateSize) * 100);
lblDownloadProgress.Text = "" + (int)(((double)totalUpdateRecieved / (double)totalUpdateSize) * 100) + "%";
}
示例3: OnDownloadProgressChanged
protected override void OnDownloadProgressChanged(DownloadProgressChangedEventArgs e)
{
if (dt.Ticks == 0)
{
dt = DateTime.Now;
}
time = (DateTime.Now.Ticks - dt.Ticks) / (TimeSpan.TicksPerMillisecond * 1000);
if (sw.ElapsedMilliseconds == 0)
{
sw.Start();
}
float dbSec = sw.ElapsedMilliseconds / 1000;
string strSpeed;
try
{
strSpeed = clsMain.formatBytes(e.BytesReceived / dbSec);
}
catch
{
strSpeed = "";
}
//System.Diagnostics.Debug.Print(((DateTime.Now.Ticks - dt.Ticks) / (TimeSpan.TicksPerMillisecond*1000) ).ToString());
//System.Diagnostics.Debug.Print(((time / 60) % 60).ToString());
//System.Diagnostics.Debug.Print((e.BytesReceived.ToString() + "\t" + (DateTime.Now.Ticks - dt.Ticks).ToString()));
DownloadProgressChangedIndex(e, intCurrentClassIndex, String.Format("{0:00}:{1:00}:{2:00}", (int)time / 3600, (int)((time / 60) % 60), (int)(time % 60)), strSpeed);
}
示例4: VideoProgressChanged
private void VideoProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
_progressTextBlock.Text = String.Format("{0} Downloaded {1} of {2} bytes. {3} % Complete...",
(string)e.UserState, e.BytesReceived, e.TotalBytesToReceive,
e.ProgressPercentage);
_progressBar.Value = e.ProgressPercentage;
}
示例5: Client_DownloadProgressChanged
private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
if (this.ProgressChanged != null)
{
this.ProgressChanged(this, e.ProgressPercentage);
}
}
示例6: client_DownloadProgressChanged
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
if (e.UserState as string == "pompeu")
{
//txtStatus.Text = e.BytesReceived.ToString() + " bytes received.";
}
}
示例7: Client_DownloadProgressChanged
void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progressBar1.Maximum = Convert.ToInt32(e.TotalBytesToReceive);
progressBar1.Value = Convert.ToInt32(e.BytesReceived);
label5.Text = e.BytesReceived.ToString();
label6.Text = e.TotalBytesToReceive.ToString();
}
示例8: HandleDownloadProgressChanged
private void HandleDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
//Console.WriteLine("SyncClientService - HandleDownloadProgressChanged - progressPercentage: {0} bytesReceived: {1} totalBytesToReceive: {2}", e.ProgressPercentage, e.BytesReceived, e.TotalBytesToReceive);
string fileName = string.Empty;
if(_audioFiles != null && _audioFiles.Count >= _filesDownloaded+1)
fileName = Path.GetFileName(_audioFiles[_filesDownloaded].FilePath);
_bytesDownloaded += e.BytesReceived - _lastBytesReceived;
_lastBytesReceived = e.BytesReceived;
if (OnDownloadIndexProgress != null)
OnDownloadIndexProgress(e.ProgressPercentage, e.BytesReceived, e.TotalBytesToReceive);
if (OnDownloadAudioFileProgress != null)
OnDownloadAudioFileProgress(new SyncClientDownloadAudioFileProgressEntity(){
Status = "Downloading files...",
PercentageDone = ((float)_filesDownloaded / (float)_audioFiles.Count()) * 100f,
FilesDownloaded = _filesDownloaded,
TotalFiles = _audioFiles.Count(),
DownloadBytesReceived = e.BytesReceived,
DownloadTotalBytesToReceive = e.TotalBytesToReceive,
DownloadPercentageDone = ((float)e.BytesReceived / (float)e.TotalBytesToReceive) * 100f,
DownloadSpeed = GetDownloadSpeed(),
Errors = _errorCount,
DownloadFileName = fileName,
Log = string.Empty
});
}
示例9: DownloadStatusChanged
private void DownloadStatusChanged(object sender, DownloadProgressChangedEventArgs e)
{
// Prozentualen Fortschritt in progressBar1 anzeigen
progressBar2.Value = e.ProgressPercentage;
statusLabel2.Text = e.ProgressPercentage + "% (" + e.BytesReceived + " von " + e.TotalBytesToReceive + " Bytes)";
}
示例10: wc_DownloadProgressChanged
public void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
if (e.BytesReceived != 0)
{
this.Connected = true;
}
}
示例11: webClient_DownloadProgressChanged
void webClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
test.Value = e.BytesReceived;
//test.Value = e.ProgressPercentage;
test.Maximum = e.TotalBytesToReceive;
DownloadResultText.Text = "Downloaded " + e.BytesReceived + "/" + e.TotalBytesToReceive + "bytes, " + e.ProgressPercentage + "% completed.";
}
示例12: ProgressIndicator
public ProgressIndicator(DownloadProgressChangedEventArgs args,string token = "")
{
Processed = args.BytesReceived;
Remaining = args.TotalBytesToReceive;
Percentage = args.ProgressPercentage;
RequestToken = token;
}
示例13: downloader_DownloadProgressChanged
void downloader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
double bytesIn = double.Parse(e.BytesReceived.ToString());
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = bytesIn / totalBytes * 100;
this.Dispatcher.Invoke(()=>progressBar.Value = int.Parse(Math.Truncate(percentage).ToString()));
}
示例14: ClientDownloadProgressChanged
/// <summary>
/// Callback by the web client when a new piece of file has been incrementally downloaded
/// </summary>
void ClientDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
string progress = String.Format("Downloaded {0} of {1} Kb", e.BytesReceived / 1024, e.TotalBytesToReceive / 1024);
UIThread(() => labelProgress.Text = progress);
UIThread(() => progressBar.Maximum = (int) e.TotalBytesToReceive);
UIThread(() => progressBar.Value = (int) e.BytesReceived);
}
示例15: downloadProgressChanged
private void downloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
if (e.ProgressPercentage != updateProgress.Value)
{
updateProgress.Value = e.ProgressPercentage;
}
}