예제 #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;
 }