protected virtual void OnStatusChanged(EventArgs e)
{
switch (this.Status)
{
case DownloadStatus.Waiting:
case DownloadStatus.Downloading:
case DownloadStatus.Paused:
case DownloadStatus.Canceled:
case DownloadStatus.Completed:
if (this.StatusChanged != null)
{
this.StatusChanged(this, e);
}
break;
default:
break;
}
if (this.status == DownloadStatus.Canceled)
{
Exception ex = new Exception("Downloading is canceled by user's request. ");
this.OnDownloadCompleted(
new DownloadCompletedEventArgs(
null,
this.DownloadedSize,
this.TotalSize,
this.TotalUsedTime,
ex));
}
if (this.Status == DownloadStatus.Completed)
{
this.OnDownloadCompleted(
new DownloadCompletedEventArgs(
new FileInfo(this.DownloadPath),
this.DownloadedSize,
this.TotalSize,
this.TotalUsedTime,
null));
}
}