Пример #1
0
            private string GetDownloadProgressText(DownloadItemStatus downloadStatus, long?downloadedSize, long?totalSize)
            {
                if (downloadStatus == DownloadItemStatus.COMPLETED && totalSize.HasValue)
                {
                    return(localization.GetDownloadProgress(totalSize.Value, totalSize.Value, 100));
                }
                else if (downloadedSize.HasValue && totalSize.HasValue)
                {
                    int percentage = (int)Math.Truncate(GetDownloadProgressValue(status, downloadedSize, totalSize));
                    return(localization.GetDownloadProgress(downloadedSize.Value, totalSize.Value, percentage));
                }
                else
                {
                    switch (downloadStatus)
                    {
                    case DownloadItemStatus.QUEUED:
                        return(localization.QueuedStatus);

                    case DownloadItemStatus.DOWNLOADING:
                        return(localization.DownloadingStatus);

                    case DownloadItemStatus.STOPPED:
                        return(localization.StoppedStatus);

                    case DownloadItemStatus.ERROR:
                        return(localization.ErrorStatus);

                    default:
                        throw new Exception($"Unexpected collection download status: {downloadStatus}.");
                    }
                }
            }
Пример #2
0
        public void should_not_process_if_download_status_isnt_completed(DownloadItemStatus status)
        {
            _trackedDownload.DownloadItem.Status = status;

            Subject.Process(_trackedDownload);

            AssertNoAttemptedImport();
        }
Пример #3
0
 public void UpdateStatus(DownloadItemStatus newStatus)
 {
     Status = newStatus;
     if (newStatus == DownloadItemStatus.COMPLETED && !totalSize.HasValue)
     {
         totalSize = 0;
     }
     UpdateProgressTextAndValue();
 }
Пример #4
0
 private void ReportStatusChange(DownloadItem downloadItem, DownloadItemStatus newStatus, DownloadItemLogLineType logLineType, string logMessage)
 {
     lock (downloadQueueLock)
     {
         AddLogLine(downloadItem, logLineType, logMessage);
         downloadItem.Status = newStatus;
         ReportChange(downloadItem);
     }
 }
Пример #5
0
 public DownloadItemViewModel(SharedSetupContext.Collection collection, DownloadDumpsSetupStepLocalizator localization)
 {
     this.localization = localization;
     Collection        = collection;
     name           = GetDownloadName(collection.Identifier);
     status         = collection.DownloadStatus;
     downloadedSize = collection.DownloadedSize;
     totalSize      = collection.TotalSize;
     UpdateProgressTextAndValue();
 }
Пример #6
0
 public DownloadItemViewModel(Guid id, string name, DownloadItemStatus status, string progressText, double progressValue,
                              string downloadDirectory, IEnumerable <DownloadItemLogLineViewModel> logs)
 {
     Id                 = id;
     this.name          = name;
     this.status        = status;
     this.progressText  = progressText;
     this.progressValue = progressValue;
     isSelected         = false;
     DownloadDirectory  = downloadDirectory;
     this.logs          = new ObservableCollection <DownloadItemLogLineViewModel>(logs);
 }
Пример #7
0
 private static double GetDownloadProgressValue(DownloadItemStatus status, long?downloadedSize, long?totalSize)
 {
     if (status == DownloadItemStatus.COMPLETED)
     {
         return(100);
     }
     else if (downloadedSize.HasValue && totalSize.HasValue)
     {
         return((double)downloadedSize.Value * 100 / totalSize.Value);
     }
     else
     {
         return(0);
     }
 }
Пример #8
0
        public void GetItems_should_return_downloading_item_as_downloadItemStatus(TransmissionTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus)
        {
            _downloading.Status = apiStatus;

            PrepareClientToReturnDownloadingItem();

            var item = Subject.GetItems().Single();

            item.Status.Should().Be(expectedItemStatus);
        }
Пример #9
0
        public void GetItems_should_return_completed_item_as_downloadItemStatus(UTorrentTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus, bool expectedValue)
        {
            _completed.Status = apiStatus;

            PrepareClientToReturnCompletedItem();

            var item = Subject.GetItems().Single();

            item.Status.Should().Be(expectedItemStatus);
            item.CanBeRemoved.Should().Be(expectedValue);
            item.CanMoveFiles.Should().Be(expectedValue);
        }
Пример #10
0
        public void GetItems_should_return_queued_item_as_downloadItemStatus(UTorrentTorrentStatus apiStatus, DownloadItemStatus expectedItemStatus)
        {
            _queued.Status = apiStatus;

            PrepareClientToReturnQueuedItem();

            var item = Subject.GetItems().Single();

            item.Status.Should().Be(expectedItemStatus);
        }
Пример #11
0
        public void GetItems_should_return_completed_item_as_downloadItemStatus(String apiStatus, DownloadItemStatus expectedItemStatus, Boolean expectedReadOnly)
        {
            _completed.State = apiStatus;

            PrepareClientToReturnCompletedItem();

            var item = Subject.GetItems().Single();

            item.Status.Should().Be(expectedItemStatus);
            item.IsReadOnly.Should().Be(expectedReadOnly);
        }
Пример #12
0
 private bool IsCompleted(DownloadItemStatus downloadItemStatus)
 {
     return(downloadItemStatus == DownloadItemStatus.COMPLETED);
 }
Пример #13
0
 private bool CanBeStopped(DownloadItemStatus downloadItemStatus)
 {
     return(downloadItemStatus == DownloadItemStatus.QUEUED || downloadItemStatus == DownloadItemStatus.DOWNLOADING ||
            downloadItemStatus == DownloadItemStatus.RETRY_DELAY);
 }
Пример #14
0
 private bool CanBeStarted(DownloadItemStatus downloadItemStatus)
 {
     return(downloadItemStatus == DownloadItemStatus.STOPPED || downloadItemStatus == DownloadItemStatus.ERROR);
 }
Пример #15
0
 private void SetItemStatus(DownloadViewItem item, DownloadItemStatus status)
 {
     item.Status = status;
     this.Invoke((Action)(() => item.UpdateStatus()));
     Thread.Sleep(0);
 }
Пример #16
0
    private void SetItemStatus(DownloadViewItem item, DownloadItemStatus status)
    {
      item.Status = status;
			this.Invoke((Action) (() => item.UpdateStatus()));
      Thread.Sleep(0);
    }