コード例 #1
0
        private async Task DownloadAsync()
        {
            //Try to initialize the source.
            DetailedProgress_Box.AppendText("Initalize Mango Source... \n");
            Mango_Source my_source = await Mango_Source.Factory.get_new_Async(SourcesList_ComboBox.SelectedItem.ToString(), SourceUrl_Box.Text);

            //Source is OK, create downloader
            DetailedProgress_Box.AppendText("Initalize Downloader... \n");
            Mango_Downloader my_downloader = new Mango_Downloader(my_source, SaveTo_TextBox.Text);

            //Everything is good. Start downloading.
            DetailedProgress_Box.AppendText("Downloading...\n.\n.\n.\n");
            do
            {
                await my_downloader.DownloadCurrentPageAsync();

                DetailedProgress_Box.AppendText(my_downloader.current_filename + " downloaded\n");
                int completed = my_downloader.completed_percentage();
                progressBar1.Value = completed;
            } while (await my_downloader.get_next_page_Async() == true);

            //everything is good.
            progressBar1.Value = 100;
            DetailedProgress_Box.AppendText("Completed!\n");
        }
コード例 #2
0
 public Mango_Downloader(Mango_Source html, string local_uri)
 {
     //Create a downloader for Mango, accept in a string of HTML (source) and the local path (where to save)
     source_html       = html;
     _downloaded_count = 0;
     local_saving_path = local_uri;
 }