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}."); } } }
public void should_not_process_if_download_status_isnt_completed(DownloadItemStatus status) { _trackedDownload.DownloadItem.Status = status; Subject.Process(_trackedDownload); AssertNoAttemptedImport(); }
public void UpdateStatus(DownloadItemStatus newStatus) { Status = newStatus; if (newStatus == DownloadItemStatus.COMPLETED && !totalSize.HasValue) { totalSize = 0; } UpdateProgressTextAndValue(); }
private void ReportStatusChange(DownloadItem downloadItem, DownloadItemStatus newStatus, DownloadItemLogLineType logLineType, string logMessage) { lock (downloadQueueLock) { AddLogLine(downloadItem, logLineType, logMessage); downloadItem.Status = newStatus; ReportChange(downloadItem); } }
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(); }
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); }
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); } }
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); }
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); }
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); }
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); }
private bool IsCompleted(DownloadItemStatus downloadItemStatus) { return(downloadItemStatus == DownloadItemStatus.COMPLETED); }
private bool CanBeStopped(DownloadItemStatus downloadItemStatus) { return(downloadItemStatus == DownloadItemStatus.QUEUED || downloadItemStatus == DownloadItemStatus.DOWNLOADING || downloadItemStatus == DownloadItemStatus.RETRY_DELAY); }
private bool CanBeStarted(DownloadItemStatus downloadItemStatus) { return(downloadItemStatus == DownloadItemStatus.STOPPED || downloadItemStatus == DownloadItemStatus.ERROR); }
private void SetItemStatus(DownloadViewItem item, DownloadItemStatus status) { item.Status = status; this.Invoke((Action)(() => item.UpdateStatus())); Thread.Sleep(0); }
private void SetItemStatus(DownloadViewItem item, DownloadItemStatus status) { item.Status = status; this.Invoke((Action) (() => item.UpdateStatus())); Thread.Sleep(0); }