public void Complete(DownloadItem item) { //TODO: play a sound item.IsComplete = true; var itemControl = GetControlByID(item.DownloadID); itemControl.ProgressBar.Visible = false; }
public bool Add(DownloadItem item) { downloadList.Add(item); item.PropertyChanged += item_PropertyChanged; var itemControl = new DownloadItemControl(); itemControl.Name = item.DownloadID.ToString(); itemControl.FileName = item.SaveFileName; UpdateProgressBar(item, itemControl); itemPanel.Controls.Add(itemControl); return true; }
private static void UpdateProgressBar(DownloadItem item, DownloadItemControl itemControl) { //文件大小溢出 if (item.ContentLength > (long)int.MaxValue) { //计算单位刻度 long ProgressBarSpan = item.ContentLength / int.MaxValue; itemControl.ProgressBar.Maximum = int.MaxValue; itemControl.ProgressBar.Value = (int)(item.CurrLength / ProgressBarSpan); } else if (item.ContentLength == -1)//文件大小无法获得 { itemControl.ProgressBar.Style = ProgressBarStyle.Marquee; //itemControl.ProgressBar.MarqueeAnimationSpeed = 1000; } else { itemControl.ProgressBar.Maximum = (int)item.ContentLength; itemControl.ProgressBar.Value = (int)item.CurrLength; } }
public bool Cancel(DownloadItem item) { item.IsCancel = true; return true; }
public bool Cancel(DownloadItem item) { item.IsCancel = true; return(true); }