public void LoadNexPage() { if ((currentPage + 1) < pages.Last()) { currentPage += 1; var PreViewAwaiter = WallBoxApi.GetCategoryPageData(((WallBox.DataModel.CategoryModel)CategoriesListBox.SelectedItem).Url, currentPage).GetAwaiter(); PreViewAwaiter.OnCompleted(() => { var data = PreViewAwaiter.GetResult(); pages = data.Item2; foreach (var previewModel in data.Item1) { imageModels.Add(previewModel); } if (AllCheckbox.IsChecked == true) { PreviewListView.SelectAll(); } Loading = false; }); } }
public void LoadCategories() { var TaskAwaiter = WallBoxApi.GetCategoriesAsync().GetAwaiter(); TaskAwaiter.OnCompleted(() => { var data = TaskAwaiter.GetResult(); foreach (WallBox.DataModel.CategoryModel categoryModel in data) { CategoriesListBox.Items.Add(categoryModel); } }); }
private async Task sAsync(string folder, WallBox.DataModel.ImageModel imageobject) { try { var ImageUrl = await WallBoxApi.GetImageUrlAsync(imageobject); Debug.WriteLine(ImageUrl); var sp = ImageUrl.Split('/'); new WebClient().DownloadFile(ImageUrl, folder + "\\" + sp[sp.Length - 2] + sp[sp.Length - 1]); } catch (Exception ex) { Debug.WriteLine(ex.Message); } await this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => { DownloadProgressBar.Value++; DownloadProgressTextBlock.Text = "Загруженно " + DownloadProgressBar.Value + " из " + DownloadProgressBar.Maximum; })); await Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => { if (DownloadProgressBar.Value == DownloadProgressBar.Maximum) { GC.Collect(0, GCCollectionMode.Optimized); GC.Collect(1, GCCollectionMode.Optimized); GC.Collect(2, GCCollectionMode.Optimized); GC.Collect(3, GCCollectionMode.Optimized); DownloadProgressTextBlock.Text = "Загрузка завершена"; FinishExitButton.Visibility = Visibility.Visible; } })); }