示例#1
0
        public void AddNewTorrent(string source)
        {
            var(torrentHandle, downloadLocation, name) = _torrentSessionService.AddTorrent(source, true);
            var torrentSource    = source.StartsWith("magnet") ? source : _persistenceService.PersistTorrentFile(source);
            var torrentViewModel = new TorrentViewModel
            {
                Name             = name,
                Size             = torrentHandle.torrent_file()?.total_size() ?? 0,
                QueuePosition    = torrentHandle.queue_position(),
                TorrentSource    = torrentSource,
                TorrentHandle    = torrentHandle,
                DownloadLocation = downloadLocation,
                Active           = true
            };

            AddToCollection(torrentViewModel);
        }
示例#2
0
 private void RemoveFromCollection(TorrentViewModel torrentViewModel)
 {
     Torrents.Remove(torrentViewModel);
     torrentViewModel.PropertyChanged -= TorrentViewModel_PropertyChanged;
 }
示例#3
0
 private void AddToCollection(TorrentViewModel torrentViewModel)
 {
     Torrents.Add(torrentViewModel);
     torrentViewModel.PropertyChanged += TorrentViewModel_PropertyChanged;
 }