private void ShowTorrentDetails(TorrentLinkVM torLink) { SetAttachedSeries(null); if (!torrentDetailsWorker.IsBusy) { torrentDetailsWorker.RunWorkerAsync(torLink); } }
void torrentDownload(object sender, RoutedEventArgs e) { try { this.Cursor = Cursors.Wait; this.IsEnabled = false; MenuItem item = e.Source as MenuItem; MenuItem itemSender = sender as MenuItem; if (item == null || itemSender == null) { return; } if (!item.Header.ToString().Equals(itemSender.Header.ToString())) { return; } if (item != null && item.CommandParameter != null) { Window parentWindow = Window.GetWindow(this); parentWindow.Cursor = Cursors.Wait; this.IsEnabled = false; TorrentLinkVM torLink = item.CommandParameter as TorrentLinkVM; torLink.Source.PopulateTorrentDownloadLink(ref torLink); if (!AppSettings.TorrentBlackhole) { UTorrentHelperVM.Instance.AddTorrentFromURL(torLink.TorrentDownloadLink); } else { if (!string.IsNullOrEmpty(AppSettings.TorrentBlackholeFolder)) { using (WebClient client = new WebClient()) { client.DownloadFileAsync(new Uri(torLink.TorrentDownloadLink), AppSettings.TorrentBlackholeFolder + "\\" + GetValidFileName(torLink.TorrentName + ".torrent")); } } } parentWindow.Cursor = Cursors.Arrow; this.IsEnabled = true; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; this.IsEnabled = true; } }
void dgTorrents_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataGrid _DataGrid = sender as DataGrid; TorrentLinkVM torLink = _DataGrid.SelectedItem as TorrentLinkVM; if (torLink == null) { return; } ShowTorrentDetails(torLink); }
void dgTorrents_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { DataGrid _DataGrid = sender as DataGrid; TorrentLinkVM torLink = _DataGrid.SelectedItem as TorrentLinkVM; if (torLink == null) { return; } ShowTorrentDetails(torLink); }
private bool LinkSearchFilter(object obj) { TorrentLinkVM torLink = obj as TorrentLinkVM; if (torLink == null) { return(true); } int index = torLink.TorrentName.IndexOf(txtFileSearch.Text.Trim(), 0, StringComparison.InvariantCultureIgnoreCase); if (index > -1) { return(true); } return(false); }
void dgTorrents_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataGrid _DataGrid = sender as DataGrid; TorrentLinkVM torLink = _DataGrid.SelectedItem as TorrentLinkVM; if (torLink == null) { return; } DetailsContainer details = new DetailsContainer(); details.TorLink = torLink; details.SearchCritera = CurrentSearchCriteria; ShowTorrentDetails(details); }
void torrentDetailsWorker_DoWork(object sender, DoWorkEventArgs e) { TorrentLinkVM torLink = e.Argument as TorrentLinkVM; // try and find the series foreach (AniDB_AnimeVM anime in AniDB_AnimeVM.BestLevenshteinDistanceMatchesCache(torLink.ClosestAnimeMatchString, 10)) { // get the series for the anime AnimeSeriesVM ser = MainListHelperVM.Instance.GetSeriesForAnime(anime.AnimeID); if (ser != null) { e.Result = ser; return; } } e.Result = null; }
void torrentDownload(object sender, RoutedEventArgs e) { try { this.Cursor = Cursors.Wait; this.IsEnabled = false; MenuItem item = e.Source as MenuItem; MenuItem itemSender = sender as MenuItem; if (item == null || itemSender == null) { return; } if (!item.Header.ToString().Equals(itemSender.Header.ToString())) { return; } if (item != null && item.CommandParameter != null) { Window parentWindow = Window.GetWindow(this); parentWindow.Cursor = Cursors.Wait; this.IsEnabled = false; TorrentLinkVM torLink = item.CommandParameter as TorrentLinkVM; torLink.Source.PopulateTorrentDownloadLink(ref torLink); UTorrentHelperVM.Instance.AddTorrentFromURL(torLink.TorrentDownloadLink); parentWindow.Cursor = Cursors.Arrow; this.IsEnabled = true; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; this.IsEnabled = true; } }
void Row_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { DataGridRow dgr = sender as DataGridRow; if (dgr == null) { return; } dgTorrents.SelectedItem = dgr.DataContext; ContextMenu m = new ContextMenu(); TorrentLinkVM torLink = dgTorrents.SelectedItem as TorrentLinkVM; if (torLink == null) { return; } MenuItem itemStart = new MenuItem(); itemStart.Header = "Download"; itemStart.Click += new RoutedEventHandler(torrentDownload); itemStart.CommandParameter = torLink; m.Items.Add(itemStart); if (!string.IsNullOrEmpty(torLink.TorrentLink)) { MenuItem itemLink = new MenuItem(); itemLink.Header = "Go to Website"; itemLink.Click += new RoutedEventHandler(torrentBrowseWebsite); itemLink.CommandParameter = torLink; m.Items.Add(itemLink); } m.IsOpen = true; }
void torrentBrowseWebsite(object sender, RoutedEventArgs e) { try { MenuItem item = e.Source as MenuItem; MenuItem itemSender = sender as MenuItem; if (item == null || itemSender == null) { return; } if (!item.Header.ToString().Equals(itemSender.Header.ToString())) { return; } if (item != null && item.CommandParameter != null) { Window parentWindow = Window.GetWindow(this); parentWindow.Cursor = Cursors.Wait; this.IsEnabled = false; TorrentLinkVM torLink = item.CommandParameter as TorrentLinkVM; Uri uri = new Uri(torLink.TorrentLinkFull); Process.Start(new ProcessStartInfo(uri.AbsoluteUri)); parentWindow.Cursor = Cursors.Arrow; this.IsEnabled = true; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }