コード例 #1
0
        public async void TorrentChanged(ListView obj, TorrentInfo inf)
        {
            try
            {
                SelectedTorrents = obj.SelectedItems.Cast <TorrentInfo>().ToArray();

                _moreInfoCancelTokeSource?.Cancel();
                _moreInfoCancelTokeSource = new CancellationTokenSource();

                await Task.Delay(250, _moreInfoCancelTokeSource.Token);

                if (_moreInfoCancelTokeSource.Token.IsCancellationRequested)
                {
                    return;
                }
                selectedIDs = SelectedTorrents.Select(x => x.Id).ToArray();

                if (ConfigService.Instanse.MoreInfoShow)
                {
                    UpdateMoreInfoPosition(SelectedTorrents.Any());
                    UpdateMoreInfoView(_moreInfoCancelTokeSource.Token);
                }
            }
            catch (TaskCanceledException)
            {
            }
        }
コード例 #2
0
 /// <summary>
 /// Open torrent properties popUp by double click on grid or RightClickMenu on torrent row.
 /// </summary>
 /// <param name="sender">sender...</param>
 /// <param name="torrentRow">Torrent..</param>
 public void Properties(object?sender, TorrentInfo?torrentRow)
 {
     if (_transmissionClient != null)
     {
         if (selectedIDs != null)
         {
             if (selectedIDs.Length > 1)
             {
                 manager.ShowDialogAsync(new TorrentPropsViewModel(_transmissionClient,
                                                                   SelectedTorrents.Select(x => x.Id).ToArray(), manager));
             }
             else
             {
                 manager.ShowDialogAsync(new TorrentPropsViewModel(
                                             _transmissionClient,
                                             new[] { SelectedTorrents.Select(x => x.Id).First() },
                                             manager));
             }
         }
         else if (sender is ListView && torrentRow is TorrentInfo selectedTorrent)
         {
             manager.ShowDialogAsync(new TorrentPropsViewModel(_transmissionClient, new[] { torrentRow.Id }, manager));
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Remove selected torrents and downloaded files
        /// </summary>
        private void RemoveTorrentWithData()
        {
            try
            {
                var result = _dialogService.ShowMessageBox(Res.ConfirmTorrentRemovalWithData,
                                                           Res.ApplicationTitle, MessageBoxButton.YesNo);

                if (result == MessageBoxResult.Yes)
                {
                    _torrentService.RemoveTorrentsAsync(SelectedTorrents.Cast <TorrentEntity>().ToList(), true);
                }
            }
            catch (Exception ex)
            {
                _dialogService.ShowMessageBox(ex.ToString());
            }
        }
コード例 #4
0
        /// <summary>
        /// Set the priority of all files in a torrent
        /// </summary>
        /// <param name="param">The parameter.</param>
        private void SetTorrentPriority(string param)
        {
            TorrentPriority priority;

            if (param.Equals(TorrentPriority.Low.ToString()))
            {
                priority = TorrentPriority.Low;
            }
            else if (param.Equals(TorrentPriority.High.ToString()))
            {
                priority = TorrentPriority.High;
            }
            else
            {
                priority = TorrentPriority.Normal;
            }

            _torrentService.SetTorrentPriority(SelectedTorrents.Cast <TorrentEntity>().ToList(), priority);
        }