예제 #1
0
        private void addWaitList_Click(object sender, RoutedEventArgs e)
        {
            foreach (String item in listChapters.SelectedItems)
            {
                IChapter chap = null;
                switch (selectedSite)
                {
                case 0:
                    chap = new ChapJapscan(all_mangas, item);
                    break;

                case 1:
                    chap = new ChapMangaReader(all_mangas, item);
                    break;

                case 2:
                    chap = new ChapMangaHere(all_mangas, item);
                    break;

                case 3:
                    chap = new ChapReadManga(all_mangas, item);
                    break;
                }
                list_mangas.Add(chap);
            }
        }
예제 #2
0
        private async void StartButton_Click(object sender, RoutedEventArgs e)
        {
            Int16   timeout;
            Boolean hasBeenDownloaded;
            var     dialog = new System.Windows.Forms.FolderBrowserDialog();

            System.Windows.Forms.DialogResult result = dialog.ShowDialog();
            BackButton.IsEnabled = false;

            String path = dialog.SelectedPath + "/";

            StopButton.Visibility  = Visibility.Visible;
            StartButton.Visibility = Visibility.Hidden;
            cancel = false;

            while (list_mangas.Count > 0)
            {
                IChapter i = list_mangas.First();
                timeout           = 0;
                hasBeenDownloaded = false;
                while (!hasBeenDownloaded)
                {
                    try
                    {
                        System.IO.Directory.CreateDirectory(path + i.getMangaName());
                        String[] chapters = i.get_chapters_details();

                        System.IO.Directory.CreateDirectory(path + chapters[1]);
                        CurrentElem.Content = chapters[0];
                        List <String[]> pages = i.get_pages_details(chapters[2], path + chapters[1], chapters[4]);

                        foreach (String[] details_page in pages)
                        {
                            if (cancel == true)
                            {
                                cancel = false;
                                return;
                            }
                            ProgressPage.Value  = Int32.Parse(details_page[0]);
                            CurrentPage.Content = "Page " + details_page[2];
                            i.download_one_scan(details_page[1], details_page[2], details_page[3], path + chapters[1]);
                            await Task.Delay(10);
                        }
                        hasBeenDownloaded = true;
                    }
                    catch (System.Net.WebException)
                    {
                        System.Threading.Thread.Sleep(30000);
                        ++timeout;
                    }
                    if (timeout == 5)
                    {
                        stop_action();
                        return;
                    }
                }


                if (list_mangas.Count > 0)
                {
                    list_mangas.RemoveAt(0);
                }
                RefreshWaitList();
            }
            stop_action();
        }