private async void LoadTvShowsAsync() { if (IsLoading) { return; } IsLoading = true; TvShows.Clear(); if (App.Context.Connection.Xbmc.IsMocked) { var videoDetailsTvShow = new VideoDetailsTvShow { TvShowId = 1, Title = "Saturday Night Live", Art = new MediaArtwork { Banner = "http://thetvdb.com/banners/_cache/graphical/76177-g5.jpg" } }; TvShows.Add(new ExtendedVideoDetailsTvShow(videoDetailsTvShow)); IsLoading = false; return; } try { var tvshows = await App.Context.Connection.Xbmc.VideoLibrary.GetTvShowsAsync( fields : new[] { VideoFieldsTVShow.art, VideoFieldsTVShow.title, VideoFieldsTVShow.plot, VideoFieldsTVShow.episode, VideoFieldsTVShow.watchedepisodes, VideoFieldsTVShow.playcount }); if (tvshows.TvShows == null || !tvshows.TvShows.Any()) { MessageBox.Show(AppResources.Page_Tv_Shows_Message_No_Tv_Show, AppResources.ApplicationTitle, MessageBoxButton.OK); if (NavigationService.CanGoBack) { NavigationService.GoBack(); } return; } var items = tvshows.TvShows.Where(s => _keepWatched || (!_keepWatched && !s.IsWatched)) .OrderBy(s => s.Label) .Select(s => new ExtendedVideoDetailsTvShow(s)); foreach (var extendedVideoDetailsTvShow in items) { TvShows.Add(extendedVideoDetailsTvShow); } } catch (Exception ex) { App.TrackException(ex); MessageBox.Show(AppResources.Global_Error_Message, AppResources.ApplicationTitle, MessageBoxButton.OK); } finally { IsLoading = false; } }
private async Task LoadTvShowsAsync(bool keepWatched) { if (IsLoading) { return; } IsLoading = true; TvShows.Clear(); if (App.Context.Connection.Kodi.IsMocked) { var videoDetailsTvShow = new VideoDetailsTvShow { TvShowId = 1, Title = "Saturday Night Live", Art = new MediaArtwork { Banner = "http://thetvdb.com/banners/_cache/graphical/76177-g5.jpg" } }; TvShows.Add(new ExtendedVideoDetailsTvShow(videoDetailsTvShow)); IsLoading = false; return; } try { var tvshows = await App.Context.Connection.Kodi.VideoLibrary.GetTvShowsAsync( fields : new[] { VideoFieldsTVShow.art, VideoFieldsTVShow.title, VideoFieldsTVShow.plot, VideoFieldsTVShow.episode, VideoFieldsTVShow.watchedepisodes, VideoFieldsTVShow.playcount }); if (tvshows.TvShows == null || !tvshows.TvShows.Any()) { return; } var items = tvshows.TvShows.Where(s => keepWatched || (!keepWatched && !s.IsWatched)) .OrderBy(s => s.Label) .Select(s => new ExtendedVideoDetailsTvShow(s)); foreach (var extendedVideoDetailsTvShow in items) { TvShows.Add(extendedVideoDetailsTvShow); } } catch (Exception ex) { App.TrackException(ex); var dialog = new MessageDialog(_resourceLoader.GetString("GlobalErrorMessage"), _resourceLoader.GetString("ApplicationTitle")); await dialog.ShowAsync(); } finally { IsLoading = false; } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusbar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView(); statusbar.BackgroundColor = new Windows.UI.Color() { R = 115, G = 143, B = 186 }; statusbar.BackgroundOpacity = 1; statusbar.ForegroundColor = Windows.UI.Colors.White; } int paramIndex = e.Parameter.ToString().IndexOf("|"); string id = e.Parameter.ToString().Substring(0, paramIndex); TvShowTitle = e.Parameter.ToString().Substring(paramIndex + 1); Cast = new ObservableCollection <ExtendedVideoCast>(); Seasons = new ObservableCollection <VideoDetailsSeason>(); IsLoading = true; try { int tvShowId = int.Parse(id); if (App.Context.Connection.Kodi.IsMocked) { #region Mocked TvShow = new VideoDetailsTvShow { TvShowId = 1, Rating = 9, Genre = new[] { "Comedy" }, Studio = new[] { "NBC" }, ImdbNumber = "tt0072562", Thumbnail = "http://thetvdb.com/banners/_cache/posters/76177-4.jpg", FanArt = "http://thetvdb.com/banners/fanart/original/76177-6.jpg", Title = "Saturday Night Live", Plot = "A weekly late-night 90-minute American sketch comedy/variety show broadcast live from Studio 8H at the GE Building in New York's Rockefeller Center. The show is one of the longest-running network programs in American television history and has launched careers for many major American comedy stars of the last thirty years.", Art = new MediaArtwork { Banner = "http://thetvdb.com/banners/_cache/graphical/76177-g5.jpg" }, Cast = new[] { new VideoCast { Name = "Tina Fey", Role = "Artist", Thumbnail = "http://ia.media-imdb.com/images/M/MV5BMTU3NzMwMDI2MF5BMl5BanBnXkFtZTcwNDk0MzcyNw@@._V1._SX214_CR0,0,214,314_.jpg" } } }; #endregion } else { var tvShow = await App.Context.Connection.Kodi.VideoLibrary.GetTvShowDetailsAsync(tvShowId); TvShow = tvShow.TvShowDetails; var seasons = await App.Context.Connection.Kodi.VideoLibrary.GetSeasonsAsync(tvShowId); foreach (VideoDetailsSeason season in seasons.Seasons) { Seasons.Add(season); } } Studio = Helpers.Combine(TvShow.Studio); Genres = Helpers.Combine(TvShow.Genre); Rating = TvShow.Rating / 2; //Votes = string.Format(AppResources.Page_Tv_Shows_Votes_Format, TvShow.Votes); //if (TvShow.ImdbNumber == null) // ButtonSeeImdb.Visibility = Visibility.Collapsed; foreach (var cast in TvShow.Cast) { Cast.Add(new ExtendedVideoCast(cast)); } } catch (Exception ex) { App.TrackException(ex); var dialog = new MessageDialog(_resourceLoader.GetString("GlobalErrorMessage"), _resourceLoader.GetString("ApplicationTitle")); await dialog.ShowAsync(); } finally { IsLoading = false; } if (TvShow != null && !string.IsNullOrWhiteSpace(TvShow.Thumbnail)) { ImageVertical = await Helpers.LoadImageUrl(TvShow.Thumbnail); } if (TvShow != null && App.Context.DownloadFanArt) { ImageHeader = await Helpers.LoadImageUrl(TvShow.FanArt); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { string setTitle; string id; int tvShowId; if (!NavigationContext.QueryString.TryGetValue("id", out id) || !NavigationContext.QueryString.TryGetValue("title", out setTitle) || !int.TryParse(id, out tvShowId)) { if (NavigationService.CanGoBack) { NavigationService.GoBack(); } return; } Cast = new ObservableCollection <ExtendedVideoCast>(); Seasons = new ObservableCollection <VideoDetailsSeason>(); TvShowTitle = HttpUtility.UrlDecode(setTitle); IsLoading = true; try { if (App.Context.Connection.Xbmc.IsMocked) { #region Mocked TvShow = new VideoDetailsTvShow { TvShowId = 1, Rating = 9, Genre = new[] { "Comedy" }, Studio = new[] { "NBC" }, ImdbNumber = "tt0072562", Thumbnail = "http://thetvdb.com/banners/_cache/posters/76177-4.jpg", FanArt = "http://thetvdb.com/banners/fanart/original/76177-6.jpg", Title = "Saturday Night Live", Plot = "A weekly late-night 90-minute American sketch comedy/variety show broadcast live from Studio 8H at the GE Building in New York's Rockefeller Center. The show is one of the longest-running network programs in American television history and has launched careers for many major American comedy stars of the last thirty years.", Art = new MediaArtwork { Banner = "http://thetvdb.com/banners/_cache/graphical/76177-g5.jpg" }, Cast = new[] { new VideoCast { Name = "Tina Fey", Role = "Artist", Thumbnail = "http://ia.media-imdb.com/images/M/MV5BMTU3NzMwMDI2MF5BMl5BanBnXkFtZTcwNDk0MzcyNw@@._V1._SX214_CR0,0,214,314_.jpg" } } }; #endregion } else { var tvShow = await App.Context.Connection.Xbmc.VideoLibrary.GetTvShowDetailsAsync(tvShowId); TvShow = tvShow.TvShowDetails; var seasons = await App.Context.Connection.Xbmc.VideoLibrary.GetSeasonsAsync(tvShowId); foreach (VideoDetailsSeason season in seasons.Seasons) { Seasons.Add(season); } } Studio = Helpers.Combine(TvShow.Studio); Genres = Helpers.Combine(TvShow.Genre); Rating = TvShow.Rating / 2; Votes = string.Format(AppResources.Page_Tv_Shows_Votes_Format, TvShow.Votes); if (TvShow.ImdbNumber == null) { ButtonSeeImdb.Visibility = Visibility.Collapsed; } foreach (var cast in TvShow.Cast.Take(5)) { Cast.Add(new ExtendedVideoCast(cast)); } } catch (Exception ex) { App.TrackException(ex); MessageBox.Show(AppResources.Global_Error_Message, AppResources.ApplicationTitle, MessageBoxButton.OK); } finally { IsLoading = false; } if (TvShow != null && !string.IsNullOrWhiteSpace(TvShow.Thumbnail)) { ImageVertical = await Helpers.LoadImageUrl(TvShow.Thumbnail); } if (TvShow != null && App.Context.DownloadFanArt) { ImageHeader = await Helpers.LoadImageUrl(TvShow.FanArt); } }