Пример #1
0
        private async void downloadButton_Click(object sender, EventArgs e)
        {
            if (isDanbooruSite.Checked) //If it's a danbooru site
            {
                DanEngine engine    = new DanEngine();
                int       postCount = engine.getPostCount(domainBox.Text, tagsBox.Text);
                Console.WriteLine(postCount);
                if (postCount == 0)
                {
                    Console.WriteLine("No posts found by tag " + tagsBox.Text);
                    statusLabel.ForeColor = Color.Red;
                    statusLabel.Text      = "No posts found.";
                }
                else
                {
                    statusLabel.ForeColor = Color.Blue;
                    statusLabel.Text      = "Downloading...";
                    for (int i = 1; i < postCount; i++)
                    {
                        await Task.Run(() => engine.downloadPosts(domainBox.Text, tagsBox.Text, i, checkBox1.Checked, ratingCheckBox.Checked));

                        label4.Text = Convert.ToString(postCount - i) + " left";
                    }
                    statusLabel.ForeColor = Color.Green;
                    statusLabel.Text      = "Ready.";
                    label4.Text           = "";
                    MessageBox.Show("Download compelete!", "BooruDownloader", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                }
            }
            else
            {//If it's a gelbooru site
                GelEngine engine    = new GelEngine();
                int       postCount = engine.getPostCount(domainBox.Text, tagsBox.Text);
                Console.WriteLine(postCount);
                if (postCount == 0)
                {
                    Console.WriteLine("No posts found by tag " + tagsBox.Text);
                    statusLabel.ForeColor = Color.Red;
                    statusLabel.Text      = "No posts found.";
                }
                else
                {
                    statusLabel.ForeColor = Color.Blue;
                    statusLabel.Text      = "Downloading...";
                    for (int i = 0; i < postCount; i++)
                    {
                        await Task.Run(() => engine.downloadPosts(domainBox.Text, tagsBox.Text, i, checkBox1.Checked, ratingCheckBox.Checked));

                        label4.Text = Convert.ToString(postCount - i) + " left";
                    }
                    statusLabel.ForeColor = Color.Green;
                    statusLabel.Text      = "Ready.";
                    label4.Text           = "";
                    MessageBox.Show("Download compelete!", "BooruDownloader", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                }
            }
        }
Пример #2
0
        private async void downloadButton_Click(object sender, EventArgs e)
        {
            EngineBase engine = Detector.detectEngine(domainBox.Text);

            if (engine == null)
            {
                if (isDanbooruSite.Checked == true)
                {
                    engine = new DanEngine();
                }
                else
                {
                    engine = new GelEngine();
                }
            }
            int postCount = engine.getPostCount(domainBox.Text, tagsBox.Text);

            Console.WriteLine(postCount);
            if (postCount == 0)
            {
                Console.WriteLine("No posts found by tag " + tagsBox.Text);
                statusLabel.ForeColor = Color.Red;
                statusLabel.Text      = "No posts found.";
            }
            else
            {
                statusLabel.ForeColor = Color.Blue;
                statusLabel.Text      = "Downloading...";

                int limitBoxText;
                try
                {
                    limitBoxText = int.Parse(limitBox.Text);
                }
                catch (Exception e1)
                {
                    limitBox.Text = "999";
                    limitBoxText  = 999;
                }
                for (int i = 1; i < postCount; i++)
                {
                    if (alreadyDownloaded <= limitBoxText)
                    {
                        await Task.Run(() => engine.downloadPosts(domainBox.Text, tagsBox.Text, i, checkBox1.Checked, ratingCheckBox.Checked));

                        label4.Text = Convert.ToString(postCount - i) + " left";
                        alreadyDownloaded++;
                    }
                }
                statusLabel.ForeColor = Color.Green;
                statusLabel.Text      = "Ready.";
                label4.Text           = "";
                MessageBox.Show("Download compelete!", "BooruDownloader", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
            }
        }