コード例 #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;
 }