private void SendCrewToFacade(List <TraktPersonShowJob> crew) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (crew == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); return; } // filter Shows var filteredCrew = FilterCrewShows(crew).Where(m => !string.IsNullOrEmpty(m.Show.Title)).ToList(); // sort Shows filteredCrew.Sort(new GUIListItemShowSorter(TraktSettings.SortByCreditShows.Field, TraktSettings.SortByCreditShows.Direction)); int itemId = 0; GUIShowListItem item = null; var ShowImages = new List <GUITmdbImage>(); foreach (var job in filteredCrew) { // add image for download var images = new GUITmdbImage { ShowImages = new TmdbShowImages { Id = job.Show.Ids.Tmdb } }; ShowImages.Add(images); item = new GUIShowListItem(job.Show.Title, (int)TraktGUIWindows.PersonCreditShows); item.Label2 = job.Show.Year == null ? "----" : job.Show.Year.ToString(); item.Show = job.Show; item.TVTag = job; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", Facade.Count.ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", filteredCrew.Count, filteredCrew.Count > 1 ? Translation.Shows : Translation.Show)); // Download Show images Async and set to facade GUIShowListItem.GetImages(ShowImages); }
private void SendSearchResultsToFacade(IEnumerable <TraktSearchResult> searchResults) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (searchResults == null || searchResults.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound); return; } // jump directly to results if (!TraktSettings.ShowSearchResultsBreakdown && SearchTypes.Count == 1) { // set the selected search type as we have not clicked on a facade item SelectedSearchType = (SearchType)GetSearchTypesID(); SendSearchResultsToWindow(SearchResults); // clear the search term so when we return (press back) we don't go in a loop. SearchTerm = null; return; } int itemId = 0; // Add each search type to the list foreach (var type in SearchTypes) { GUIListItem item = new GUIListItem(GetSearchListName(type)); item.Label2 = GetSearchResultCount(searchResults, type).ToString(); item.ItemId = Int32.MaxValue - itemId; item.TVTag = type; item.IconImage = "defaultFolder.png"; item.IconImageBig = "defaultFolderBig.png"; item.ThumbnailImage = "defaultFolderBig.png"; item.OnItemSelected += OnItemSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout("List"); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= SearchTypes.Count) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", SearchTypes.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", SearchTypes.Count.ToString(), Translation.SearchTypes)); }
private void SendSearchResultsToFacade(IEnumerable <TraktEpisodeSummary> episodes) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (episodes == null || episodes.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound); GUIWindowManager.ShowPreviousWindow(); Episodes = null; return; } int itemId = 0; var showImages = new List <TraktImage>(); // Add each show foreach (var episodeSummary in episodes) { // add images for download var images = new TraktImage { EpisodeImages = episodeSummary.Episode.Images, ShowImages = episodeSummary.Show.Images }; showImages.Add(images); var item = new GUIEpisodeListItem(episodeSummary.ToString(), (int)TraktGUIWindows.SearchEpisodes); item.Label2 = episodeSummary.Show.Year.ToString(); item.TVTag = episodeSummary; item.Images = images; item.IsPlayed = episodeSummary.Episode.Watched; item.ItemId = Int32.MaxValue - itemId; item.IconImage = "defaultTraktEpisode.png"; item.IconImageBig = "defaultTraktEpisodeBig.png"; item.ThumbnailImage = "defaultTraktEpisodeBig.png"; item.OnItemSelected += OnEpisodeSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (SearchTermChanged) { PreviousSelectedIndex = 0; } Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", episodes.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", episodes.Count().ToString(), episodes.Count() > 1 ? Translation.Episodes : Translation.Episode)); // Download images Async and set to facade GUIEpisodeListItem.GetImages(showImages); }
private void SendShowSeasonsToFacade(IEnumerable <TraktShowSeason> seasons) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (seasons == null || seasons.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSeasonsForShow); GUIWindowManager.ShowPreviousWindow(); return; } // sort ascending or descending order if (TraktSettings.SortSeasonsAscending) { seasons = seasons.OrderBy(s => s.Season); } int itemId = 0; var seasonImages = new List <TraktImage>(); foreach (var season in seasons) { // add image for download var images = new TraktImage { SeasonImages = season.Images, ShowImages = Show.Images }; seasonImages.Add(images); string itemLabel = season.Season == 0 ? Translation.Specials : string.Format("{0} {1}", Translation.Season, season.Season.ToString()); var item = new GUISeasonListItem(itemLabel, (int)TraktGUIWindows.ShowSeasons); item.Label2 = string.Format("{0} {1}", season.EpisodeCount, Translation.Episodes); item.TVTag = season; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnSeasonSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", seasons.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", seasons.Count().ToString(), seasons.Count() > 1 ? Translation.Seasons : Translation.Season)); // Download show images Async and set to facade GUISeasonListItem.GetImages(seasonImages); }
private void SendTrendingShowsToFacade(IEnumerable <TraktTrendingShow> shows) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (shows.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoTrendingShows); GUIWindowManager.ShowPreviousWindow(); return; } // filter shows shows = GUICommon.FilterTrendingShows(shows); // sort shows var showList = shows.ToList(); showList.Sort(new GUIListItemShowSorter(TraktSettings.SortByTrendingShows.Field, TraktSettings.SortByTrendingShows.Direction)); int itemId = 0; List <TraktShow.ShowImages> showImages = new List <TraktShow.ShowImages>(); foreach (var show in showList) { GUITraktTrendingShowListItem item = new GUITraktTrendingShowListItem(show.Title); item.Label2 = show.Year.ToString(); item.TVTag = show; item.Item = show.Images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = "defaultVideo.png"; item.IconImageBig = "defaultVideoBig.png"; item.ThumbnailImage = "defaultVideoBig.png"; item.OnItemSelected += OnShowSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; // add image for download showImages.Add(show.Images); } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", shows.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", shows.Count().ToString(), shows.Count() > 1 ? Translation.SeriesPlural : Translation.Series)); GUIUtils.SetProperty("#Trakt.Trending.PeopleCount", shows.Sum(s => s.Watchers).ToString()); GUIUtils.SetProperty("#Trakt.Trending.Description", string.Format(Translation.TrendingTVShowsPeople, shows.Sum(s => s.Watchers).ToString(), shows.Count().ToString())); // Download show images Async and set to facade GetImages(showImages); }
private void SendRelatedMoviesToFacade(IEnumerable <TraktMovie> movies) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (movies.Count() == 0) { string title = string.IsNullOrEmpty(relatedMovie.Title) ? relatedMovie.IMDbId : relatedMovie.Title; GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoRelatedMovies, title)); GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; var movieImages = new List <TraktImage>(); // Add each movie foreach (var movie in movies.Where(m => !string.IsNullOrEmpty(m.Title))) { var item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.RelatedMovies); // add image for download var image = new TraktImage { MovieImages = movie.Images }; movieImages.Add(image); item.Label2 = movie.Year; item.TVTag = movie; item.Images = image; item.IsPlayed = movie.Watched; item.ItemId = Int32.MaxValue - itemId; // movie in collection doesnt nessararily mean // that the movie is locally available on this computer // as 'keep library clean' might not be enabled //item.IsRemote = !movie.InCollection; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", movies.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movies.Count().ToString(), movies.Count() > 1 ? Translation.Movies : Translation.Movie)); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void SendSearchResultsToFacade(IEnumerable <TraktMovie> movies) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (movies == null || movies.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound); GUIWindowManager.ShowPreviousWindow(); Movies = null; return; } int itemId = 0; var movieImages = new List <TraktImage>(); // Add each movie foreach (var movie in movies) { // add image for download var images = new TraktImage { MovieImages = movie.Images }; movieImages.Add(images); GUIMovieListItem item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.SearchMovies); item.Label2 = movie.Year == "0" ? "----" : movie.Year; item.TVTag = movie; item.Images = images; item.IsPlayed = movie.Watched; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (SearchTermChanged) { PreviousSelectedIndex = 0; } Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", movies.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movies.Count().ToString(), movies.Count() > 1 ? Translation.Movies : Translation.Movie)); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void SendSearchResultsToFacade(IEnumerable <TraktPersonSummary> people) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (people == null || people.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound); GUIWindowManager.ShowPreviousWindow(); People = null; return; } int itemId = 0; var personImages = new List <TraktImage>(); // Add each movie foreach (var person in people) { // add image for download var images = new TraktImage { PoepleImages = person.Images }; personImages.Add(images); var item = new GUIPersonListItem(person.Name.Trim(), (int)TraktGUIWindows.SearchPeople); item.TVTag = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnPersonSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (SearchTermChanged) { PreviousSelectedIndex = 0; } Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", people.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", people.Count().ToString(), people.Count() > 1 ? Translation.People : Translation.Person)); // Download images Async and set to facade GUIPersonListItem.GetImages(personImages); }
private void SendSearchResultsToFacade(IEnumerable <TraktUser> users) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (users == null || users.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound); GUIWindowManager.ShowPreviousWindow(); Users = null; return; } int itemId = 0; var userImages = new List <TraktImage>(); // Add each user foreach (var user in users) { // add image to download var images = new TraktImage { Avatar = user.Avatar }; userImages.Add(images); var item = new GUIUserListItem(user.Username, (int)TraktGUIWindows.SearchUsers); item.Images = images; item.TVTag = user; item.ItemId = Int32.MaxValue - itemId; item.IconImage = "defaultTraktUser.png"; item.IconImageBig = "defaultTraktUserBig.png"; item.ThumbnailImage = "defaultTraktUserBig.png"; item.OnItemSelected += OnUserSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (SearchTermChanged) { PreviousSelectedIndex = 0; } Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", users.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", users.Count().ToString(), users.Count() > 1 ? Translation.Users : Translation.User)); // Download images Async and set to facade GUIUserListItem.GetImages(userImages); }
private void SendListItemsToFacade(TraktUserList list) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (list.Items == null || list.Items.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoListItemsFound); GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 1; var listImages = new List <TraktImage>(); // Add each list item foreach (var listItem in list.Items.Where(l => !string.IsNullOrEmpty(l.Title))) { // add image for download var images = GetTraktImage(listItem); listImages.Add(images); string itemName = list.ShowNumbers ? string.Format("{0}. {1}", itemId, GetListItemName(listItem)) : GetListItemName(listItem); var item = new GUICustomListItem(itemName, (int)TraktGUIWindows.ListItems); item.Label2 = listItem.Year; item.TVTag = listItem; item.Images = images; item.IsPlayed = listItem.Watched; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnItemSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", list.Items.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", list.Items.Count().ToString(), list.Items.Count() > 1 ? Translation.Items : Translation.Item)); // Download images Async and set to facade GUICustomListItem.GetImages(listImages); }
private void SendRelatedShowsToFacade(IEnumerable <TraktShow> shows) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (shows.Count() == 0) { string title = string.IsNullOrEmpty(relatedShow.Title) ? relatedShow.TVDbId : relatedShow.Title; GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoRelatedShows, title)); GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; var showImages = new List <TraktImage>(); foreach (var show in shows) { var item = new GUIShowListItem(show.Title, (int)TraktGUIWindows.RelatedShows); // add image for download var images = new TraktImage { ShowImages = show.Images }; showImages.Add(images); item.Label2 = show.Year.ToString(); item.TVTag = show; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnShowSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", shows.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", shows.Count().ToString(), shows.Count() > 1 ? Translation.SeriesPlural : Translation.Series)); // Download show images Async and set to facade GUIShowListItem.GetImages(showImages); }
private void SendTrendingListsToFacade(IEnumerable <TraktListTrending> lists) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (lists == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; // Add each list foreach (var trending in lists) { var item = new GUIListItem(trending.List.Name.RemapHighOrderChars()); item.Label2 = string.Format("{0} {1}", trending.List.ItemCount, trending.List.ItemCount != 1 ? Translation.Items : Translation.Item); item.TVTag = trending; item.ItemId = Int32.MaxValue - itemId; item.PinImage = TraktLists.GetPrivacyLevelIcon(trending.List.Privacy); item.IconImage = "defaultFolder.png"; item.IconImageBig = "defaultFolderBig.png"; item.ThumbnailImage = "defaultFolderBig.png"; item.OnItemSelected += OnItemSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.CurrentLayout = GUIFacadeControl.Layout.List; GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= lists.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", lists.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", lists.Count().ToString(), lists.Count() > 1 ? Translation.Lists : Translation.List)); }
private void SendListItemsToFacade(TraktUserList list) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (list.Items == null || list.Items.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoListItemsFound); GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; List <object> images = new List <object>(); // Add each list item foreach (var listItem in list.Items) { GUITraktCustomListItem item = new GUITraktCustomListItem(listItem.ToString()); item.Label2 = listItem.Year; item.TVTag = listItem; item.Item = listItem.Images; item.IsPlayed = listItem.Watched; item.ItemId = Int32.MaxValue - itemId; item.IconImage = "defaultVideo.png"; item.IconImageBig = "defaultVideoBig.png"; item.ThumbnailImage = "defaultVideoBig.png"; item.OnItemSelected += OnItemSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; // add image for download images.Add(listItem.Images); } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", list.Items.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", list.Items.Count().ToString(), list.Items.Count() > 1 ? Translation.Items : Translation.Item)); // Download images Async and set to facade GetImages(images); }
// triggered when a group header was selected on the facade private static void onGroupHeaderSelected(GUIListItem item, GUIControl parent) { // if this is not a message from the facade, exit GUIFacadeControl facade = Browser.Facade; if (!facade.IsRelated(parent) || facade.SelectedListItem != item) { return; } int newIndex = facade.SelectedListItemIndex; int oldIndex = Browser.SelectedIndex; int lastIndex = facade.Count - 1; logger.Debug("onGroupHeaderSelected CurrentIndex {0} OldIndex {1}", newIndex, oldIndex); if (newIndex < oldIndex && !(newIndex == 0 && oldIndex == lastIndex)) { // MOVE UP logger.Debug("Jumping Up"); if (newIndex == 0) { facade.SelectIndex(lastIndex); } else { facade.OnAction(new MediaPortal.GUI.Library.Action(MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_UP, 0, 0)); } } else { // MOVE DOWN logger.Debug("Jumping Down"); facade.OnAction(new MediaPortal.GUI.Library.Action(MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_DOWN, 0, 0)); } }
private void SendBoxOfficeToFacade(IEnumerable <TraktMovieBoxOffice> boxOffice) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (boxOffice == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); return; } if (boxOffice.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoBoxOffice); GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; var movieImages = new List <GUITmdbImage>(); // Add each movie foreach (var box in boxOffice.Where(b => !string.IsNullOrEmpty(b.Movie.Title))) { var item = new GUIMovieListItem(box.Movie.Title, (int)TraktGUIWindows.BoxOffice); // add image for download var image = new GUITmdbImage { MovieImages = new TmdbMovieImages { Id = box.Movie.Ids.Tmdb } }; movieImages.Add(image); item.Label2 = box.Movie.Year == null ? "----" : box.Movie.Year.ToString(); item.TVTag = box; item.Movie = box.Movie; item.Images = image; item.IsPlayed = box.Movie.IsWatched(); item.ItemId = Int32.MaxValue - itemId; // movie in collection doesnt nessararily mean // that the movie is locally available on this computer // as 'keep library clean' might not be enabled //item.IsRemote = !movie.InCollection; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", boxOffice.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", boxOffice.Count().ToString(), boxOffice.Count() > 1 ? Translation.Movies : Translation.Movie)); int totalRevenue = boxOffice.Sum(b => b.Revenue); GUIUtils.SetProperty("#Trakt.BoxOffice.Total.Revenue", string.Format("{0:C0}", totalRevenue)); GUIUtils.SetProperty("#Trakt.BoxOffice.Total.Revenue.Raw", totalRevenue.ToString()); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void SendRecentlyWatchedToFacade(IEnumerable <TraktMovieHistory> recentlyWatched) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); // protected profiles might return null if (recentlyWatched == null || recentlyWatched.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.UserHasNotWatchedMovies); PreviousUser = CurrentUser; CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; var movieImages = new List <GUITmdbImage>(); // Add each item watched foreach (var recent in recentlyWatched) { // bad data in API if (recent.Movie == null) { continue; } // add image for download var images = new GUITmdbImage { MovieImages = new TmdbMovieImages { Id = recent.Movie.Ids.Tmdb } }; movieImages.Add(images); var item = new GUIMovieListItem(recent.Movie.Title, (int)TraktGUIWindows.RecentWatchedMovies); // add user watched date as second label item.Label2 = recent.WatchedAt.ToPrettyDateTime(); item.Date = recent.WatchedAt.FromISO8601().ToLongDateString(); item.Action = recent.Action; item.TVTag = recent.Movie; item.Movie = recent.Movie; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IsPlayed = CurrentUser != TraktSettings.Username ? recent.Movie.IsWatched() : false; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= recentlyWatched.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", recentlyWatched.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", recentlyWatched.Count().ToString(), recentlyWatched.Count() > 1 ? Translation.Movies : Translation.Movie)); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void SendRecentlyWatchedToFacade(IEnumerable <TraktActivity.Activity> activities) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); // protected profiles might return null if (activities == null || activities.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.UserHasNotWatchedEpisodes); PreviousUser = CurrentUser; CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; var showImages = new List <TraktImage>(); // Add each item watched foreach (var activity in activities) { // bad data in API if (activity.Show == null || activity.Episode == null) { continue; } var episodeSummary = new TraktEpisodeSummary { Episode = activity.Episode, Show = activity.Show }; // skip invalid episodes if (episodeSummary.Episode.Number == 0) { continue; } var item = new GUIEpisodeListItem(episodeSummary.ToString(), (int)TraktGUIWindows.RecentWatchedEpisodes); // add images for download var images = new TraktImage { EpisodeImages = activity.Episode.Images, ShowImages = activity.Show.Images }; showImages.Add(images); // add user watched date as second label item.Label2 = activity.Timestamp.FromEpoch().ToShortDateString(); item.TVTag = episodeSummary; item.Date = activity.Timestamp.FromEpoch().ToLongDateString(); item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IsPlayed = activity.Episode.Watched; item.IconImage = "defaultTraktEpisode.png"; item.IconImageBig = "defaultTraktEpisodeBig.png"; item.ThumbnailImage = "defaultTraktEpisodeBig.png"; item.OnItemSelected += OnEpisodeSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= activities.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", activities.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", activities.Count().ToString(), activities.Count() > 1 ? Translation.Episodes : Translation.Episode)); // Download show images Async and set to facade GUIEpisodeListItem.GetImages(showImages); }
/// <summary> /// Selects the requested, or if not available the first, object of the specified type in the facade /// </summary> /// <typeparam name="T"></typeparam> /// <param name="self"></param> /// <param name="item">the object to select or null </param> /// <param name="selectedIndex">the index of the selection</param> /// <returns>selected object</returns> public static T SyncToFacade <T>(this GUIFacadeControl self, T item, out int selectedIndex) where T : class { lock (self) { object selectedItem = null; selectedIndex = -1; // no use in syncing when we got no items if (self.Count == 0) { return(null); } // Check if the current selected item already is the item we want // if so we don't have to do the routine check if (item != null & self.SelectedListItem != null && self.SelectedListItem.TVTag is T) { if (self.SelectedListItem.TVTag == item) { selectedItem = self.SelectedListItem.TVTag; selectedIndex = self.SelectedListItemIndex; } } // Find the item in the facade and mark the first item found if (selectedItem == null) { for (int i = 0; i < self.Count; i++) { if (self[i].TVTag is T) { // mark the first item found if (selectedIndex == -1) { selectedIndex = i; } // if we found the item or had no selection break the loop; if (item == null || item == self[i].TVTag) { selectedIndex = i; selectedItem = self[i].TVTag; break; } } } // if no item was found during the iteration we use the first item found if (selectedItem == null) { if (selectedIndex == -1) { return(null); } selectedItem = self[selectedIndex].TVTag; } // select the item in the facade if (self.SelectedListItemIndex != selectedIndex) { logger.Debug("SyncToFacade<{0}>: Index={1}, Item={2}", typeof(T).Name, selectedIndex, selectedItem); self.SelectIndex(selectedIndex); } } // return the (new) selected item return(selectedItem as T); } }
private void SendSearchResultsToFacade(IEnumerable <TraktEpisodeSummaryEx> episodes) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (episodes == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); Episodes = null; return; } if (episodes.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound); GUIWindowManager.ShowPreviousWindow(); Episodes = null; return; } int itemId = 0; var showImages = new List <GUITmdbImage>(); // Add each show foreach (var episodeSummary in episodes) { // add images for download var images = new GUITmdbImage { EpisodeImages = new TmdbEpisodeImages { Id = episodeSummary.Show.Ids.Tmdb, Season = episodeSummary.Episode.Season, Episode = episodeSummary.Episode.Number, AirDate = episodeSummary.Episode.FirstAired == null ? null : episodeSummary.Episode.FirstAired.FromISO8601().ToLocalTime().ToShortDateString() } }; showImages.Add(images); var item = new GUIEpisodeListItem(episodeSummary.ToString(), (int)TraktGUIWindows.SearchEpisodes); item.Label2 = episodeSummary.Show.Year.ToString(); item.TVTag = episodeSummary; item.Episode = episodeSummary.Episode; item.Show = episodeSummary.Show; item.Images = images; item.IsPlayed = episodeSummary.Episode.IsWatched(episodeSummary.Show); item.ItemId = Int32.MaxValue - itemId; item.IconImage = "defaultTraktEpisode.png"; item.IconImageBig = "defaultTraktEpisodeBig.png"; item.ThumbnailImage = "defaultTraktEpisodeBig.png"; item.OnItemSelected += OnEpisodeSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); if (SearchTermChanged) { PreviousSelectedIndex = 0; } Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", episodes.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", episodes.Count().ToString(), episodes.Count() > 1 ? Translation.Episodes : Translation.Episode)); // Download images Async and set to facade GUIEpisodeListItem.GetImages(showImages); }
private void SendTrendingMoviesToFacade(IEnumerable <TraktTrendingMovie> movies) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (movies.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoTrendingMovies); GUIWindowManager.ShowPreviousWindow(); return; } // filter movies movies = GUICommon.FilterTrendingMovies(movies); // sort movies var movieList = movies.Where(m => !string.IsNullOrEmpty(m.Title)).ToList(); movieList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByTrendingMovies.Field, TraktSettings.SortByTrendingMovies.Direction)); int itemId = 0; var movieImages = new List <TraktImage>(); // Add each movie mark remote if not in collection foreach (var movie in movieList) { // add image for download var images = new TraktImage { MovieImages = movie.Images }; movieImages.Add(images); var item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.TrendingMovies); item.Label2 = movie.Year == "0" ? "----" : movie.Year; item.TVTag = movie; item.Images = images; item.IsPlayed = movie.Watched; item.ItemId = Int32.MaxValue - itemId; // movie in collection doesnt nessararily mean // that the movie is locally available on this computer // as 'keep library clean' might not be enabled //item.IsRemote = !movie.InCollection; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", movies.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movies.Count().ToString(), movies.Count() > 1 ? Translation.Movies : Translation.Movie)); GUIUtils.SetProperty("#Trakt.Trending.PeopleCount", movies.Sum(m => m.Watchers).ToString()); GUIUtils.SetProperty("#Trakt.Trending.Description", string.Format(Translation.TrendingMoviePeople, movies.Sum(m => m.Watchers).ToString(), movies.Count().ToString())); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void SendListsToFacade(IEnumerable <TraktUserList> lists) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (lists.Count() == 0 && TraktSettings.Username != CurrentUser) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoUserLists, CurrentUser)); CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } if (lists.Count() == 0) { if (!GUIUtils.ShowYesNoDialog(Translation.Lists, Translation.NoListsFound, true)) { // nothing to do, exit GUIWindowManager.ShowPreviousWindow(); return; } TraktList list = new TraktList(); if (TraktLists.GetListDetailsFromUser(ref list)) { TraktLogger.Info("Creating new '{0}' list '{1}'", list.Privacy, list.Name); CreateList(list); } return; } int itemId = 0; // Add each list foreach (var list in lists) { GUIListItem item = new GUIListItem(list.Name); item.Label2 = TraktLists.GetPrivacyLevelTranslation(list.Privacy); item.TVTag = list; item.ItemId = Int32.MaxValue - itemId; item.IconImage = "defaultFolder.png"; item.IconImageBig = "defaultFolderBig.png"; item.ThumbnailImage = "defaultFolderBig.png"; item.OnItemSelected += OnItemSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout("List"); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= lists.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", lists.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", lists.Count().ToString(), lists.Count() > 1 ? Translation.Lists : Translation.List)); }
private void SendCreditResultsToFacade(TraktCredits credits) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (credits == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); Show = null; return; } int itemId = 0; var personImages = new List <GUITmdbImage>(); // Add each character if (Type == CreditType.Cast && credits.Cast != null) { foreach (var person in credits.Cast) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(string.IsNullOrEmpty(person.Character) ? person.Person.Name : string.Format(Translation.ActorAndRole, person.Person.Name, person.Character), (int)TraktGUIWindows.CreditsShow); item.Person = person.Person; item.CreditType = Credit.Cast; item.Character = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCastSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } // add each crew member if (Type == CreditType.Crew && credits.Crew != null) { if (credits.Crew.Directing != null) { foreach (var person in credits.Crew.Directing) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Directing; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.Writing != null) { foreach (var person in credits.Crew.Writing) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Writing; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.Production != null) { foreach (var person in credits.Crew.Production) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Production; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.Art != null) { foreach (var person in credits.Crew.Art) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Art; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.Camera != null) { foreach (var person in credits.Crew.Camera) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Camera; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.CostumeAndMakeUp != null) { foreach (var person in credits.Crew.CostumeAndMakeUp) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.CostumeAndMakeUp; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.Sound != null) { foreach (var person in credits.Crew.Sound) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Sound; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } } // if nothing to display exit if (Facade.Count == 0) { GUIUtils.ShowNotifyDialog(Type == CreditType.Crew ? Translation.Crew : Translation.Cast, Translation.NoCreditsFound); GUIWindowManager.ShowPreviousWindow(); Show = null; return; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", Facade.Count.ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", Facade.Count.ToString(), Facade.Count > 1 ? Translation.People : Translation.Person)); // Download images Async and set to facade GUIPersonListItem.GetImages(personImages, false); }
private void SendPopularMoviesToFacade(TraktMoviesPopular PopularItems) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (PopularItems == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); PopularMoviePages = null; return; } // filter movies var filteredPopularList = FilterPopularMovies(PopularItems.Movies).Where(m => !string.IsNullOrEmpty(m.Title)).ToList(); // sort movies filteredPopularList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByPopularMovies.Field, TraktSettings.SortByPopularMovies.Direction)); int itemId = 0; var movieImages = new List <GUITmdbImage>(); // Add Previous Page Button if (PopularItems.CurrentPage != 1) { var prevPageItem = new GUIMovieListItem(Translation.PreviousPage, (int)TraktGUIWindows.PopularMovies); prevPageItem.IsPrevPageItem = true; prevPageItem.IconImage = "traktPreviousPage.png"; prevPageItem.IconImageBig = "traktPreviousPage.png"; prevPageItem.ThumbnailImage = "traktPreviousPage.png"; prevPageItem.OnItemSelected += OnPreviousPageSelected; prevPageItem.IsFolder = true; Facade.Add(prevPageItem); itemId++; } // Add each movie mark remote if not in collection foreach (var PopularItem in filteredPopularList) { // add image for download var images = new GUITmdbImage { MovieImages = new TmdbMovieImages { Id = PopularItem.Ids.Tmdb } }; movieImages.Add(images); var item = new GUIMovieListItem(PopularItem.Title, (int)TraktGUIWindows.PopularMovies); item.Label2 = PopularItem.Year == null ? "----" : PopularItem.Year.ToString(); item.TVTag = PopularItem; item.Movie = PopularItem; item.Images = images; item.IsPlayed = PopularItem.IsWatched(); item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Add Next Page Button if (PopularItems.CurrentPage != PopularItems.TotalPages) { var nextPageItem = new GUIMovieListItem(Translation.NextPage, (int)TraktGUIWindows.PopularMovies); nextPageItem.IsNextPageItem = true; nextPageItem.IconImage = "traktNextPage.png"; nextPageItem.IconImageBig = "traktNextPage.png"; nextPageItem.ThumbnailImage = "traktNextPage.png"; nextPageItem.OnItemSelected += OnNextPageSelected; nextPageItem.IsFolder = true; Facade.Add(nextPageItem); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", filteredPopularList.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", filteredPopularList.Count(), filteredPopularList.Count() > 1 ? Translation.Movies : Translation.Movie)); // Page Properties GUIUtils.SetProperty("#Trakt.Facade.CurrentPage", PopularItems.CurrentPage.ToString()); GUIUtils.SetProperty("#Trakt.Facade.TotalPages", PopularItems.TotalPages.ToString()); GUIUtils.SetProperty("#Trakt.Facade.TotalItemsPerPage", TraktSettings.MaxPopularMoviesRequest.ToString()); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void SendShowSeasonsToFacade(IEnumerable <TraktSeasonSummary> seasons) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (seasons == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); return; } if (seasons.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSeasonsForShow); GUIWindowManager.ShowPreviousWindow(); return; } // sort ascending or descending order if (!TraktSettings.SortSeasonsAscending) { seasons = seasons.OrderByDescending(s => s.Number).ToList(); } else { seasons = seasons.OrderBy(s => s.Number).ToList(); } int itemId = 0; var seasonImages = new List <GUITmdbImage>(); // skip over any seasons with no episodes foreach (var season in seasons.Where(s => s.EpisodeCount > 0)) { // add image for download var images = new GUITmdbImage { SeasonImages = new TmdbSeasonImages { Id = Show.Ids.Tmdb, Season = season.Number } }; seasonImages.Add(images); // if a custom title is set for the season, use that, otherwise use a translated string string itemLabel = season.Number == 0 ? Translation.Specials : string.Format("{0} {1}", Translation.Season, season.Number.ToString()); if (!string.IsNullOrEmpty(season.Title) && itemLabel != season.Title) { itemLabel = string.Format("{0}. {1}", season.Number, season.Title); } var item = new GUISeasonListItem(itemLabel, (int)TraktGUIWindows.ShowSeasons); item.Label2 = string.Format("{0} {1}", season.EpisodeCount, Translation.Episodes); item.TVTag = season; item.Show = Show; item.Season = season; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IsPlayed = season.IsWatched(Show); item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnSeasonSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", seasons.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", seasons.Count().ToString(), seasons.Count() > 1 ? Translation.Seasons : Translation.Season)); // Download show images Async and set to facade GUISeasonListItem.GetImages(seasonImages); }
private void SendWatchListShowsToFacade(IEnumerable <TraktWatchListShow> shows) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (shows.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoShowWatchList, CurrentUser)); CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } // sort shows var showList = shows.ToList(); showList.Sort(new GUIListItemShowSorter(TraktSettings.SortByWatchListShows.Field, TraktSettings.SortByWatchListShows.Direction)); int itemId = 0; var showImages = new List <TraktImage>(); // Add each show foreach (var show in showList) { // add image for download var images = new TraktImage { ShowImages = show.Images }; showImages.Add(images); GUIShowListItem item = new GUIShowListItem(show.Title, (int)TraktGUIWindows.WatchedListShows); item.Label2 = show.Year.ToString(); item.TVTag = show; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnShowSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= shows.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", shows.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", shows.Count().ToString(), shows.Count() > 1 ? Translation.SeriesPlural : Translation.Series)); // Download show images Async and set to facade GUIShowListItem.GetImages(showImages); }
private void SendRecentCommentsToFacade(IEnumerable <TraktCommentItem> comments) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); // protected profiles might also return null if (comments == null || comments.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.UserHasNoRecentShouts); PreviousUser = CurrentUser; CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 0; var commentImages = new List <GUITmdbImage>(); // Add each item added foreach (var comment in comments) { // bad api data - at least one must not be null if (comment.Movie == null && comment.Show == null && comment.List == null) { continue; } // add image for download var images = GetTmdbImage(comment); commentImages.Add(images); var item = new GUICustomListItem(GetCommentItemTitle(comment), (int)TraktGUIWindows.RecentShouts); // add user shout date as second label item.Label2 = comment.Comment.CreatedAt.ToPrettyDateTime(); item.TVTag = comment; item.Episode = comment.Episode; item.Show = comment.Show; item.Movie = comment.Movie; item.Season = comment.Season; item.List = comment.List; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.PinImage = "traktActivityShout.png"; item.OnItemSelected += OnCommentSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // set Facade Layout Facade.SetCurrentLayout("List"); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= comments.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", comments.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", comments.Count().ToString(), comments.Count() > 1 ? Translation.Comment : Translation.Comments)); // Download images Async and set to facade GUICustomListItem.GetImages(commentImages); }
private void SendTrendingShowsToFacade(TraktShowsTrending trendingItems) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (trendingItems == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); TrendingShowPages = null; return; } if (trendingItems.Shows.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoTrendingShows); GUIWindowManager.ShowPreviousWindow(); TrendingShowPages = null; return; } // filter shows var filteredTrendingList = GUICommon.FilterTrendingShows(trendingItems.Shows).Where(s => !string.IsNullOrEmpty(s.Show.Title)).ToList(); // sort shows filteredTrendingList.Sort(new GUIListItemShowSorter(TraktSettings.SortByTrendingShows.Field, TraktSettings.SortByTrendingShows.Direction)); int itemId = 0; var showImages = new List <GUITmdbImage>(); // Add Previous Page Button if (trendingItems.CurrentPage != 1) { var prevPageItem = new GUIShowListItem(Translation.PreviousPage, (int)TraktGUIWindows.TrendingShows); prevPageItem.IsPrevPageItem = true; prevPageItem.IconImage = "traktPreviousPage.png"; prevPageItem.IconImageBig = "traktPreviousPage.png"; prevPageItem.ThumbnailImage = "traktPreviousPage.png"; prevPageItem.OnItemSelected += OnPreviousPageSelected; prevPageItem.IsFolder = true; Facade.Add(prevPageItem); itemId++; } foreach (var trendingItem in filteredTrendingList) { var item = new GUIShowListItem(trendingItem.Show.Title, (int)TraktGUIWindows.TrendingShows); // add image for download var image = new GUITmdbImage { ShowImages = new TmdbShowImages { Id = trendingItem.Show.Ids.Tmdb } }; showImages.Add(image); item.Label2 = trendingItem.Show.Year.ToString(); item.TVTag = trendingItem; item.Show = trendingItem.Show; item.Images = image; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnShowSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Add Next Page Button if (trendingItems.CurrentPage != trendingItems.TotalPages) { var nextPageItem = new GUIShowListItem(Translation.NextPage, (int)TraktGUIWindows.TrendingShows); nextPageItem.IsNextPageItem = true; nextPageItem.IconImage = "traktNextPage.png"; nextPageItem.IconImageBig = "traktNextPage.png"; nextPageItem.ThumbnailImage = "traktNextPage.png"; nextPageItem.OnItemSelected += OnNextPageSelected; nextPageItem.IsFolder = true; Facade.Add(nextPageItem); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", filteredTrendingList.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", filteredTrendingList.Count(), filteredTrendingList.Count() > 1 ? Translation.SeriesPlural : Translation.Series)); GUIUtils.SetProperty("#Trakt.Trending.PeopleCount", trendingItems.TotalWatchers.ToString()); GUIUtils.SetProperty("#Trakt.Trending.Description", string.Format(Translation.TrendingTVShowsPeople, trendingItems.TotalWatchers.ToString(), trendingItems.TotalItems.ToString())); // Page Properties GUIUtils.SetProperty("#Trakt.Facade.CurrentPage", trendingItems.CurrentPage.ToString()); GUIUtils.SetProperty("#Trakt.Facade.TotalPages", trendingItems.TotalPages.ToString()); GUIUtils.SetProperty("#Trakt.Facade.TotalItemsPerPage", TraktSettings.MaxTrendingShowsRequest.ToString()); // Download show images Async and set to facade GUIShowListItem.GetImages(showImages); }
private void SendListItemsToFacade(IEnumerable <TraktListItem> listItems) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (listItems == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); return; } CurrentListItems = listItems.ToList(); if (listItems.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoListItemsFound); GUIWindowManager.ShowPreviousWindow(); return; } int itemId = 1; var listImages = new List <GUITmdbImage>(); // Add each list item foreach (var listItem in listItems) { // add image for download var images = GetTmdbImage(listItem); listImages.Add(images); string itemName = CurrentList.DisplayNumbers ? string.Format("{0}. {1}", itemId, GetListItemLabel(listItem)) : GetListItemLabel(listItem); var item = new GUICustomListItem(itemName, (int)TraktGUIWindows.CustomListItems); item.Label2 = GetListItemSecondLabel(listItem); item.TVTag = listItem; item.Type = (TraktItemType)Enum.Parse(typeof(TraktItemType), listItem.Type, true); item.Movie = listItem.Movie; item.Show = listItem.Show; item.Episode = listItem.Episode; item.Season = listItem.Season; item.Person = listItem.Person; item.Images = images; item.IsPlayed = listItem.IsWatched(); item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnItemSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", listItems.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", listItems.Count().ToString(), listItems.Count() > 1 ? Translation.Items : Translation.Item)); // Download images Async and set to facade GUICustomListItem.GetImages(listImages); }
private void SendWatchListMoviesToFacade(IEnumerable <TraktWatchListMovie> movies) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (movies.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoMovieWatchList, CurrentUser)); CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } // sort movies var movieList = movies.Where(m => !string.IsNullOrEmpty(m.Title)).ToList(); movieList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByWatchListMovies.Field, TraktSettings.SortByWatchListMovies.Direction)); int itemId = 0; var movieImages = new List <TraktImage>(); // Add each movie foreach (var movie in movieList) { // add image for download var images = new TraktImage { MovieImages = movie.Images }; movieImages.Add(images); var item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.WatchedListMovies); item.Label2 = movie.Year; item.TVTag = movie; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IsPlayed = movie.Watched; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= movies.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", movies.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movies.Count().ToString(), movies.Count() > 1 ? Translation.Movies : Translation.Movie)); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
private void SendSeasonEpisodesToFacade(IEnumerable <TraktEpisode> episodes) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (episodes == null || episodes.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoEpisodesInSeason); GUIWindowManager.ShowPreviousWindow(); return; } // Set Common Show Properties GUICommon.SetShowProperties(Show); int itemCount = 0; var episodeImages = new List <TraktImage>(); foreach (var episode in episodes) { // use episode short string string itemLabel = string.Format("{0}. {1}", episode.Number.ToString(), string.IsNullOrEmpty(episode.Title) ? Translation.Episode + " " + episode.Number.ToString() : episode.Title); // add image for download var images = new TraktImage { EpisodeImages = episode.Images, ShowImages = Show.Images }; episodeImages.Add(images); var item = new GUIEpisodeListItem(itemLabel, (int)TraktGUIWindows.SeasonEpisodes); item.Label2 = episode.FirstAired == 0 ? " " : episode.FirstAired.FromEpoch().ToShortDateString(); item.TVTag = new TraktEpisodeSummary { Episode = episode, Show = Show }; item.IsPlayed = episode.Watched; item.Images = images; item.ItemId = Int32.MaxValue - itemCount; item.IconImage = "defaultTraktEpisode.png"; item.IconImageBig = "defaultTraktEpisodeBig.png"; item.ThumbnailImage = "defaultTraktEpisodeBig.png"; item.OnItemSelected += OnEpisodeSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemCount++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= itemCount) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", itemCount.ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", itemCount.ToString(), itemCount > 1 ? Translation.Episodes : Translation.Episode)); // Download episode images Async and set to facade GUIEpisodeListItem.GetImages(episodeImages); }