Exemple #1
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 #2
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;
 }