From ffc66d2aa3abda3c84b88b3cf560a17d2bb58e0f Mon Sep 17 00:00:00 2001 From: Intel Date: Sun, 20 Dec 2020 13:10:47 +0200 Subject: [PATCH] Fixed progress bar bug introduced in 65fcff0b87f0236a7498a69fbb78d8766eb0ca38 --- Wallhaven Downloader V2/Main.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Wallhaven Downloader V2/Main.cs b/Wallhaven Downloader V2/Main.cs index 8b42144..831ed56 100644 --- a/Wallhaven Downloader V2/Main.cs +++ b/Wallhaven Downloader V2/Main.cs @@ -708,7 +708,12 @@ private void DownloadButton_Click(object sender, EventArgs e) { Logpush($"New seed: {search_params.seed}"); } ProgressBarSetValue(0); - SetMaxProgressBar(target_amount); + if (PagesRangeSelectorRadioButton.Checked) { + SetMaxProgressBar((1 + search_params.end_page - search_params.page) * (Int32.Parse(probe.SelectToken("meta.per_page").ToString()))); + } + else { + SetMaxProgressBar(target_amount); + } while ((Images.Count < target_amount & search_params.page <= search_params.end_page) & started) { Thread.Sleep(1340); foreach (var image in probe.SelectToken("data")) { @@ -736,8 +741,23 @@ private void DownloadButton_Click(object sender, EventArgs e) { target_amount = Int32.Parse(response.SelectToken("meta.total").ToString()); Logpush($"Amount set to {target_amount} as it was 0"); } + else { + Logpush("Amount will be used to determine when to stop."); + } + if (search_params.end_page == 0) { + search_params.end_page = Int32.Parse(response.SelectToken("meta.last_page").ToString()); + Logpush($"End page set to {search_params.end_page} as it was 0"); + } + else { + Logpush("Eng page will be used to determine where to stop."); + } ProgressBarSetValue(0); - SetMaxProgressBar(target_amount); + if (PagesRangeSelectorRadioButton.Checked) { + SetMaxProgressBar((1 + search_params.end_page - search_params.page) * (Int32.Parse(response.SelectToken("meta.per_page").ToString()))); + } + else { + SetMaxProgressBar(target_amount); + } while ((Images.Count < target_amount & search_params.page <= search_params.end_page) & started) { Thread.Sleep(1340); foreach (var image in response.SelectToken("data")) {