Exemplo n.º 1
0
            // Запуск периодического вывода сообщений
            private void StartWorking()
            {
                Awaiting = false;
                picture.Invoke(refreshQueue);
                var period  = rand.Next(500, 10000);
                var success = rand.Next() % 2 == 0;

                messages = success ? client.Operation.SuccessMessages : client.Operation.FailMessages;
                current  = 0;

                timer = new Timer(Work, null, 0, period);
            }
Exemplo n.º 2
0
 private void updatePictureBoxImg_EVT(System.Windows.Forms.PictureBox _control, Bitmap bt)
 {
     try
     {
         if (_control.InvokeRequired)
         {
             while (!_control.IsHandleCreated)
             {
                 if (_control.Disposing || _control.IsDisposed)
                 {
                     return;
                 }
             }
             updatePictureBoxImg uLEvt = new updatePictureBoxImg(updatePictureBoxImg_EVT);
             _control.Invoke(uLEvt, new object[] { _control, bt });
         }
         else
         {
             _control.Image = bt;
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 3
0
        private static List <Anime> getAnimesPerPage(Bunifu.Framework.UI.BunifuCustomDataGrid dataGrid, System.Windows.Forms.PictureBox preview, List <string> Links)
        {
            List <Anime> animes  = new List <Anime>();
            HtmlWeb      browser = new HtmlWeb();


            foreach (string link in Links)
            {
                try {
                    //Console.WriteLine(link);
                    HtmlDocument       document = browser.Load(link);
                    Anime              anime    = new Anime();
                    HtmlNodeCollection info     = document.DocumentNode.SelectSingleNode("//div[@class='anime_info_body_bg']").SelectNodes("p[@class='type']");
                    anime.Title = document.DocumentNode.SelectSingleNode("//div[@class='anime_info_body_bg']").SelectSingleNode("h1").InnerText;
                    anime.Image = document.DocumentNode.SelectSingleNode("//div[@class='anime_info_body_bg']").SelectSingleNode("img").Attributes["src"].Value;
                    preview.Invoke(new Action(() => preview.ImageLocation = anime.Image));
                    foreach (HtmlNode item in info)
                    {
                        string choice = item.FirstChild.InnerText.Trim();
                        item.FirstChild.Remove();
                        switch (choice)
                        {
                        case "Type:":
                            anime.Type = item.SelectSingleNode("a").Attributes["title"].Value;
                            break;

                        case "Status:":
                            anime.Status = item.InnerText;
                            break;

                        case "Released:":
                            anime.Aired = item.InnerText;
                            break;

                        case "Genre:":
                            foreach (HtmlNode genre in item.SelectNodes("a"))
                            {
                                anime.Genres.Add(genre.Attributes["title"].Value);
                            }
                            break;

                        case "Plot Summary:":
                            anime.Summary = item.InnerText;
                            break;

                        default: break;
                        }
                    }
                    //------get Episodes

                    int numEpisodes = int.Parse(document.DocumentNode.SelectSingleNode("//ul[@id='episode_page']")
                                                .SelectNodes("li")
                                                .Last()
                                                .SelectSingleNode("a")
                                                .Attributes["ep_end"].Value);
                    string unq = link.Split(new[] { "category/" }, StringSplitOptions.None)[1];
                    anime.Streams = getEpisodesPerAnime(unq, numEpisodes);
                    anime.Unique  = unq;
                    dumpIntodb(dataGrid, anime);
                    //dumpScrapedAnimeGrid(dataGrid,anime);
                    //Console.WriteLine(anime.ToString());
                    animes.Add(anime);
                }
                catch
                {
                }
            }



            return(animes);
        }