Exemple #1
0
        /// <summary>
        /// Load image
        /// </summary>
        private async Task loadImage()
        {
            if (people != null)
            {
                bool fromDormant = false;
                peopleImageParser = new PeopleImageHtmlParser(people);
                ImageProgressBar.IsIndeterminate = true;
                ImageProgressBar.Visibility      = System.Windows.Visibility.Visible;
                imageNewLoad = true;

                try
                {
                    await peopleImageParser.getImage();

                    imageSelector.ItemsSource = peopleImageParser.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 (!peopleImageParser.isCanceled())
                        {
                            imageLoaded = false;
                            MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
                        }
                    }
                }
                catch (Exception)
                {
                    movieProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                    imageLoaded = false;
                    MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
                }

                if (fromDormant)
                {
                    App.isFromDormant = false;
                    await loadImage();
                }
            }
        }
 private void loadImage()
 {
     if (people != null)
     {
         loadMoreImageButton.IsEnabled    = false;
         peopleImageParser                = new PeopleImageHtmlParser(people);
         peopleImageParser.progressBar    = ImageProgressBar;
         ImageProgressBar.IsIndeterminate = true;
         ImageProgressBar.Visibility      = System.Windows.Visibility.Visible;
         peopleImageParser.button         = loadMoreImageButton;
         peopleImageParser.text           = loadImageText;
         imageListBox.ItemsSource         = peopleImageParser.imageCollection;
         peopleImageParser.parseImage();
     }
 }