コード例 #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);
        }
コード例 #2
0
ファイル: DownloadList.cs プロジェクト: mythocalos/webauto
        public DownloadList()
        {
            InitializeComponent();
            InitLanguage();

            ProtocolProviderFactory.RegisterProtocolHandler("http", typeof(HttpProtocolProvider));
            ProtocolProviderFactory.RegisterProtocolHandler("https", typeof(HttpProtocolProvider));
            ProtocolProviderFactory.RegisterProtocolHandler("ftp", typeof(FtpProtocolProvider));

            WebAutomation.DownloadManager.DownloadManager.Instance.DownloadAdded   += new EventHandler <DownloaderEventArgs>(Instance_DownloadAdded);
            WebAutomation.DownloadManager.DownloadManager.Instance.DownloadRemoved += new EventHandler <DownloaderEventArgs>(Instance_DownloadRemoved);
            WebAutomation.DownloadManager.DownloadManager.Instance.DownloadEnded   += new EventHandler <DownloaderEventArgs>(Instance_DownloadEnded);

            for (int i = 0; i < WebAutomation.DownloadManager.DownloadManager.Instance.Downloads.Count; i++)
            {
                AddDownload(WebAutomation.DownloadManager.DownloadManager.Instance.Downloads[i]);
            }

            lvwDownloads.SmallImageList = FileTypeImageList.GetSharedInstance();
        }
コード例 #3
0
ファイル: DownloadList.cs プロジェクト: mythocalos/webauto
        private void AddDownload(Downloader d)
        {
            d.RestartingSegment += new EventHandler <SegmentEventArgs>(download_RestartingSegment);
            d.SegmentStoped     += new EventHandler <SegmentEventArgs>(download_SegmentEnded);
            d.SegmentFailed     += new EventHandler <SegmentEventArgs>(download_SegmentFailed);
            d.SegmentStarted    += new EventHandler <SegmentEventArgs>(download_SegmentStarted);
            d.InfoReceived      += new EventHandler(download_InfoReceived);
            d.SegmentStarting   += new EventHandler <SegmentEventArgs>(Downloader_SegmentStarting);

            string ext = Path.GetExtension(d.LocalFile);

            ListViewItem item = new ListViewItem();

            item.ImageIndex = FileTypeImageList.GetImageIndexByExtention(ext);
            item.Text       = Path.GetFileName(d.LocalFile);

            // size
            item.SubItems.Add(ByteFormatter.ToString(d.FileSize));
            // completed
            item.SubItems.Add(ByteFormatter.ToString(d.Transfered));
            // progress
            item.SubItems.Add(String.Format("{0:0.##}%", d.Progress));
            // left
            item.SubItems.Add(TimeSpanFormatter.ToString(d.Left));
            // rate
            item.SubItems.Add("0");
            // added
            item.SubItems.Add(d.CreatedDateTime.ToShortDateString() + " " + d.CreatedDateTime.ToShortTimeString());
            // state
            item.SubItems.Add(d.State.ToString());
            // resume
            item.SubItems.Add(GetResumeStr(d));
            // url
            item.SubItems.Add(d.ResourceLocation.URL);

            mapDownloadToItem[d]    = item;
            mapItemToDownload[item] = d;

            lvwDownloads.Items.Add(item);
        }