Exemple #1
0
        private void UpdateSegmentsInserting(Downloader d, ListViewItem newSelection)
        {
            lastSelection = newSelection;


            List <Block> blocks = new List <Block>();

            for (int i = 0; i < d.Segments.Count; i++)
            {
                ListViewItem item = new ListViewItem();

                item.Text = d.Segments[i].CurrentTry.ToString();
                item.SubItems.Add(String.Format("{0:0.##}%", d.Segments[i].Progress));
                item.SubItems.Add(ByteFormatter.ToString(d.Segments[i].Transfered));
                item.SubItems.Add(ByteFormatter.ToString(d.Segments[i].TotalToTransfer));
                item.SubItems.Add(ByteFormatter.ToString(d.Segments[i].InitialStartPosition));
                item.SubItems.Add(ByteFormatter.ToString(d.Segments[i].EndPosition));
                item.SubItems.Add(String.Format("{0:0.##}", d.Segments[i].Rate / 1024.0));
                item.SubItems.Add(TimeSpanFormatter.ToString(d.Segments[i].Left));
                item.SubItems.Add(d.Segments[i].State.ToString());
                item.SubItems.Add(d.Segments[i].CurrentURL);

                blocks.Add(new Block(d.Segments[i].TotalToTransfer, (float)d.Segments[i].Progress));
            }
        }
Exemple #2
0
        public void RefreshDownloaderData()
        {
            lock (_lockObj)
            {
                if (_downloader.State == DownloaderState.Preparing)
                {
                    lblStatus.Text = "Preparing";
                    return;
                }

                lblUrl.Text    = _downloader.ResourceLocation.URL;
                lblStatus.Text = _downloader.LastError != null
                    ? _downloader.State.ToString() + ", " + _downloader.LastError.Message
                    : _downloader.State.ToString();

                toggleStateButton.Label = _downloader.State == DownloaderState.Working ? "Pause" : "Resume";

                progressBar.Fraction = _downloader.Progress / 100.0;
                lblTransferred.Text  = string.Format("{0} ({1}%)", ByteFormatter.ToString(_downloader.Transfered),
                                                     _downloader.Progress);
                lblTransferRate.Text = TransferRateFormatter.ToString(_downloader.Rate);

                if (_downloader.RemoteFileInfo == null)
                {
                    return;
                }

                lblFileSize.Text  = ByteFormatter.ToString(_downloader.RemoteFileInfo.FileSize);
                lblResumable.Text = _downloader.RemoteFileInfo == null
                    ? "N/A"
                    : (_downloader.RemoteFileInfo.AcceptRanges ? "Yes" : "No");
                lblTimeLeft.Text = TimeSpanFormatter.ToString(_downloader.Left);
            }
        }
Exemple #3
0
        public void UpdateList()
        {
            for (int i = 0; i < lvwDownloads.Items.Count; i++)
            {
                ListViewItem item = lvwDownloads.Items[i];
                if (item == null)
                {
                    return;
                }
                Downloader d = mapItemToDownload[item] as Downloader;
                if (d == null)
                {
                    return;
                }

                DownloaderState state;

                if (item.Tag == null)
                {
                    state = DownloaderState.Working;
                }
                else
                {
                    state = (DownloaderState)item.Tag;
                }

                if (state != d.State ||
                    state == DownloaderState.Working ||
                    state == DownloaderState.WaitingForReconnect)
                {
                    item.SubItems[1].Text = ByteFormatter.ToString(d.FileSize);
                    item.SubItems[2].Text = ByteFormatter.ToString(d.Transfered);
                    item.SubItems[3].Text = String.Format("{0:0.##}%", d.Progress);
                    item.SubItems[4].Text = TimeSpanFormatter.ToString(d.Left);
                    item.SubItems[5].Text = String.Format("{0:0.##}", d.Rate / 1024.0);

                    if (d.LastError != null)
                    {
                        item.SubItems[7].Text = d.State.ToString() + ", " + d.LastError.Message;
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(d.StatusMessage))
                        {
                            item.SubItems[7].Text = d.State.ToString();
                        }
                        else
                        {
                            item.SubItems[7].Text = d.State.ToString() + ", " + d.StatusMessage;
                        }
                    }

                    item.SubItems[8].Text = GetResumeStr(d);
                    item.SubItems[9].Text = d.ResourceLocation.URL;
                    item.Tag = d.State;
                }
            }

            UpdateSegments();
        }
Exemple #4
0
        private async void OnLoadSelectDir(object dirPath)
        {
            if (dirPath == null)
            {
                return;
            }
            try
            {
                var drive = await _hcdzClient.GetSingleDrive(dirPath.ToString());

                if (drive == null)
                {
                    return;
                }
                EnableValue = ByteFormatter.ToString(drive.AvailableFreeSpace) + " 可用";
            }
            catch (Exception ex)
            {
            }

            //if (drives.Count() > 1)
            //{
            //    DriveIndex = 1;
            //}
        }
        private void UpdateSegmentsWithoutInsert(Downloader d)
        {
            for (int i = 0; i < d.Segments.Count; i++)
            {
                lvwSegments.Items[i].SubItems[0].Text = d.Segments[i].CurrentTry.ToString();
                lvwSegments.Items[i].SubItems[1].Text = String.Format("{0:0.##}%", d.Segments[i].Progress);
                lvwSegments.Items[i].SubItems[2].Text = ByteFormatter.ToString(d.Segments[i].Transfered);
                lvwSegments.Items[i].SubItems[3].Text = ByteFormatter.ToString(d.Segments[i].TotalToTransfer);
                lvwSegments.Items[i].SubItems[4].Text = ByteFormatter.ToString(d.Segments[i].InitialStartPosition);
                lvwSegments.Items[i].SubItems[5].Text = ByteFormatter.ToString(d.Segments[i].EndPosition);
                lvwSegments.Items[i].SubItems[6].Text = String.Format("{0:0.##}", d.Segments[i].Rate / 1024.0);
                lvwSegments.Items[i].SubItems[7].Text = TimeSpanFormatter.ToString(d.Segments[i].Left);
                if (d.Segments[i].LastError != null)
                {
                    lvwSegments.Items[i].SubItems[8].Text = d.Segments[i].State.ToString() + ", " + d.Segments[i].LastError.Message;
                }
                else
                {
                    lvwSegments.Items[i].SubItems[8].Text = d.Segments[i].State.ToString();
                }
                lvwSegments.Items[i].SubItems[9].Text = d.Segments[i].CurrentURL;

                this.blockedProgressBar1.BlockList[i].BlockSize       = d.Segments[i].TotalToTransfer;
                this.blockedProgressBar1.BlockList[i].PercentProgress = (float)d.Segments[i].Progress;
            }

            this.blockedProgressBar1.Refresh();
        }
Exemple #6
0
        private async void Init()
        {
            var models = new ObservableCollection <DriveInfoModel>();

            DriveInfo[] drives = await _hcdzClient.GetDrives();

            if (drives == null)
            {
                return;
            }
            foreach (var item in drives)
            {
                var drive = new DriveInfoModel()
                {
                    AvailableFreeSpace     = item.AvailableFreeSpace,
                    AvailableFreeSpaceText = ByteFormatter.ToString(item.AvailableFreeSpace) + " 可用",
                    DriveFormat            = item.DriveFormat,
                    DriveType          = item.DriveType,
                    IsReady            = item.IsReady,
                    Name               = item.Name,
                    RootDirectory      = item.RootDirectory,
                    TotalFreeSpace     = item.TotalFreeSpace,
                    TotalFreeSpaceText = ByteFormatter.ToString(item.TotalFreeSpace),
                    TotalSize          = item.TotalSize,
                    TotalSizeText      = "共" + ByteFormatter.ToString(item.TotalSize),
                    VolumeLabel        = string.IsNullOrEmpty(item.VolumeLabel) ? "本地磁盘 " : item.VolumeLabel,
                    Percent            = 100.0 - (int)(item.AvailableFreeSpace * 100.0 / item.TotalSize),
                    DriveLetter        = item.Name.Replace("\\", "")
                };
                drive.NameDesc = drive.VolumeLabel + string.Format("({0}:)", item.ToString().Replace(":", "").Replace("\\", ""));
                models.Add(drive);
            }
            DriveInfoItems = models;
        }
Exemple #7
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);
        }
Exemple #8
0
        private async void OnLoadSelectDir(object dirPath)
        {
            if (dirPath == null)
            {
                return;
            }
            try
            {
                var drive = await _hcdzClient.GetSingleDrive(dirPath.ToString());

                if (drive == null)
                {
                    return;
                }

                DiskVal     = ByteFormatter.ToString(drive.AvailableFreeSpace) + " 可用";
                DiskPercent = 100.0 - (int)(drive.AvailableFreeSpace * 100.0 / drive.TotalSize);
            }
            catch (Exception ex)
            {
            }

            //if (drives.Count() > 1)
            //{
            //    DriveIndex = 1;
            //}
        }
Exemple #9
0
        public void UpdateList()
        {
            ListView.ListViewItemCollection listViewItemCollection = lvwDownloadTasks.Items;
            for (int i = 0; i < listViewItemCollection.Count; i++)
            {
                ListViewItem item = listViewItemCollection[i];
                if (item == null)
                {
                    return;
                }

                Guid guid = m_DownloadTaskItemMap[item];
                DownloadTaskStatistics downloadTaskStatistics = m_DownloadHelper.GetDownloadTaskStatistics(guid);
                if (downloadTaskStatistics == null)
                {
                    return;
                }

                DownloadTaskState state;

                if (item.Tag == null)
                {
                    state = DownloadTaskState.Working;
                }
                else
                {
                    state = (DownloadTaskState)item.Tag;
                }

                if (state != downloadTaskStatistics.DownloadTaskState ||
                    state == DownloadTaskState.Working ||
                    state == DownloadTaskState.WaitingForReconnect)
                {
                    item.SubItems[1].Text = ByteFormatter.ToString(downloadTaskStatistics.FileSize);
                    item.SubItems[2].Text = ByteFormatter.ToString(downloadTaskStatistics.TransferedDownload);
                    item.SubItems[3].Text = GetDownloadProgressText(downloadTaskStatistics);
                    item.SubItems[4].Text = TimeSpanFormatter.ToString(downloadTaskStatistics.RemainingTime);
                    item.SubItems[5].Text = GetDownloadRateText(downloadTaskStatistics);
                    item.SubItems[6].Text = GetAverageDownloadRateText(downloadTaskStatistics);

                    if (!string.IsNullOrWhiteSpace(downloadTaskStatistics.LastError))
                    {
                        item.SubItems[8].Text = string.Format(CultureInfo.CurrentCulture, "{0}, {1}", downloadTaskStatistics.DownloadTaskState, downloadTaskStatistics.LastError);
                    }
                    else
                    {
                        item.SubItems[8].Text = string.IsNullOrEmpty(downloadTaskStatistics.StatusMessage) ? downloadTaskStatistics.DownloadTaskState.ToString() : string.Format(CultureInfo.CurrentCulture, "{0}, {1}", downloadTaskStatistics.DownloadTaskState, downloadTaskStatistics.StatusMessage);
                    }

                    item.SubItems[9].Text  = GetResumeText(downloadTaskStatistics);
                    item.SubItems[10].Text = downloadTaskStatistics.FileUri.OriginalString;
                    item.Tag = downloadTaskStatistics.DownloadTaskState;
                }
            }

            UpdateSegments();
        }
Exemple #10
0
 public void RefreshUI()
 {
     lblSize.Text = string.Format("{0} ({1} bytes) of {2} ({3} bytes), {4:P}",
                                  ByteFormatter.ToString(Downloader.Transfered),
                                  Downloader.Transfered,
                                  ByteFormatter.ToString(Downloader.RemoteFileInfo?.FileSize ?? 0),
                                  Downloader.RemoteFileInfo?.FileSize.ToString() ?? "N/a",
                                  Downloader.Progress);
 }
Exemple #11
0
        private async void Initializer()
        {
            IsBusy = true;
            //获取远程磁盘
            //DriveInfo[] drives =await _hcdzClient.GetDrives();
            //if (drives!=null)
            //{
            //    DriveInfoItems = new ObservableCollection<DriveInfo>(drives);
            //}
            var models = new ObservableCollection <DriveInfoModel>();

            var drives = await _hcdzClient.GetDrives();

            if (drives == null)
            {
                return;
            }
            //drives = drives.Take(2).ToArray();
            foreach (var item in drives)
            {
                var drive = new DriveInfoModel()
                {
                    AvailableFreeSpace     = item.AvailableFreeSpace,
                    AvailableFreeSpaceText = ByteFormatter.ToString(item.AvailableFreeSpace) + " 可用",
                    DriveFormat            = item.DriveFormat,
                    DriveType          = item.DriveType,
                    IsReady            = item.IsReady,
                    Name               = item.Name,
                    RootDirectory      = item.RootDirectory,
                    TotalFreeSpace     = item.TotalFreeSpace,
                    TotalFreeSpaceText = ByteFormatter.ToString(item.TotalFreeSpace),
                    TotalSize          = item.TotalSize,
                    TotalSizeText      = "共" + ByteFormatter.ToString(item.TotalSize),
                    VolumeLabel        = string.IsNullOrEmpty(item.VolumeLabel) ? "本地磁盘 " : item.VolumeLabel,
                    Percent            = 100.0 - (int)(item.AvailableFreeSpace * 100.0 / item.TotalSize),
                    DriveLetter        = item.Name.Replace("\\", "")
                };
                drive.NameDesc = drive.VolumeLabel + string.Format("({0}:)", item.ToString().Replace(":", "").Replace("\\", ""));
                models.Add(drive);
            }
            DriveInfoItems = models;
            var items = await List();

            if (items != null)
            {
                DirectoryItems = new ObservableCollection <DirectoryInfoModel>(items);
            }
            SelectedPath = DriveInfoItems.FirstOrDefault()?.Name;
            EnableValue  = DriveInfoItems.FirstOrDefault()?.AvailableFreeSpaceText;
            if (!string.IsNullOrEmpty(SelectedPath))
            {
                OnLoadSelectDir(SelectedPath.Substring(0, 3));
            }

            IsBusy = false;
        }
 void download_SegmentStarted(object sender, SegmentEventArgs e)
 {
     Log(
         e.Downloader,
         String.Format(
             "Started segment for {3}, start position = {0}, end position {1}, segment size = {2}",
             ByteFormatter.ToString(e.Segment.InitialStartPosition),
             ByteFormatter.ToString(e.Segment.EndPosition),
             ByteFormatter.ToString(e.Segment.TotalToTransfer),
             e.Downloader.ResourceLocation.URL),
         LogMode.Information);
 }
        void download_InfoReceived(object sender, EventArgs e)
        {
            Downloader d = (Downloader)sender;

            Log(
                d,
                String.Format(
                    "Connected to: {2}. File size = {0}, Resume = {1}",
                    ByteFormatter.ToString(d.FileSize),
                    d.RemoteFileInfo.AcceptRanges,
                    d.ResourceLocation.URL),
                LogMode.Information);
        }
Exemple #14
0
        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();

            //ListViewItem.ListViewSubItem subItem;

            item.ImageIndex = FileTypeImageList.GetImageIndexByExtention(ext);
            //lvwDownloads.Columns["columnFile"].ImageIndex = FileTypeImageList.GetImageIndexByExtention(ext);
            //lvwDownloads.Columns[1].ImageIndex = FileTypeImageList.GetImageIndexByExtention(ext);

            //item.Text = Path.GetFileName(d.LocalFile);
            //item.Text = d.Id.ToString();
            item.Text = (d.OrderedIndex + 1).ToString();

            // Id
            item.SubItems.Add(d.Id.ToString());
            //File
            item.SubItems.Add(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);
        }
        private void AddDownload(Downloader d)
        {
            string ext = System.IO.Path.GetExtension(d.LocalFile);

            DownLoadFileInfo dInfo = new DownLoadFileInfo();

            dInfo.FileName              = System.IO.Path.GetFileName(d.LocalFile);
            dInfo.FileSize              = ByteFormatter.ToString(d.FileSize);
            dInfo.DownloadProcess       = d.Progress;
            dInfo.FileLink              = d.ResourceLocation.URL;
            dInfo.FileAlbum             = d.ResourceLocation.Password;
            dInfo.DownloadState         = d.State;
            mapDownloadToObj[d]         = dInfo;
            mapObjToDownload[dInfo]     = d;
            mapObjToCurrentState[dInfo] = d.State;
            DownloadingList.Add(dInfo);
        }
Exemple #16
0
        private void UpdateSegmentsWithoutInsert(SegmentDownloaderInfoCollection segmentDownloaderInfoCollection)
        {
            for (int i = 0; i < segmentDownloaderInfoCollection.Count; i++)
            {
                ISegmentDownloaderInfo segmentDownloaderInfo = segmentDownloaderInfoCollection[i];
                ListViewItem           listViewItem          = lvwDownloadTaskSegments.Items[i];
                listViewItem.SubItems[0].Text = string.Format("{0:0.##}%", segmentDownloaderInfo.DownloadProgress);
                listViewItem.SubItems[1].Text = ByteFormatter.ToString(segmentDownloaderInfo.TransferedDownload);
                listViewItem.SubItems[2].Text = ByteFormatter.ToString(segmentDownloaderInfo.EndPosition - segmentDownloaderInfo.StartPosition);
                listViewItem.SubItems[3].Text = ByteFormatter.ToString(segmentDownloaderInfo.StartPosition);
                listViewItem.SubItems[4].Text = ByteFormatter.ToString(segmentDownloaderInfo.EndPosition);
                listViewItem.SubItems[5].Text = string.Format("{0:0.##}", segmentDownloaderInfo.DownloadRate / 1024.0);
                listViewItem.SubItems[6].Text = TimeSpanFormatter.ToString(segmentDownloaderInfo.RemainingTime);
                listViewItem.SubItems[7].Text = segmentDownloaderInfo.LastException != null?string.Format(CultureInfo.CurrentCulture, "{0}, {1}", segmentDownloaderInfo.State, segmentDownloaderInfo.LastException.Message) : segmentDownloaderInfo.State.ToString();

                listViewItem.SubItems[8].Text = segmentDownloaderInfo.Uri.OriginalString;
            }
        }
Exemple #17
0
 private void Fill(Segment s)
 {
     CurrentTry           = s.CurrentTry;
     Progress             = String.Format("{0:0.##}%", s.Progress);
     ProgressInt          = (int)s.Progress;
     Transferred          = ByteFormatter.ToString(s.Transfered);
     TotalToTransfer      = ByteFormatter.ToString(s.TotalToTransfer);
     InitialStartPosition = ByteFormatter.ToString(s.InitialStartPosition);
     EndPosition          = ByteFormatter.ToString(s.EndPosition);
     TransferRate         = TransferRateFormatter.ToString(s.Rate);
     TimeLeft             = TimeSpanFormatter.ToString(s.Left);
     if (s.LastError != null)
     {
         StateMessage = s.State.ToString() + ", " + s.LastError.Message;
     }
     else
     {
         StateMessage = s.State.ToString();
     }
     CurrentUrl = s.CurrentURL;
 }
Exemple #18
0
        void Fill(Downloader d)
        {
            FileName = System.IO.Path.GetFileName(d.LocalFile);
            // size
            FileSize = ByteFormatter.ToString(d.FileSize);
            // completed
            Transferred = ByteFormatter.ToString(d.Transfered);
            // progress
            Progress = String.Format("{0:0.##}%", d.Progress);
            // left
            TimeLeft = TimeSpanFormatter.ToString(d.Left);
            // rate
            TransferRate = String.Format("{0:0.##}", d.Rate / 1024.0);
            // added
            DateAdded = d.CreatedDateTime.ToShortDateString() + " " + d.CreatedDateTime.ToShortTimeString();
            // resume
            SupportsResume = DownloadList.GetResumeStr(d);
            // url
            Url = d.ResourceLocation.URL;

            SaveTo = d.LocalFile;

            if (d.LastError != null)
            {
                StateMessage = d.State.ToString() + ", " + d.LastError.Message;
            }
            else
            {
                if (String.IsNullOrEmpty(d.StatusMessage))
                {
                    StateMessage = d.State.ToString();
                }
                else
                {
                    StateMessage = d.State.ToString() + ", " + d.StatusMessage;
                }
            }

            Tag = d.State;
        }
Exemple #19
0
        public void SetDownloadData(Downloader d)
        {
            _downloader = d;

            _lblFileName.Text = IO.Path.GetFileName(d.LocalFile);

            string size = d.RemoteFileInfo == null ? "N/a" : ByteFormatter.ToString(d.RemoteFileInfo.FileSize);

            _lblSize.Text = string.Format("({0} {1:P})", size, _downloader.Progress / 100.0);

            _lblStatus.Text = _downloader.State.ToString();

            string fileType = IO.Path.GetExtension(_downloader.LocalFile)?.Trim('.').ToUpper();

            _lblType.Text = string.IsNullOrEmpty(fileType) ? "N/a" : string.Format("{0} File", fileType);

            _txtDest.Text      = _downloader.LocalFile;
            _txtDest.Sensitive = false;

            if (_downloader.IsWorking())
            {
                _txtUrl.Sensitive    = false;
                _btnBrowse.Sensitive = false;
            }
            _txtUrl.Text = _downloader.ResourceLocation.URL;

            _cbAuth.Active = _downloader.ResourceLocation.Authenticate;
            CbAuthOnToggled(null, null);
            _txtUser.Text     = _downloader.ResourceLocation.Login ?? "";
            _txtPassword.Text = _downloader.ResourceLocation.Password ?? "";


            if (_downloader.State == DownloaderState.Ended)
            {
                AddButton("Open", ResponseType.Apply);
            }
        }
Exemple #20
0
        private void UpdateSegmentsInserting(ListViewItem newSelection, SegmentDownloaderInfoCollection segmentDownloaderInfoCollection)
        {
            m_LastDownloadTaskSelection = newSelection;

            lvwDownloadTaskSegments.Items.Clear();

            for (int i = 0; i < segmentDownloaderInfoCollection.Count; i++)
            {
                ListViewItem item = new ListViewItem();

                ISegmentDownloaderInfo segmentDownloaderInfo = segmentDownloaderInfoCollection[i];
                item.Text = string.Format("{0:0.##}%", segmentDownloaderInfo.DownloadProgress);
                item.SubItems.Add(ByteFormatter.ToString(segmentDownloaderInfo.TransferedDownload));
                item.SubItems.Add(ByteFormatter.ToString(segmentDownloaderInfo.EndPosition - segmentDownloaderInfo.StartPosition));
                item.SubItems.Add(ByteFormatter.ToString(segmentDownloaderInfo.StartPosition));
                item.SubItems.Add(ByteFormatter.ToString(segmentDownloaderInfo.EndPosition));
                item.SubItems.Add(string.Format("{0:0.##}", segmentDownloaderInfo.DownloadRate / 1024.0));
                item.SubItems.Add(TimeSpanFormatter.ToString(segmentDownloaderInfo.RemainingTime));
                item.SubItems.Add(segmentDownloaderInfo.State.ToString());
                item.SubItems.Add(segmentDownloaderInfo.Uri.OriginalString);

                lvwDownloadTaskSegments.Items.Add(item);
            }
        }
Exemple #21
0
        public void UpdateList(bool all = true)
        {
            for (int i = 0; i < lvwDownloads.Items.Count; i++)
            {
                ListViewItem item = lvwDownloads.Items[i];
                if (item == null)
                {
                    return;
                }
                //Downloader d = mapItemToDownload[item] as Downloader;
                Downloader d = DownloadManager.Instance.GetOrderedDownloader(item.Index);
                if (d == null)
                {
                    return;
                }

                DownloaderState state;

                if (item.Tag == null)
                {
                    state = DownloaderState.Working;
                }
                else
                {
                    state = (DownloaderState)item.Tag;
                }

                if (all || state != d.State || state == DownloaderState.Working || state == DownloaderState.WaitingForReconnect)
                {
                    item.Text = (d.OrderedIndex + 1).ToString();
                    int indexColumnSize = 3;
                    int indexColumn     = indexColumnSize;
                    item.SubItems[indexColumn++].Text = ByteFormatter.ToString(d.FileSize);
                    item.SubItems[indexColumn++].Text = ByteFormatter.ToString(d.Transfered);
                    item.SubItems[indexColumn++].Text = String.Format("{0:0.##}%", d.Progress);
                    item.SubItems[indexColumn++].Text = TimeSpanFormatter.ToString(d.Left);
                    item.SubItems[indexColumn++].Text = String.Format("{0:0.##}", d.Rate / 1024.0);
                    indexColumn++; // column Added
                    if (d.LastError != null)
                    {
                        item.SubItems[indexColumn].Text = d.State.ToString() + ", " + d.LastError.Message;
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(d.StatusMessage))
                        {
                            item.SubItems[indexColumn].Text = d.State.ToString();
                        }
                        else
                        {
                            item.SubItems[indexColumn].Text = d.State.ToString() + ", " + d.StatusMessage;
                        }
                    }
                    indexColumn++; // column State

                    item.SubItems[indexColumn++].Text = GetResumeStr(d);
                    item.SubItems[indexColumn++].Text = d.ResourceLocation.URL;
                    item.Tag = d.State;
                }
            }

            UpdateSegments();
        }
 private void UpdateControls()
 {
     lblMinSize.Text = ByteFormatter.ToString((int)numMinSegSize.Value);
 }