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); }
private void RemoveFromCollection(TorrentViewModel torrentViewModel) { Torrents.Remove(torrentViewModel); torrentViewModel.PropertyChanged -= TorrentViewModel_PropertyChanged; }
private void AddToCollection(TorrentViewModel torrentViewModel) { Torrents.Add(torrentViewModel); torrentViewModel.PropertyChanged += TorrentViewModel_PropertyChanged; }