Example #1
0
        private void Accept_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                switch (DB)
                {
                case "Films":
                    FilmCard FilmData = (FilmCard)Films.Items[Films.SelectedIndex];
                    Int32.TryParse(FilmData.IDFilm, out CurrentRecordIndex);
                    CurrentRowIndex = Films.SelectedIndex;
                    DialogResult    = true;
                    break;

                case "Actors":
                    ArtData = (ArtCard)Actors.Items[Actors.SelectedIndex];
                    Int32.TryParse(ArtData.IDArt, out CurrentRecordIndex);
                    CurrentRowIndex = Actors.SelectedIndex;
                    DialogResult    = true;
                    break;

                default:
                    Accept.IsEnabled = false;
                    break;
                }
            }
            catch { }
        }
Example #2
0
 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 { }
 }
Example #3
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);
                    }
                }
            }
        }
Example #4
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);
        }
Example #5
0
        public Result FindFilm(string name, bool complet)
        {
            var    webget      = new HtmlWeb();
            Result res         = new Result();
            var    doc         = webget.Load("http://www.seznam.cz");
            var    advanced    = "";
            int    pokracovani = 0;

            doc  = webget.Load("http://www.csfd.cz/hledat/?q=" + name);
            HDoc = doc;
            for (int i = 1; i <= 4; i++)
            {
                try
                {
                    string[] rok = doc.DocumentNode.SelectSingleNode("//*[@id='search-films']/div[1]/ul[1]/li[" + i + "]/div[1]/p[1]").InnerHtml.Split(',');
                    if (doc.DocumentNode.SelectSingleNode("//*[@id='search-films']/div[1]/ul[1]/li[" + i + "]/h3/span") != null)
                    {
                        advanced = " " + doc.DocumentNode.SelectSingleNode("//*[@id='search-films']/div[1]/ul[1]/li[" + i + "]/div[1]/h3/span").InnerHtml;
                    }
                    int index = 1;
                    if (rok.Length > 2)
                    {
                        index = 2;
                    }
                    res.Films.Items.Add(new FilmCard()
                    {
                        IDFilm = i.ToString(), NameFilm = doc.DocumentNode.SelectSingleNode("//*[@id='search-films']/div[1]/ul[1]/li[" + i + "]/div[1]/h3/a").InnerHtml + advanced, Year = rok[index].Substring(1, 4)
                    });
                    pokracovani++;
                    advanced = "";
                }
                catch
                {
                    pokracovani = i;
                    break;
                }
            }

            doc = webget.Load("http://www.csfd.cz/hledat/?q=" + name);
            for (int i = 1; ; i++)
            {
                try
                {
                    string rok;
                    int    index = 1;
                    if (doc.DocumentNode.SelectSingleNode("//*[@id='search-films']/div[1]/ul[2]/li[" + i + "]/span[1]").InnerHtml.Length != 6)
                    {
                        advanced = " " + doc.DocumentNode.SelectSingleNode("//*[@id='search-films']/div[1]/ul[2]/li[" + i + "]/span[1]").InnerHtml;
                        index    = 2;
                    }
                    rok = doc.DocumentNode.SelectSingleNode("//*[@id='search-films']/div[1]/ul[2]/li[" + i + "]/span[" + index.ToString() + "]").InnerHtml;
                    var radek = new FilmCard {
                        IDFilm = (i + pokracovani).ToString(), NameFilm = doc.DocumentNode.SelectSingleNode("//*[@id='search-films']/div[1]/ul[2]/li[" + i + "]/a[1]").InnerHtml + advanced, Year = rok.Substring(1, 4)
                    };
                    res.Films.Items.Add(radek);
                    advanced = "";
                }
                catch { break; }
            }
            if (!complet)
            {
                return(res);
            }
            else
            {
                res.Actors.ItemsSource = FindArt(name).Items;
                return(res);
            }
        }