public async void StartDownload() { if (!TryParseAspectRatio()) { MessageBox.Show("The given aspect ratio is not valid.", "ImageDownloader"); return; } IsIdle = false; //Remove trailing slash Source = Source.Trim('/'); Log = new ThreadsafeObservableStringCollection(); Log.Add("Contacting server and parsing responses"); ProgressMaxValue = int.MaxValue; var content = await _downloader.ParseSource(Source); if (content?.GetImages() == null) { Log.Add("Unable to contact server"); ProgressMaxValue = 0; } else { ProgressMaxValue = content.GetImages().Count(); await _downloader.FetchContent(content, TargetFolder, ResolutionFilter, Log = new ThreadsafeObservableStringCollection()); } IsIdle = true; }
public override async void StartDownload() { if (!TryParseAspectRatio()) { MessageBox.Show("The given aspect ratio is not valid.", "ImageDownloader"); return; } IsIdle = false; //Remove trailing slash Source = Source.Trim('/'); Log = new ThreadsafeObservableStringCollection(); Log.Add("Contacting server and parsing responses"); ProgressMaxValue = int.MaxValue; var content = await _downloader.ParseSource(Source); if (content?.GetImages() == null) { Log.Add("Unable to contact server"); ProgressMaxValue = 0; } else { ProgressMaxValue = content.GetImages().Count(); try { await _downloader.FetchContent(content, TargetFolder, ResolutionFilter, Log = new ThreadsafeObservableStringCollection()); } catch (Exception e) { Log.Add("Unhandled error occurred during downloading. Aborting."); var message = "Unhandled error occurred during download.\n" + "Downloading has been aborted.\n\n" + "To get the the error-message and stacktrace\n" + "copied to your clipboard, click 'OK'.\n" + "If you want to report this error, please provide\n" + "the error message in an issue on\n" + "Github.com/Jameak/ImageDownloader"; var result = MessageBox.Show(message, "ImageDownloader", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { Clipboard.SetText(e.ToString()); MessageBox.Show("Error message copied to clipboard", "ImageDownloader", MessageBoxButton.OK); } } } IsIdle = true; }
public async void StartDownload() { if (!TryParseAspectRatio()) { MessageBox.Show("The given aspect ratio is not valid.", "ImageDownloader"); return; } IsIdle = false; RedditListing content; Log = new ThreadsafeObservableStringCollection(); Log.Add("Contacting server and parsing responses"); ProgressMaxValue = int.MaxValue; if (CustomQuery) { content = await _downloader.ParseSource(Source, !SkipAlbums, PostsToGet); } else { //Remove trailing slash Source = Source.Trim('/'); var request = Source.Split('/').Last(); //Remove the unneeded info if the user has typed in full url, instead of just the subreddit. var modifier = PullParam != "top" ? $"/{PullParam}/.json" : $"/top/.json?sort=top&t={TopParam}"; var query = request + modifier; content = await _downloader.ParseSource(query, !SkipAlbums, PostsToGet); } if (content?.GetImages() == null) { Log.Add("Unable to enumerate files"); ProgressMaxValue = 0; } else { ProgressMaxValue = content.GetImages().Count(); await _downloader.FetchContent(content, TargetFolder, Filter, Log); } IsIdle = true; }