Beispiel #1
0
        private void BackgroundWorker_Progress(object sender0, System.ComponentModel.ProgressChangedEventArgs e0)
        {
            Element   el  = new Element();
            StorageTV sTv = (StorageTV)e0.UserState;

            el.Name     = "Element" + sTv.Index;
            el.Title    = sTv.Title;
            el.TitleUrl = sTv.TitleUrl;

            el.Episode    = sTv.Episode;
            el.EpisodeUrl = sTv.EpisodeUrl;

            el.Index    = sTv.Index;
            el.Location = new Point(0, (sTv.Index * 38) / 1 + 38);
            el.Expand   = sTv.Expand;
            el.Type     = sTv.Type;

            if (sTv.Type == "lastep")
            {
                el.titleLabel.ForeColor   = Color.FromArgb(255, 204, 51, 51);
                el.episodeLabel.ForeColor = Color.FromArgb(255, 204, 51, 51);
            }

            if (sTv.Type == "firstep")
            {
                el.titleLabel.ForeColor   = Color.FromArgb(255, 130, 202, 59);
                el.episodeLabel.ForeColor = Color.FromArgb(255, 130, 202, 59);
            }

            if (sTv.Index % 2 == 0)
            {
                el.BackColor = Color.FromArgb(255, 44, 44, 44);
            }
            else
            {
                el.BackColor = Color.FromArgb(255, 53, 53, 53);
            }
            el.titleLabel.Click   += (sender, e) => openSeries(sender, e, el.TitleUrl);
            el.episodeLabel.Click += (sender, e) => openSeries(sender, e, el.EpisodeUrl);
            this.Controls.Add(el);
        }
Beispiel #2
0
        private void BackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

            //// There are various options, set as needed
            htmlDoc.OptionFixNestedTags = true;

            htmlDoc.LoadHtml(DownloadToday("http://www.pogdesign.co.uk/cat/"));
            HtmlNodeCollection seriesToday = htmlDoc.DocumentNode.SelectNodes("//td[@class='today']/div");

            if (seriesToday != null)
            {
                elementCount = seriesToday.Count;
                char[] delimiterChars = { ';' };
                int licz = 0;

                List<int> Index = new List<int>();
                List<string> Title = new List<string>();
                List<string> TitleUrl = new List<string>();
                List<string> Episode = new List<string>();
                List<string> EpisodeUrl = new List<string>();
                List<string> Type = new List<string>();

                for (int index = 0; index < elementCount; index++)
                {
                    HtmlNode p = seriesToday[index].SelectSingleNode("p");
                    string title = correctTitle(p.SelectSingleNode("a[1]").InnerText.Trim());
                    if (Array.Exists(Properties.Settings.Default.Favorites.Split(delimiterChars), delegate(string s) { return s.Equals(title); }) != false)
                    {
                        Index.Add(licz);
                        Title.Add(title);
                        TitleUrl.Add(getSeriesUrl(p.SelectSingleNode("a[1]")));
                        Episode.Add(p.SelectSingleNode("a[2]").InnerText.Trim());
                        EpisodeUrl.Add(getEpisodeUrl(p.SelectSingleNode("a[2]")));
                        Type.Add(p.GetAttributeValue("class", "normal"));
                        licz++;
                    }
                }

                if (licz > 6)
                {
                    if ((licz * 38 + 100) > getMaxHeight())
                    {
                        maxElementView = (getMaxHeight()-100) / 38;
                        ElementExpand = false;
                        changeSpeed = 2;
                    }
                    else
                    {
                        maxElementView = licz;
                        ElementExpand = true;
                    }
                }
                else
                {
                    maxElementView = licz;
                    ElementExpand = true;
                }

                for (int index = 0; index < licz; index++)
                {
                    StorageTV storageTv = new StorageTV();

                    storageTv.Index = index;
                    storageTv.LastIndex = index - 1;
                    storageTv.Title = Title[index];
                    storageTv.TitleUrl = TitleUrl[index];
                    storageTv.Episode = Episode[index];
                    storageTv.EpisodeUrl = EpisodeUrl[index];
                    storageTv.Expand = ElementExpand;
                    storageTv.Type = Type[index];

                    backgroundWorker.ReportProgress(index, storageTv);
                }

            }
            else
            {
                Console.WriteLine("html => NULL");
            }
        }
Beispiel #3
0
        private void BackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

            //// There are various options, set as needed
            htmlDoc.OptionFixNestedTags = true;

            htmlDoc.LoadHtml(DownloadToday("http://www.pogdesign.co.uk/cat/"));
            HtmlNodeCollection seriesToday = htmlDoc.DocumentNode.SelectNodes("//td[@class='today']/div");

            if (seriesToday != null)
            {
                elementCount = seriesToday.Count;
                char[] delimiterChars = { ';' };
                int    licz           = 0;

                List <int>    Index      = new List <int>();
                List <string> Title      = new List <string>();
                List <string> TitleUrl   = new List <string>();
                List <string> Episode    = new List <string>();
                List <string> EpisodeUrl = new List <string>();
                List <string> Type       = new List <string>();

                for (int index = 0; index < elementCount; index++)
                {
                    HtmlNode p     = seriesToday[index].SelectSingleNode("p");
                    string   title = correctTitle(p.SelectSingleNode("a[1]").InnerText.Trim());
                    if (Array.Exists(Properties.Settings.Default.Favorites.Split(delimiterChars), delegate(string s) { return(s.Equals(title)); }) != false)
                    {
                        Index.Add(licz);
                        Title.Add(title);
                        TitleUrl.Add(getSeriesUrl(p.SelectSingleNode("a[1]")));
                        Episode.Add(p.SelectSingleNode("a[2]").InnerText.Trim());
                        EpisodeUrl.Add(getEpisodeUrl(p.SelectSingleNode("a[2]")));
                        Type.Add(p.GetAttributeValue("class", "normal"));
                        licz++;
                    }
                }

                if (licz > 6)
                {
                    if ((licz * 38 + 100) > getMaxHeight())
                    {
                        maxElementView = (getMaxHeight() - 100) / 38;
                        ElementExpand  = false;
                        changeSpeed    = 2;
                    }
                    else
                    {
                        maxElementView = licz;
                        ElementExpand  = true;
                    }
                }
                else
                {
                    maxElementView = licz;
                    ElementExpand  = true;
                }

                for (int index = 0; index < licz; index++)
                {
                    StorageTV storageTv = new StorageTV();

                    storageTv.Index      = index;
                    storageTv.LastIndex  = index - 1;
                    storageTv.Title      = Title[index];
                    storageTv.TitleUrl   = TitleUrl[index];
                    storageTv.Episode    = Episode[index];
                    storageTv.EpisodeUrl = EpisodeUrl[index];
                    storageTv.Expand     = ElementExpand;
                    storageTv.Type       = Type[index];

                    backgroundWorker.ReportProgress(index, storageTv);
                }
            }
            else
            {
                Console.WriteLine("html => NULL");
            }
        }