Ejemplo n.º 1
0
        private void FindOnNet()
        {
            if (FindFilm == true)
            {
                if (name.Text == name.ToolTip.ToString())
                {
                    SearchBut.IsEnabled = false;
                }
                else
                {
                    try
                    {
                        #region koment

                        /* var webget = new HtmlWeb();
                         * SearchClass SClass = new SearchClass();
                         * Result res = SClass.FindFilm(name, false);
                         * if (stop == 0)
                         *   if ((bool)res.ShowDialog())
                         *   {
                         *       var dataRow = res.Films.Items[res.CurrentRowIndex] as FilmCard;
                         *       name.Text = dataRow.NameFilm;
                         *       /*    var FindH3Tag = doc.DocumentNode.Descendants("a").Where(d => d.Attributes.Contains("class"));
                         *           var puvod2 = FindH3Tag.Where(c => c.InnerText == dataRow.Nazev).Select(c => c.OuterHtml);*/
                        /*int ul = 1;
                         * if (res.CurrentRecordIndex > 4)
                         * {
                         *  ul = 2;
                         *  res.CurrentRecordIndex -= 5;
                         * }
                         * string asd = SClass.HDoc.DocumentNode.SelectSingleNode("//*[@id='search-films']/div[1]/ul[" + ul.ToString() + "]/li[" + (res.CurrentRecordIndex) + "]").InnerHtml;
                         * string[] mezi = Regex.Split(SClass.HDoc.DocumentNode.SelectSingleNode("//*[@id='search-films']/div[1]/ul[" + ul.ToString() + "]/li[" + (res.CurrentRecordIndex) + "]").InnerHtml, "<a href=\"");
                         * string[] link = Regex.Split(mezi[1], "\">");
                         * SClass.HDoc = webget.Load("http://www.csfd.cz" + link[0]);
                         * var FindPTag = SClass.HDoc.DocumentNode.Descendants("p").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("origin"));
                         * try
                         * {
                         *  var puvod = FindPTag.Select(c => c.InnerHtml).Single();
                         *  string[] info = Regex.Split(puvod, ", ");
                         *  int cislo = 0;
                         *  if (info.Length != 0)
                         *  {
                         *      bool[] properties = new bool[3];
                         *      for (int j = 0; j < info.Length; j++)
                         *      {
                         *          if (Int32.TryParse(info[j], out cislo))
                         *          {
                         *              rok.Text = info[j];
                         *              properties[1] = true;
                         *          }
                         *          else if (info[j].Contains(" min"))
                         *          {
                         *              delka.Text = info[j].Substring(0, info[j].Length - 4);
                         *              properties[2] = true;
                         *          }
                         *          else
                         *          {
                         *              zeme.Text = info[j];
                         *              properties[0] = true;
                         *          }
                         *      }
                         *      for (int j = 0; j < properties.Length; j++)
                         *      {
                         *          if (properties[j] == false)
                         *              switch (j)
                         *              {
                         *                  case 0:
                         *                      zeme.Text = "xxx";
                         *                      break;
                         *                  case 1:
                         *                      rok.Text = "xxx";
                         *                      break;
                         *                  case 2:
                         *                      delka.Text = "xxx";
                         *                      break;
                         *              }
                         *      }
                         *  }
                         *  else
                         *  {
                         *      rok.Text = "xxx";
                         *      delka.Text = "xxx";
                         *      zeme.Text = "xxx";
                         *  }
                         * }
                         * catch { }
                         * try
                         * {
                         *  FindPTag = SClass.HDoc.DocumentNode.Descendants("p").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("genre"));
                         *  var type = FindPTag.Select(c => c.InnerHtml).Single();
                         *  typ.Text = type;
                         * }
                         * catch { typ.Text = "xxx"; }
                         * /*   if (ul == 2)
                         *     ul = 4;
                         * else
                         *     ul = 0;*//*
                         * adresa.Text = "http://www.csfd.cz" + link[0];
                         * try
                         * {
                         *  var FindH2Tag = SClass.HDoc.DocumentNode.Descendants("h2").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("average"));
                         *  var rating = FindH2Tag.Select(c => c.InnerHtml).Single();
                         *  hodnoceni.Text = rating;
                         * }
                         * catch { hodnoceni.Text = ""; }
                         * CheckProperties();
                         * }
                         * else
                         * {
                         * stop--;
                         * }
                         * stop++;*/
                        #endregion

                        SearchClass SClass = new SearchClass();
                        Result      res    = SClass.FindFilm(name.Text, false);

                        if (res.Films.Items.Count == 0)
                        {
                            res.Exp1.IsExpanded = false;
                        }
                        else
                        {
                            res.Exp1.IsExpanded = true;
                        }

                        if (res.Actors.Items.Count == 0)
                        {
                            res.Exp2.IsExpanded = false;
                        }
                        else
                        {
                            res.Exp2.IsExpanded = true;
                        }

                        if ((bool)res.ShowDialog())
                        {
                            FilmCard FCard      = new FilmCard();
                            string   NameOfFilm = name.Text;
                            string[] data       = FCard.LoadProperties(ref NameOfFilm, res, SClass.HDoc);
                            name.Text      = NameOfFilm;
                            typ.Text       = data[2];
                            zeme.Text      = data[3];
                            rok.Text       = data[4];
                            delka.Text     = data[5];
                            adresa.Text    = data[6];
                            hodnoceni.Text = data[7];
                            CheckProperties();
                        }
                    }
                    catch
                    {
                        name.Text = "";
                        object obj = new object();
                        obj = name;
                        RoutedEventArgs e = new RoutedEventArgs();
                        Placeholder(obj, e);
                    }
                    Accept.IsEnabled = true;
                    if (name.Text[name.Text.Length - 1] == ' ')
                    {
                        name.Text = name.Text.Substring(0, name.Text.Length - 1);
                    }
                }
            }
        }
Ejemplo n.º 2
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);
        }