Example #1
0
        public void Complete(DownloadItem item)
        {
            //TODO: play a sound

            item.IsComplete = true;
            var itemControl = GetControlByID(item.DownloadID);

            itemControl.ProgressBar.Visible = false;
        }
Example #2
0
        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;
        }
Example #3
0
 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;
     }
 }
Example #4
0
        public bool Cancel(DownloadItem item)
        {
            item.IsCancel = true;

            return true;
        }
Example #5
0
        public bool Cancel(DownloadItem item)
        {
            item.IsCancel = true;

            return(true);
        }