Ejemplo n.º 1
0
        private void Actors_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var  webget = new HtmlWeb();
            var  doc    = webget.Load(LinkFilm);
            bool con    = true;
            int  div    = 1;

            while (con)
            {
                string Actors = doc.DocumentNode.SelectSingleNode("//*[@id='profile']/div[1]/div[2]/div[1]/div[" + div + "]/h4[1]").InnerText;
                if (Actors == "Hrají:")
                {
                    con = false;
                }
                else
                {
                    div++;
                }
            }

            try
            {
                string LinkSource = doc.DocumentNode.SelectSingleNode("//*[@id='profile']/div[1]/div[2]/div[1]/div[" + div + "]/span[1]/a[" + (Actors.SelectedIndex + 1) + "]").OuterHtml;
                string Link       = "http://www.csfd.cz" + Regex.Split(Regex.Split(LinkSource, "<a href=\"")[1], "\">")[0];

                ArtCard  ACard   = (ArtCard)Actors.SelectedItem;
                Card_art PropArt = ACard.LoadCard(ACard, (new SearchClass()
                {
                    HDoc = webget.Load(Link)
                }).HDoc);
                PropArt.Client  = Client;
                PropArt.LinkAct = Link;
                PropArt.Title   = "Karta tvůrce: " + ACard.NameArt;
                PropArt.Show();
            }
            catch {}
        }
Ejemplo n.º 2
0
        internal Card_art LoadCard(ArtCard data, HtmlDocument HDoc)
        {
            Card_art card = new Card_art(data.LinkArt);

            card.ArtName.Text  = data.NameArt;
            card.Birthday.Text = data.Birth;
            card.Job.Text      = data.Job;
            try
            {
                try
                {
                    card.Die.Text = HDoc.DocumentNode.SelectSingleNode("//*[@id='profile']/div[1]/div[2]/ul[1]/li[2]").InnerText;
                    card.Die.Text = Replace(card.Die.Text, "\n", " ");
                    card.Die.Text = Replace(card.Die.Text, "\t");
                    card.Die.Text = card.Die.Text.Substring(1, card.Die.Text.Length - 2);
                }
                catch { }

                try
                {
                    card.Birthday.Text = HDoc.DocumentNode.SelectSingleNode("//*[@id='profile']/div[1]/div[2]/ul[1]/li[1]").InnerText;
                    card.Birthday.Text = Replace(card.Birthday.Text, "\n", " ");
                    card.Birthday.Text = Replace(card.Birthday.Text, "\t");
                    card.Birthday.Text = card.Birthday.Text.Substring(1, card.Birthday.Text.Length - 2);
                }
                catch { }

                try
                {
                    var         FindDivTag      = HDoc.DocumentNode.Descendants("div").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("image"));
                    var         ImageHTMLSource = FindDivTag.Select(c => c.InnerHtml).Single();
                    string      Img             = "http:" + Regex.Split(Regex.Split(ImageHTMLSource, "<img src=\"")[1], "\"")[0];
                    BitmapImage bitmap          = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri(Img, UriKind.Absolute);
                    bitmap.EndInit();
                    card.Photo.Source  = bitmap;
                    card.Photo.Stretch = System.Windows.Media.Stretch.UniformToFill;
                }
                catch { }

                try
                {
                    for (int i = 1; ; i++)
                    {
                        try
                        {
                            string AwardsSource = HDoc.DocumentNode.SelectSingleNode("//*[@id='fanclub-chart']/p[" + i + "]/a").InnerHtml;
                            string Awards       = Replace(Replace(Regex.Split(AwardsSource, "<br>")[0], "\t"), "\n") + " " + Regex.Split(AwardsSource, "<br>")[1];
                            card.FanAwards.Text += Replace(Awards, "\t") + ", ";
                        }
                        catch { break; }
                    }
                    card.FanAwards.Text = card.FanAwards.Text.Substring(0, card.FanAwards.Text.Length - 2);
                }
                catch { }

                try
                {
                    card.Story.Text = HDoc.DocumentNode.SelectSingleNode("//*[@id='action']/div[2]/p[1]").InnerText;
                }
                catch { card.Story.Text = "Nepodařilo se nám načíst biografii tvůrce."; }

                try
                {
                    try
                    {
                        for (int i = 1; ; i++)
                        {
                            string Header = "";
                            try
                            {
                                Header = HDoc.DocumentNode.SelectSingleNode("//*[@id='filmography']/div[" + i + "]/div[1]/h2").InnerText;
                                DataGrid DataG = new DataGrid();
                                DataG.IsReadOnly = true;

                                DataGridTextColumn Column = new DataGridTextColumn();
                                Column.Header     = "ID";
                                Column.Binding    = new Binding("IDFilm");
                                Column.Visibility = Visibility.Collapsed;
                                DataG.Columns.Add(Column);

                                Column         = new DataGridTextColumn();
                                Column.Header  = "Rok";
                                Column.Binding = new Binding("Year");
                                DataG.Columns.Add(Column);

                                Column         = new DataGridTextColumn();
                                Column.Header  = "Název filmu";
                                Column.Binding = new Binding("NameFilm");
                                DataG.Columns.Add(Column);

                                string last = "";

                                for (int j = 1; ; j++)
                                {
                                    try
                                    {
                                        string pok = HDoc.DocumentNode.SelectSingleNode("//*[@id='filmography']/div[" + i + "]/div[2]/table/tr[" + j + "]/td[1]").InnerText;
                                        try
                                        {
                                            string year = HDoc.DocumentNode.SelectSingleNode("//*[@id='filmography']/div[" + i + "]/div[2]/table/tr[" + j + "]/th").InnerText;
                                            Replace(ref year, "\n");
                                            Replace(ref year, "\t");
                                            string film = HDoc.DocumentNode.SelectSingleNode("//*[@id='filmography']/div[" + i + "]/div[2]/table/tr[" + j + "]/td").InnerText;
                                            Replace(ref film, "\n");
                                            Replace(ref film, "\t");
                                            if (year != "")
                                            {
                                                last = year;
                                            }
                                            else
                                            {
                                                year = last;
                                            }
                                            if (film != "")
                                            {
                                                DataG.Items.Add(new FilmCard()
                                                {
                                                    IDFilm = j.ToString(), Year = year, NameFilm = film
                                                });
                                            }
                                        }
                                        catch { }
                                    }
                                    catch { break; }
                                }

                                TabItem ti = new TabItem();
                                ti.Header = Header;
                                Grid           asdd = new Grid();
                                BrushConverter bc   = new BrushConverter();
                                asdd.Background = (Brush)bc.ConvertFrom("#FF000000");
                                ti.Content      = DataG;
                                card.FilmTypes.Items.Add(ti);
                            }
                            catch { break; }
                        }
                    }
                    catch { }
                }
                catch { }
            }
            catch { }

            return(card);
        }
Ejemplo n.º 3
0
        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);
        }