/// <summary> /// checkmyList - try to download all checked movies in the list. /// also run torrent program on the local pc. /// </summary> private void checkmyList() { App.Current.Dispatcher.Invoke(delegate { XElement xmlFile = XElement.Load("moviesList.xml"); if (xmlFile.Elements().Count() == 0 || listView.Items.Count == 0) { System.Windows.MessageBox.Show("no movies in the list, please add one first", "Torrent Seeker Message", MessageBoxButton.OK, MessageBoxImage.Information); return; } bool noItemsSelected = true; foreach (var item in listView.Items) { movieItem movieitem = item as movieItem; if (movieitem.checkbox.IsChecked == true) { noItemsSelected = false; string torrent = Execute.downloadLinkFromWeb(movieitem.movieName.Text); if (torrent != "-1") { Execute.run_torrent(torrent); } } } if (noItemsSelected) { MessageBox.Show("No movies selected from the list, please select at least one", "Torrent Seeker Message", MessageBoxButton.OK, MessageBoxImage.Information); } stopAnimation(); }); }
/// <summary> /// convert feedItem to movieItem, add him to xml file and to listbox /// </summary> /// <param name="fi"></param> private void addFeedItemtoCheckList(feedItem fi) { movieItem mi = new movieItem(); ListBoxItem item = new ListBoxItem(); movieItem movie_item = new movieItem(); movie_item.movieName.Text = fi.label.Content.ToString(); if (fi.circleImage != null && fi.circleImage.ImageSource.ToString() != "/TorrentChecker;component/images/add-icon.png") { var uri = new Uri(fi.circleImage.ImageSource.ToString()); var bitmap = new BitmapImage(uri); movie_item.movieImage.ImageSource = bitmap; } listView.Items.Add(movie_item); // add to xml XElement xmlFile; XElement newElement = new XElement("movie", new XElement("name", movie_item.movieName.Text), new XElement("image", movie_item.movieImage.ImageSource), new XElement("torrent", movie_item.torrentLinkString.Content)); if (!File.Exists(Directory.GetCurrentDirectory() + "\\moviesList.xml")) { xmlFile = new XElement("movies", newElement); } else { xmlFile = XElement.Load("moviesList.xml"); xmlFile.Add(newElement); } xmlFile.Save("moviesList.xml"); }
/// <summary> /// delete movie item from xml file and from listbox /// </summary> /// <param name="sender"></param> public void removeItem(object sender) { if (!(sender is movieItem)) { return; } movieItem movieItemSender = sender as movieItem; string movieName = movieItemSender.movieName.Text; XElement xmlFile = XElement.Load("moviesList.xml"); (from m in xmlFile.Elements() where m.Element("name").Value == movieName select m).FirstOrDefault().Remove(); xmlFile.Save("moviesList.xml"); movieItem temp = null; foreach (movieItem item in listView.Items) { if (item.movieName.Text == movieName) { temp = item; break; } } if (temp != null) { listView.Items.Remove(temp); } }
public void removeItem(object sender) { if (!(sender is movieItem)) { return; } movieItem movieItemSender = sender as movieItem; string movieName = movieItemSender.movieName.Text; XElement xmlFile = XElement.Load("moviesList.xml"); (from m in xmlFile.Elements() where m.Element("name").Value == movieName select m).FirstOrDefault().Remove(); xmlFile.Save("moviesList.xml"); movieItem temp = null; Master wnd = (Master)Window.GetWindow(this); mainPage mp = (mainPage)wnd.mainFrame.Content; foreach (movieItem item in mp.listView.Items) { if (item.movieName.Text == movieName) { temp = item; break; } } if (temp != null) { mp.listView.Items.Remove(temp); } }
/// <summary> /// load the items from xml file to listbox /// </summary> /// <param name="image"></param> /// <param name="name"></param> private void loadCheckList(string image, string name) { ListBoxItem item = new ListBoxItem(); movieItem movie_item = new movieItem(); movie_item.movieName.Text = name; string img = image; // if the image is not the defult image if (img != null && !img.Contains(@"/TorrentChecker;component/images/")) { var uri = new Uri(img); var bitmap = new BitmapImage(uri); movie_item.movieImage.ImageSource = bitmap; } listView.Items.Add(movie_item); }
private void addMovieItemtoNewMovieList(movieItem mi) { feedItem fi = new feedItem(); fi.label.Content = mi.movieName.Text; //fi.circleImage = mi.movieImage; //fi.label.PreviewMouseLeftButtonDown += itemnewMovies_FocusChanged; fi.rightArrow.PreviewMouseLeftButtonDown += rightArrowClicked; string img = mi.movieImage.ImageSource.ToString(); if (img != null && img != "/TorrentChecker;component/images/add-icon.png") { var uri = new Uri(img); var bitmap = new BitmapImage(uri); fi.circleImage.ImageSource = bitmap; } listnewMovies.Items.Add(fi); // add to xml if (Feed.alreadyExistinFile(fi.label.Content.ToString())) { return; } XElement xmlFile; XElement newElement = new XElement("Feed", new XElement("name", fi.label.Content), new XElement("image", img), new XElement("torrent", fi.torrentLinkString.Content)); if (!File.Exists(Directory.GetCurrentDirectory() + "\\FeedsInfo.xml")) { xmlFile = new XElement("Feeds", newElement); } else { xmlFile = XElement.Load("FeedsInfo.xml"); xmlFile.Add(newElement); } xmlFile.Save("FeedsInfo.xml"); }