Ejemplo n.º 1
0
        /// <summary>
        /// 添加下载任务
        /// </summary>
        /// <param name="urls"></param>
        public void AddDownload(System.Collections.Generic.IEnumerable<MiniDownloadItem> items)
        {
            foreach (MiniDownloadItem item in items)
            {
                string text = item.fileName;
                if (text == null || text.Trim().Length == 0)
                    text = Uri.UnescapeDataString(item.url.Substring(item.url.LastIndexOf('/') + 1));

                try
                {
                    DownloadItem itm = new DownloadItem(text, item.url);
                    downloadItemsDic.Add(item.url, itm);
                    downloadItems.Add(itm);
                    numLeft++;
                }
                catch (ArgumentException) { }//duplicate entry
            }

            if (!isWorking)
            {
                isWorking = true;
            }

            RefreshList();
        }