private void Properties(object sender, MouseButtonEventArgs e) { try { DataRowView dataRow = (DataRowView)Filmy.SelectedItem; int index = Filmy.CurrentCell.Column.DisplayIndex; if (index == 6) { System.Diagnostics.Process.Start(dataRow.Row.ItemArray[index].ToString()); stav_prog("Program otevřel odkaz"); } else { stav_prog("Program vytváří kartu k filmu"); FilmCard FCard = new FilmCard(); Card_film PropFilm = FCard.LoadCard(dataRow); PropFilm.Client = this; PropFilm.Show(); stav_prog("Program zobrazuje podrobnosti k filmu: " + dataRow.Row.ItemArray[1].ToString()); } } catch { } }
private void Find_CSFD_Click(object sender, RoutedEventArgs e) { bool SearchCSFDReuslt = false; bool Continue = false; bool MoreSearches = false; do { Search SearchCSFD = new Search(); SearchCSFD.MoreSearches.IsChecked = MoreSearches; SearchCSFDReuslt = (bool)SearchCSFD.ShowDialog(); MoreSearches = (bool)SearchCSFD.MoreSearches.IsChecked; if (SearchCSFDReuslt) { stav_prog("Program vyhledává: " + SearchCSFD.Find_box.Text); Result vysldek = SClass.FindFilm(SearchCSFD.Find_box.Text, true); if (vysldek.Films.Items.Count == 0) { vysldek.Exp1.IsExpanded = false; } else { vysldek.Exp1.IsExpanded = true; } if (vysldek.Actors.Items.Count == 0) { vysldek.Exp2.IsExpanded = false; } else { vysldek.Exp2.IsExpanded = true; } if ((bool)vysldek.ShowDialog()) { if (vysldek.DB == "Films") { FilmCard FCard = new FilmCard(); string name = ""; string[] data = FCard.LoadProperties(ref name, vysldek, SClass.HDoc); data[5] += " min"; data[8] = "Ne"; data[9] = "Ne"; Card_film PropFilm = FCard.LoadCard(data); PropFilm.Cancel.Visibility = Visibility.Visible; PropFilm.seen.IsEnabled = true; PropFilm.DVD.IsEnabled = true; PropFilm.Client = this; PropFilm.Accept.Content = "Přidat film do databáze"; PropFilm.ID = IntelID(Filmy.Items); PropFilm.pripojeni = pripojeni; PropFilm.link = data[6]; PropFilm.Show(); } else { ArtCard ACard = new ArtCard(); var data = vysldek.ArtData; Card_art PropArt = ACard.LoadCard(data, vysldek, SClass.HDoc); PropArt.Client = this; PropArt.Show(); } } } else { stav_prog("Spuštěn; Akce zrušena"); } Continue = (MoreSearches == true) && (true == SearchCSFDReuslt); }while (Continue); }
public Card_film LoadCard(string[] data) { var webget = new HtmlWeb(); SearchClass SClass = new SearchClass(); Card_film card = new Card_film(data[6]); card.name.Text = data[1]; card.type.Text = data[2]; card.state.Text = data[3]; card.year.Text = data[4]; card.length.Text = data[5]; card.seen.IsChecked = Check(data[8]); card.seen.IsEnabled = false; card.DVD.IsEnabled = false; card.DVD.IsChecked = Check(data[9]); card.Accept.Content = "Ok"; card.Accept.IsCancel = true; card.Cancel.Visibility = Visibility.Hidden; try { var doc = webget.Load(data[6]); try { var FindH2Tag = doc.DocumentNode.Descendants("h2").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("average")); var rating = FindH2Tag.Select(c => c.InnerHtml).Single(); card.rating.Text = rating; } catch { card.rating.Text = ""; } try { card.dej.Text = doc.DocumentNode.SelectSingleNode("//*[@id='plots']/div[2]/ul[1]/li[1]/div[1]").InnerText; while (card.dej.Text.Contains("\t") || card.dej.Text.Contains("\n")) { if (card.dej.Text.Contains("\t")) { card.dej.Text = card.dej.Text.Replace("\t", ""); } else { card.dej.Text = card.dej.Text.Replace("\n", ""); } } } catch { card.dej.Text = "Nebylo možné načíst děj filmu"; } try { int i = 1; card.chart.Text = ""; for (i = 1; ; i++) { try { card.chart.Text += doc.DocumentNode.SelectSingleNode("//*[@id='rating']/p[1]/a[" + i + "]").InnerText + ", "; } catch { break; } } card.chart.Text = card.chart.Text.Substring(0, card.chart.Text.Length - 2); if (i == 1) { card.chart.Text = ""; } } catch { card.chart.Text = ""; } try { string img = "http:" + Regex.Split(Regex.Split(doc.DocumentNode.SelectSingleNode("//*[@id='poster']").InnerHtml, "<img src=\"")[1], "\"")[0]; BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(img, UriKind.Absolute); bitmap.EndInit(); card.poster.Source = bitmap; card.poster.Stretch = System.Windows.Media.Stretch.UniformToFill; } catch { } try { for (int i = 1; ; i++) { string Property = doc.DocumentNode.SelectSingleNode("//*[@id='profile']/div[1]/div[2]/div[1]/div[" + i + "]/h4[1]").InnerText; switch (Property) { case "Režie:": card.Rezie.Text = LoadCreators(i, doc); break; case "Scénář:": card.Scenar.Text = LoadCreators(i, doc); break; case "Kamera:": card.Kamera.Text = LoadCreators(i, doc); break; case "Hudba:": card.Hudba.Text = LoadCreators(i, doc); break; case "Předloha:": card.Predloha.Text = LoadCreators(i, doc); break; } } } catch { } } catch { } if (SClass.CheckNet()) { try { card.Actors.ItemsSource = SClass.LoadArt(data[6]).Items; } catch { } } else { card.rating.Text = data[7]; } return(card); }