Ejemplo n.º 1
0
 private void Refresh_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (SClass.CheckNet())
         {
             stav_prog("Obnovuji všechna hodnocení");
             int i     = 0;
             int itemy = 0;
             VisibilityState();
             CurrentState.Content = "Stav: Obnovení všech hodnocení";
             Progress.Maximum     = Filmy.Items.Count;
             Progress.Value       = 0;
             foreach (var item in Filmy.Items)
             {
                 DataRowView data = (DataRowView)item;
                 if (data.Row.ItemArray[6].ToString().Length != 0)
                 {
                     string LastRate = data.Row.ItemArray[7].ToString();
                     string Rating   = "";
                     var    webget   = new HtmlAgilityPack.HtmlWeb();
                     var    doc      = webget.Load(data.Row.ItemArray[6].ToString());
                     try
                     {
                         var FindH2Tag =
                             doc.DocumentNode.Descendants("h2")
                             .Where(
                                 d =>
                                 d.Attributes.Contains("class") &&
                                 d.Attributes["class"].Value.Contains("average"));
                         var hodnoceni = FindH2Tag.Select(c => c.InnerHtml).Single();
                         Rating = hodnoceni;
                     }
                     catch
                     {
                         Rating = "";
                     }
                     if (LastRate != Rating)
                     {
                         itemy++;
                         SqlCeCommand Query =
                             new SqlCeCommand(
                                 "UPDATE Filmy Set [Hodnocení - CSFD] = '" + Rating + "' WHERE ID = " +
                                 data.Row.ItemArray[0].ToString(), pripojeni);
                         try
                         {
                             int affected = Query.ExecuteNonQuery();
                         }
                         catch (Exception ex)
                         {
                             MessageBox.Show(
                                 "V programu nastala chyba. Informace o dané položce \nPoložka číslo: " + i +
                                 "\n" +
                                 "Název filmu: " + data.Row.ItemArray[1].ToString() + "\n" +
                                 ex.Message, Name, MessageBoxButton.OK, MessageBoxImage.Error);
                         }
                     }
                     i++;
                     Addment.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                     CurrentState.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                     Progress.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                 }
                 Progress.Value = Progress.Value + 1;
             }
             Addment.Content = "Stav: Bylo upraveno " + itemy + " položek";
             stav_prog(AddOn: "\nBylo upraveno " + itemy + " položek");
         }
         else
         {
             VisibilityState();
             stav_prog("Váš počítač není připojen k internetu");
         }
     }
     catch
     {
         stav_prog("V programu nastala chyba");
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        internal void CheckUpdate()
        {
            SearchClass SClass = new SearchClass();

            if (SClass.CheckNet())
            {
                try
                {
                    InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                    Steps.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                    Steps.Maximum = 4;
                    InfoBox.Text  = "Připojuji se na server";
                    InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                    var doc = webget.Load("http://www.goid-cz.webnode.cz/update");
                    InfoBox.Text += "\nPřipojení proběhlo úspěšně";
                    Steps.Value++;
                    InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                    Steps.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                    InfoBox.Text += "\nZjišťuji verze:";
                    InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                    string NetVersion = doc.DocumentNode.SelectSingleNode("//*[@id='" + product + "-version']").InnerText;
                    if (NetVersion.Contains("\n\t"))
                    {
                        NetVersion = NetVersion.Substring(2, NetVersion.Length - 2);
                    }
                    InfoBox.Text += "\nDostupná verze: " + NetVersion;
                    InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                    string PCVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                    InfoBox.Text += "\nAktuální verze: " + PCVersion;
                    Steps.Value++;
                    InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                    Steps.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                    for (int i = 0; i <= 6; i += 2)
                    {
                        int net, pc;
                        Int32.TryParse(PCVersion[i].ToString(), out pc);
                        Int32.TryParse(NetVersion[i].ToString(), out net);
                        if (net > pc)
                        {
                            Update = true;
                            break;
                        }
                    }
                    Steps.Value++;
                    Steps.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                    if (Update)
                    {
                        Accept.Visibility = Visibility.Visible;
                        InfoBox.Text     += "\nJe dostupná novější verze";
                        InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                        InfoBox.Text += "\nKliknutím na Aktualizovat program aktualizujete";
                        InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                        link = doc.DocumentNode.SelectSingleNode("//*[@id='" + product + "-link']").InnerText;
                        if (link.Contains("\n\t"))
                        {
                            link = link.Substring(2, link.Length - 2);
                        }
                        client.NewVersion.Text = "Update k dispozici. Co nabízí nová verze?";
                        InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                        describe = doc.DocumentNode.SelectSingleNode("//*[@id='" + product + "-updateinfo']").InnerText;
                        if (describe.Contains("\n\t"))
                        {
                            client.DescribeNewVersion.Text = describe.Substring(2, describe.Length - 2);
                        }
                    }
                    else
                    {
                        InfoBox.Text += "\nVáš program je aktuální";
                        InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                        Steps.Value = Steps.Maximum;
                        Steps.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
                        Accept.Content    = "Zavřít";
                        Accept.Visibility = Visibility.Visible;
                    }
                }
                catch { }
            }
            else
            {
                InfoBox.Text = "Nejste připojeni k internetu";
                InfoBox.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
            }
            if (SilentUpdate)
            {
                client.Running = false;
            }
        }
Ejemplo n.º 4
0
        private void LoadGallery_Click(object sender, RoutedEventArgs e)
        {
            LoadGallery.Visibility = Visibility.Hidden;
            List <Image> Gal = new List <Image>();

            try
            {
                var webget     = new HtmlWeb();
                int PagesCount = 1;
                if (LinkFilm.Contains("\""))
                {
                    int i = LinkFilm.IndexOf('\"');
                    LinkFilm = LinkFilm.Substring(0, i);
                }
                var doc = webget.Load(LinkFilm + "galerie/?type=1");
                try
                {
                    try
                    {
                        string MorePages = doc.DocumentNode.SelectSingleNode("//*[@id='main']/div[4]/div[3]/div[2]/a[1]").InnerText;
                        if (MorePages == "2")
                        {
                            while (true)
                            {
                                try
                                {
                                    MorePages = doc.DocumentNode.SelectSingleNode("//*[@id='main']/div[4]/div[3]/div[2]/a[" + (PagesCount + 1).ToString() + "]").InnerText;
                                    //  if (MorePages != "následující >>")
                                    PagesCount++;
                                }
                                catch { break; }
                            }
                            PagesCount--;
                            MorePages = doc.DocumentNode.SelectSingleNode("//*[@id='main']/div[4]/div[3]/div[2]/a[" + PagesCount.ToString() + "]").InnerText;
                            Int32.TryParse(MorePages, out PagesCount);
                        }
                    }
                    catch { }
                    int Position = 10;
                    int PicCount = 1;
                    LinkFilm = LinkFilm + "galerie/strana-";
                    for (int j = 1; j <= PagesCount; j++)
                    {
                        string alink = LinkFilm + j.ToString() + "/?type=1";
                        doc = webget.Load(alink);
                        for (int i = 1; ; i++)
                        {
                            try
                            {
                                Image  Pic = new Image();
                                string s   = doc.DocumentNode.SelectSingleNode("//*[@id='main']/div[4]/div[3]/ul[1]/li[" + i + "]").InnerHtml;
                                string p   = s.Split('(')[1].Split(')')[0];
                                s = "http:" + p.Substring(1, p.Length - 2);
                                string Img = s;

                                BitmapImage bitmap = new BitmapImage();
                                bitmap.BeginInit();
                                bitmap.UriSource = new Uri(Img, UriKind.Absolute);
                                bitmap.EndInit();

                                Pic.Source     = bitmap;
                                Pic.Name       = "pic" + PicCount.ToString();
                                Pic.Stretch    = Stretch.Uniform;
                                Pic.Width      = 300;
                                Pic.Height     = 200;
                                Pic.MouseDown += Pic_MouseDown;

                                Thickness ItemPosition = Pic.Margin;
                                ItemPosition.Left = 0;
                                ItemPosition.Top  = Position;
                                Pic.Margin        = ItemPosition;
                                string PicActors = "";
                                try
                                {
                                    PicActors = doc.DocumentNode.SelectSingleNode("//*[@id='main']/div[4]/div[3]/ul[1]/li[" + i + "]/p[2]").InnerText;
                                }
                                catch { }
                                Pic.ToolTip             = PicActors;
                                Pic.HorizontalAlignment = HorizontalAlignment.Center;
                                Pic.VerticalAlignment   = VerticalAlignment.Top;

                                Position += 210;
                                Gal.Add(Pic);
                                Pics.Children.Add(Pic);
                                PicCount++;
                            }
                            catch { break; }
                        }
                    }
                }
                catch { }
            }
            catch { }
            if (Gal.Count == 0)
            {
                Label     lab          = new Label();
                Thickness ItemPosition = lab.Margin;
                ItemPosition.Left       = 0;
                ItemPosition.Top        = 0;
                lab.Margin              = ItemPosition;
                lab.HorizontalAlignment = HorizontalAlignment.Center;
                lab.VerticalAlignment   = VerticalAlignment.Stretch;
                SearchClass SClass = new SearchClass();
                if (SClass.CheckNet())
                {
                    lab.Content = "Tento film neobsahuje foto k filmu";
                    lab.ToolTip = "Tento film neobsahuje foto k filmu";
                }
                else
                {
                    lab.Content = "Nejste připojeni k internetu";
                    lab.ToolTip = "Nejste připojeni k internetu";
                }
                lab.Height = 50;
                Pics.Children.Add(lab);
            }
        }