Skip to content

Commit

Permalink
Fixed progress bar bug introduced in 65fcff0
Browse files Browse the repository at this point in the history
  • Loading branch information
intel777 committed Dec 20, 2020
1 parent 65fcff0 commit ffc66d2
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Wallhaven Downloader V2/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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")) {
Expand Down

0 comments on commit ffc66d2

Please sign in to comment.