예제 #1
0
        /// <summary>
        /// Adds the torrent to session.
        /// </summary>
        public void AddTorrentToSession()
        {
            _torrentTask.Wait(3000);

            if (_torrentTask.IsCompleted)
            {
                _torrentService.AddTorrentToSession(Torrent);
                _dialogService.Close(this);
            }
            else
            {
                Torrent   = null;
                InfoText  = string.Empty;
                IsWorking = false;
                _dialogService.ShowMessageBox(Res.InvalidTorrent, messageBoxImage: MessageBoxImage.Error);
                _dialogService.Close(this);
            }
        }
예제 #2
0
        /// <summary>
        /// Open dialog to let user select files to download or cancel
        /// </summary>
        /// <param name="torrent">The torrent.</param>
        private void AddNewTorrent(Task <TorrentEntity> torrent)
        {
            try
            {
                // MainWindow must've been shown before it can be used as an owner for dialog windows
                // This check with possible action is needed since this method could run on application startup before the MainWindow has been shown
                if (!Application.Current.MainWindow.IsLoaded)
                {
                    Application.Current.MainWindow.Show();
                }

                var win = _serviceManager.Get <AddNewTorrentViewModel>();
                win.Initialize(torrent, Torrents);

                if (_dialogService.ShowDialog(win) == true)
                {
                    _torrentService.AddTorrentToSession(win.Torrent);
                }
            }
            catch (Exception ex)
            {
                _dialogService.ShowMessageBox(ex.Message);
            }
        }