/// <summary> /// Load image /// </summary> private async Task loadImage() { if (movie != null) { imageParser = new ImageHtmlParser(movie); ImageProgressBar.IsIndeterminate = true; ImageProgressBar.Visibility = System.Windows.Visibility.Visible; bool fromDormant = false; imageNewLoad = true; try { await imageParser.getImage(); imageSelector.ItemsSource = imageParser.imageCollection; if (imageSelector.ItemsSource.Count == 0) { imageTextBlock.Visibility = System.Windows.Visibility.Visible; } ImageProgressBar.Visibility = System.Windows.Visibility.Collapsed; } catch (TaskCanceledException) { if (App.isFromDormant) { fromDormant = true; } else { ImageProgressBar.Visibility = System.Windows.Visibility.Collapsed; if (!imageParser.isCanceled()) { imageLoaded = false; MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK); } } } catch (Exception) { if (App.isFromDormant) { fromDormant = true; } else { imageLoaded = false; ImageProgressBar.Visibility = System.Windows.Visibility.Collapsed; MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK); } } if (fromDormant) { App.isFromDormant = false; await loadImage(); } } }
private void loadImage() { if (movie != null) { loadMoreImageButton.IsEnabled = false; imageParser = new ImageHtmlParser(movie); imageParser.progressBar = ImageProgressBar; ImageProgressBar.IsIndeterminate = true; ImageProgressBar.Visibility = System.Windows.Visibility.Visible; imageParser.button = loadMoreImageButton; imageParser.text = loadImageText; imageListBox.ItemsSource = imageParser.imageCollection; imageParser.parseImage(); } }