コード例 #1
0
 public TorrentViewModel(Torrent torrent, IEventAggregator eventAggregator, ErrorTracker errorTracker, ServerUnits speedUnits, ServerUnits sizeUnits)
 {
     Id = torrent.ID;
     TorrentFileViewModel = new TorrentFileViewModel(Id, eventAggregator, errorTracker);
     Size = torrent.Size.ToSizeString(sizeUnits);
     Hash = torrent.Hash;
     Update(torrent, speedUnits, sizeUnits);
 }
コード例 #2
0
ファイル: ItemViewModel.cs プロジェクト: alexhardwicke/Surge
 public static ItemViewModel Create(File file, FolderViewModel parent, int torrentId, IEventAggregator eventAggregator, ServerUnits sizeUnits)
 {
     return new FileViewModel(file, parent, torrentId, eventAggregator, sizeUnits);
 }
コード例 #3
0
        public void Update(Torrent torrent, ServerUnits speedUnits, ServerUnits sizeUnits)
        {
            // We only update certain properties if the user has a clean object.
            // Otherwise we ignore the change this time, but clear the flag.
            // The reason for this is that when pausing/verifying, the UI
            // is updated instantly (don't wait in a server response).
            if (!IsUserModified)
            {
                IsUserModified = false;
                IsPaused = torrent.IsPaused;
                IsVerifying = torrent.IsVerifying;
            }

            _percentValue = torrent.Percent;
            _magnetResolvedPercentValue = torrent.MagnetResolvedPercent;
            _verifiedPercentValue = torrent.VerifiedPercent;
            IsMagnetResolving = torrent.IsMagnetResolving;
            DownloadSpeed = torrent.DownloadSpeed.ToSizeString(speedUnits);
            UploadSpeed = torrent.UploadSpeed.ToSizeString(speedUnits);
            Availability = torrent.Availability.ToPercent(torrent.Size);
            RemainingTime = torrent.RemainingTime.ToTimeString();
            Downloaded = torrent.Downloaded.ToSizeString(sizeUnits);
            Uploaded = torrent.Uploaded.ToSizeString(sizeUnits);
            RunningTime = torrent.RunningTime.ToTimeString();
            LastActivity = torrent.LastActivity.ToTimeString();
            Percent = torrent.Percent.ToPercent();
            Ratio = torrent.Ratio.ToRatioString();
            Error = torrent.Error.ToNoneIfEmpty();
            Comment = torrent.Comment.ToNoneIfEmpty();
            IsComplete = torrent.Percent == 1.0;
            IsActive = torrent.DownloadSpeed > 0 || torrent.UploadSpeed > 0;
            Queue = torrent.QueuePosition;
            Location = torrent.Location;

            if (torrent.Name != string.Empty)
            {
                Name = torrent.Name;
            }

            if (torrent.Size > 0)
            {
                Size = torrent.Size.ToSizeString(sizeUnits);
            }

            TorrentFileViewModel.Update(torrent.Files, sizeUnits);
        }