Beispiel #1
0
        public void AddNewDownloadTask(DownloadTaskInfo downloadTaskInfo)
        {
            Guid newTaskGuid = m_DownloadHelper.AddNewDownloadTask(downloadTaskInfo);

            ListViewItem item = new ListViewItem();

            DownloadTaskStatistics downloadTaskStatistics = m_DownloadHelper.GetDownloadTaskStatistics(newTaskGuid);

            string fileName      = downloadTaskInfo.DownloadFileInfo.FileName;
            string fileExtension = Path.GetExtension(fileName);

            item.ImageIndex = FileTypeImageList.GetImageIndexByExtention(fileExtension);
            item.Text       = Path.GetFileName(fileName);

            item.SubItems.Add(ByteFormatter.ToString(downloadTaskStatistics.FileSize));
            item.SubItems.Add(ByteFormatter.ToString(downloadTaskStatistics.TransferedDownload));
            item.SubItems.Add(GetDownloadProgressText(downloadTaskStatistics));
            item.SubItems.Add(TimeSpanFormatter.ToString(downloadTaskStatistics.RemainingTime));
            item.SubItems.Add("0");
            item.SubItems.Add("0");
            item.SubItems.Add(string.Format(CultureInfo.CurrentCulture, "{0} {1}", downloadTaskStatistics.CreatedDate.ToShortDateString(), downloadTaskStatistics.CreatedDate.ToShortTimeString()));
            item.SubItems.Add(downloadTaskStatistics.DownloadTaskState.ToString());
            item.SubItems.Add(GetResumeText(downloadTaskStatistics));
            item.SubItems.Add(downloadTaskStatistics.FileUri.OriginalString);

            m_DownloadTaskItemMap[item] = newTaskGuid;

            lvwDownloadTasks.Items.Add(item);
        }
        public void Test()
        {
            string imagesPath = Path.Combine(Environment.CurrentDirectory, "images");
            if (!Directory.Exists(imagesPath))
            {
                Directory.CreateDirectory(imagesPath);
            }

            DownloadHelper downloadHelper = new DownloadHelper(new InMemoryDownloadSettings(200, 5, 1024, 5, 5), new LocalFileDownloadStreamManager(new TempFileAllocator(new DefaultFileNameCorrector())));

            downloadHelper.AddNewDownloadTask(
                new Uri("http://dc455.4shared.com/img/OctFRjPl/s3/13470492140/marika-fruscio-01.jpg"),
                Path.Combine(imagesPath, "marika-fruscio-01.jpg"));

            downloadHelper.OnDownloadFinished(
               x =>
               {
                   x.DownloadTask.State.ToString();
               });

            downloadHelper.Start();
            downloadHelper.Shutdown(true);
        }
Beispiel #3
0
        public void Test()
        {
            string imagesPath = Path.Combine(Environment.CurrentDirectory, "images");

            if (!Directory.Exists(imagesPath))
            {
                Directory.CreateDirectory(imagesPath);
            }

            DownloadHelper downloadHelper = new DownloadHelper(new InMemoryDownloadSettings(200, 5, 1024, 5, 5), new LocalFileDownloadStreamManager(new TempFileAllocator(new DefaultFileNameCorrector())));

            downloadHelper.AddNewDownloadTask(
                new Uri("http://dc455.4shared.com/img/OctFRjPl/s3/13470492140/marika-fruscio-01.jpg"),
                Path.Combine(imagesPath, "marika-fruscio-01.jpg"));

            downloadHelper.OnDownloadFinished(
                x =>
            {
                x.DownloadTask.State.ToString();
            });

            downloadHelper.Start();
            downloadHelper.Shutdown(true);
        }