///////////////////////////////////////////////////////// Loading functions for tab ///////////////////////////////////////////////// /// <summary> /// Load movie information page /// </summary> private async Task loadMovie() { bool fromDormant = false; MovieProgressBar.IsIndeterminate = true; MovieProgressBar.Visibility = System.Windows.Visibility.Visible; try { Tuple <Movie, List <People> > tuple = await movieParser.getMovieByID(); movie = tuple.Item1; List <People> peoples = tuple.Item2; movieGrid.DataContext = movie; trailer.Content = "预告片"; trailer.NavigateUri = new Uri(Movie.movieLinkHeader + movie.id + "/trailer", UriKind.Absolute); theater.Content = "选座购票"; theater.NavigateUri = new Uri(Movie.movieLinkHeader + movie.id + "/cinema", UriKind.Absolute); slash.Text = " / "; fixedName.Text = "人评分"; peopleSelector.ItemsSource = peoples; MovieProgressBar.Visibility = System.Windows.Visibility.Collapsed; } catch (TaskCanceledException) { if (App.isFromDormant) { fromDormant = true; } else { MovieProgressBar.Visibility = System.Windows.Visibility.Collapsed; // Not canceled by user, must be a network issue if (!movieParser.isCanceled()) { movieLoaded = false; MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK); } } } catch (Exception) { if (App.isFromDormant) { fromDormant = true; } else { MovieProgressBar.Visibility = System.Windows.Visibility.Collapsed; movieLoaded = false; MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK); } } // From dormant state, reload if (fromDormant) { App.isFromDormant = false; await loadMovie(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (App.fromTombStone) { NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } else { if (e.NavigationMode == NavigationMode.New) { if (movieParser != null) { MovieProgressBar.IsIndeterminate = true; MovieProgressBar.Visibility = System.Windows.Visibility.Visible; movieParser.getMovieByID(); } } } }