Beispiel #1
0
        /// <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();
                }
            }
        }
Beispiel #2
0
        private async Task loadMoreImage()
        {
            if (!imageParser.hasMore)
            {
                noImageTextBlock.Visibility = System.Windows.Visibility.Visible;
                await Task.Delay(2000);

                noImageTextBlock.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                bool fromDormant = false;
                ImageProgressBar.IsIndeterminate = true;
                ImageProgressBar.Visibility      = System.Windows.Visibility.Visible;
                imageNewLoad = true;

                try
                {
                    await imageParser.loadMore();

                    ImageProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                }
                catch (TaskCanceledException)
                {
                    if (App.isFromDormant)
                    {
                        fromDormant = true;
                    }
                    else
                    {
                        ImageProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                        if (!imageParser.isCanceled())
                        {
                            MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
                        }
                    }
                }
                catch (Exception)
                {
                    if (App.isFromDormant)
                    {
                        fromDormant = true;
                    }
                    else
                    {
                        ImageProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                        MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
                    }
                }

                if (fromDormant)
                {
                    App.isFromDormant = false;
                    await loadMoreImage();
                }
            }
        }