Inheritance: MediaPortal.GUI.Library.GUIListItem
Example #1
0
        private void SendCastToFacade(List <TraktPersonShowCast> cast)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (cast == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            // filter Shows
            var filteredCast = FilterCastShows(cast).Where(m => !string.IsNullOrEmpty(m.Show.Title)).ToList();

            // sort Shows
            filteredCast.Sort(new GUIListItemShowSorter(TraktSettings.SortByCreditShows.Field, TraktSettings.SortByCreditShows.Direction));

            int             itemId     = 0;
            GUIShowListItem item       = null;
            var             ShowImages = new List <GUITmdbImage>();

            foreach (var credit in filteredCast)
            {
                // add image for download
                var images = new GUITmdbImage {
                    ShowImages = new TmdbShowImages {
                        Id = credit.Show.Ids.Tmdb
                    }
                };
                ShowImages.Add(images);

                item                 = new GUIShowListItem(credit.Show.Title, (int)TraktGUIWindows.PersonCreditShows);
                item.Label2          = credit.Show.Year == null ? "----" : credit.Show.Year.ToString();
                item.Show            = credit.Show;
                item.TVTag           = credit;
                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++;
            }

            // 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}", filteredCast.Count, filteredCast.Count > 1 ? Translation.Shows : Translation.Show));

            // Download Show images Async and set to facade
            GUIShowListItem.GetImages(ShowImages);
        }
Example #2
0
        private void SendSearchResultsToFacade(IEnumerable <TraktShow> shows)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (shows == null || shows.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound);
                GUIWindowManager.ShowPreviousWindow();
                Shows = null;
                return;
            }

            int itemId     = 0;
            var showImages = new List <TraktImage>();

            // Add each show
            foreach (var show in shows)
            {
                // add image for download
                var images = new TraktImage {
                    ShowImages = show.Images
                };
                showImages.Add(images);

                GUIShowListItem item = new GUIShowListItem(show.Title, (int)TraktGUIWindows.SearchShows);

                item.Label2          = show.Year.ToString();
                item.TVTag           = show;
                item.Images          = images;
                item.IsPlayed        = show.Watched;
                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 (SearchTermChanged)
            {
                PreviousSelectedIndex = 0;
            }
            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.TVShows : Translation.TVShow));

            // Download images Async and set to facade
            GUIShowListItem.GetImages(showImages);
        }
Example #3
0
        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 SendAnticipatedShowsToFacade(TraktShowsAnticipated anticipatedItems)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (anticipatedItems == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                AnticipatedShowPages = null;
                return;
            }

            // filter shows
            var filteredAnticipatedList = FilterAnticipatedShows(anticipatedItems.Shows).Where(s => !string.IsNullOrEmpty(s.Show.Title)).ToList();

            // sort shows
            filteredAnticipatedList.Sort(new GUIListItemShowSorter(TraktSettings.SortByAnticipatedShows.Field, TraktSettings.SortByAnticipatedShows.Direction));

            int itemId = 0;
            var showImages = new List<GUITmdbImage>();

            // Add Previous Page Button
            if (anticipatedItems.CurrentPage != 1)
            {
                var prevPageItem = new GUIShowListItem(Translation.PreviousPage, (int)TraktGUIWindows.AnticipatedShows);
                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 anticipatedItem in filteredAnticipatedList)
            {
                var item = new GUIShowListItem(anticipatedItem.Show.Title, (int)TraktGUIWindows.AnticipatedShows);

                // add image for download
                var image = new GUITmdbImage { ShowImages = new TmdbShowImages { Id = anticipatedItem.Show.Ids.Tmdb } };
                showImages.Add(image);

                item.Label2 = anticipatedItem.Show.Year.ToString();
                item.TVTag = anticipatedItem;
                item.Show = anticipatedItem.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 (anticipatedItems.CurrentPage != anticipatedItems.TotalPages)
            {
                var nextPageItem = new GUIShowListItem(Translation.NextPage, (int)TraktGUIWindows.AnticipatedShows);
                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", filteredAnticipatedList.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", filteredAnticipatedList.Count(), filteredAnticipatedList.Count() > 1 ? Translation.SeriesPlural : Translation.Series));

            // Page Properties
            GUIUtils.SetProperty("#Trakt.Facade.CurrentPage", anticipatedItems.CurrentPage.ToString());
            GUIUtils.SetProperty("#Trakt.Facade.TotalPages", anticipatedItems.TotalPages.ToString());
            GUIUtils.SetProperty("#Trakt.Facade.TotalItemsPerPage", TraktSettings.MaxAnticipatedShowsRequest.ToString());

            // Download show images Async and set to facade
            GUIShowListItem.GetImages(showImages);
        }
        private void SendWatchListShowsToFacade(IEnumerable<TraktShowWatchList> showWatchlist)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (showWatchlist == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (showWatchlist.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoShowWatchList, CurrentUser));
                CurrentUser = TraktSettings.Username;
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            // sort shows
            var sortedList = showWatchlist.ToList();
            sortedList.Sort(new GUIListItemShowSorter(TraktSettings.SortByWatchListShows.Field, TraktSettings.SortByWatchListShows.Direction));

            int itemId = 0;
            var showImages = new List<GUITmdbImage>();

            // Add each show
            foreach (var listItem in sortedList)
            {
                // add image for download
                var images = new GUITmdbImage { ShowImages = new TmdbShowImages { Id = listItem.Show.Ids.Tmdb } };
                showImages.Add(images);

                GUIShowListItem item = new GUIShowListItem(listItem.Show.Title, (int)TraktGUIWindows.WatchedListShows);

                item.Label2 = listItem.Show.Year.ToString();
                item.TVTag = listItem;
                item.Show = listItem.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 >= sortedList.Count())
                Facade.SelectIndex(PreviousSelectedIndex - 1);
            else
                Facade.SelectIndex(PreviousSelectedIndex);

            // set facade properties
            GUIUtils.SetProperty("#itemcount", sortedList.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", sortedList.Count().ToString(), sortedList.Count() > 1 ? Translation.SeriesPlural : Translation.Series));

            // Download show images Async and set to facade
            GUIShowListItem.GetImages(showImages);
        }
Example #6
0
        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 SendPopularShowsToFacade(TraktShowsPopular PopularItems)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (PopularItems == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                PopularShowPages = null;
                return;
            }

            // filter shows
            var filteredPopularList = FilterPopularShows(PopularItems.Shows).Where(s => !string.IsNullOrEmpty(s.Title)).ToList();

            // sort shows
            filteredPopularList.Sort(new GUIListItemShowSorter(TraktSettings.SortByPopularShows.Field, TraktSettings.SortByPopularShows.Direction));

            int itemId     = 0;
            var showImages = new List <GUITmdbImage>();

            // Add Previous Page Button
            if (PopularItems.CurrentPage != 1)
            {
                var prevPageItem = new GUIShowListItem(Translation.PreviousPage, (int)TraktGUIWindows.PopularShows);
                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 popularItem in filteredPopularList)
            {
                var item = new GUIShowListItem(popularItem.Title, (int)TraktGUIWindows.PopularShows);

                // add image for download
                var image = new GUITmdbImage {
                    ShowImages = new TmdbShowImages {
                        Id = popularItem.Ids.Tmdb
                    }
                };
                showImages.Add(image);

                item.Label2          = popularItem.Year.ToString();
                item.TVTag           = popularItem;
                item.Show            = popularItem;
                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 (PopularItems.CurrentPage != PopularItems.TotalPages)
            {
                var nextPageItem = new GUIShowListItem(Translation.NextPage, (int)TraktGUIWindows.PopularShows);
                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.SeriesPlural : Translation.Series));

            // Page Properties
            GUIUtils.SetProperty("#Trakt.Facade.CurrentPage", PopularItems.CurrentPage.ToString());
            GUIUtils.SetProperty("#Trakt.Facade.TotalPages", PopularItems.TotalPages.ToString());
            GUIUtils.SetProperty("#Trakt.Facade.TotalItemsPerPage", TraktSettings.MaxPopularShowsRequest.ToString());

            // Download show images Async and set to facade
            GUIShowListItem.GetImages(showImages);
        }
        private void SendRelatedShowsToFacade(IEnumerable<TraktShowSummary> shows)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (shows == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (shows.Count() == 0)
            {
                string title = string.IsNullOrEmpty(relatedShow.Title) ? relatedShow.Slug : relatedShow.Title;
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoRelatedShows, title));
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (HideWatched)
            {
                // not interested if we have watched any underlying episodes
                shows = shows.Where(s => s.Plays() == 0);
            }

            int itemId = 0;
            var showImages = new List<GUITmdbImage>();

            foreach (var show in shows)
            {
                var item = new GUIShowListItem(show.Title, (int)TraktGUIWindows.RelatedShows);

                // add image for download
                var images = new GUITmdbImage { ShowImages = new TmdbShowImages { Id = show.Ids.Tmdb } };
                showImages.Add(images);

                item.Label2 = show.Year.ToString();
                item.TVTag = show;
                item.Show = show;
                item.Show = 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 SendRecommendedShowsToFacade(IEnumerable <TraktShowSummary> shows)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (shows == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (shows.Count() == 0)
            {
                // try again
                if (genreButton == null)
                {
                    // restore defaults for next time so we can get recommendations
                    if (CurrentGenre != "All")
                    {
                        CurrentGenre = "All";
                    }

                    _RecommendedShows = null;
                    GUIWindowManager.ShowPreviousWindow();
                }
                else
                {
                    GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoShowRecommendations);
                    GUIControl.FocusControl(GetID, genreButton.GetID);
                }
                return;
            }

            // sort shows
            var showList = shows.ToList();

            showList.Sort(new GUIListItemShowSorter(TraktSettings.SortByRecommendedShows.Field, TraktSettings.SortByRecommendedShows.Direction));

            int itemId     = 0;
            var showImages = new List <GUITmdbImage>();

            foreach (var show in showList)
            {
                var item = new GUIShowListItem(show.Title, (int)TraktGUIWindows.RecommendationsShows);

                // add image for download
                var images = new GUITmdbImage {
                    ShowImages = new TmdbShowImages {
                        Id = show.Ids.Tmdb
                    }
                };
                showImages.Add(images);

                item.Label2          = show.Year.ToString();
                item.TVTag           = show;
                item.Show            = 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 SendRecommendedShowsToFacade(IEnumerable<TraktShowSummary> shows)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (shows == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (shows.Count() == 0)
            {
                // try again
                if (genreButton == null)
                {
                    // restore defaults for next time so we can get recommendations
                    if (CurrentGenre != "All")
                        CurrentGenre = "All";

                    _RecommendedShows = null;
                    GUIWindowManager.ShowPreviousWindow();
                }
                else
                {
                    GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoShowRecommendations);
                    GUIControl.FocusControl(GetID, genreButton.GetID);
                }
                return;
            }

            // sort shows
            var showList = shows.ToList();
            showList.Sort(new GUIListItemShowSorter(TraktSettings.SortByRecommendedShows.Field, TraktSettings.SortByRecommendedShows.Direction));

            int itemId = 0;
            var showImages = new List<GUITmdbImage>();

            foreach (var show in showList)
            {
                var item = new GUIShowListItem(show.Title, (int)TraktGUIWindows.RecommendationsShows);

                // add image for download
                var images = new GUITmdbImage { ShowImages = new TmdbShowImages { Id = show.Ids.Tmdb } };
                showImages.Add(images);

                item.Label2 = show.Year.ToString();
                item.TVTag = show;
                item.Show = 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 SendSearchResultsToFacade(IEnumerable<TraktShowSummary> shows)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (shows == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                Shows = null;
                return;
            }

            if (shows.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound);
                GUIWindowManager.ShowPreviousWindow();
                Shows = null;
                return;
            }

            int itemId = 0;
            var showImages = new List<GUITmdbImage>();

            // Add each show
            foreach (var show in shows)
            {
                // add image for download
                var images = new GUITmdbImage { ShowImages = new TmdbShowImages { Id = show.Ids.Tmdb } };
                showImages.Add(images);

                GUIShowListItem item = new GUIShowListItem(show.Title, (int)TraktGUIWindows.SearchShows);

                item.Label2 = show.Year.ToString();
                item.TVTag = show;
                item.Show = show;
                item.Images = images;
                item.IsPlayed = show.IsWatched();
                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 (SearchTermChanged) PreviousSelectedIndex = 0;
            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.TVShows : Translation.TVShow));

            // Download images Async and set to facade
            GUIShowListItem.GetImages(showImages);
        }
        private void LoadTrendingShowsFacade(IEnumerable<TraktShowTrending> trendingItems, GUIFacadeControl facade)
        {
            if (TraktSkinSettings.DashboardTrendingCollection == null || !TraktSkinSettings.DashboardTrendingCollection.Exists(d => d.TVShowWindows.Contains(GUIWindowManager.ActiveWindow.ToString())))
                return;

            // get trending settings
            var trendingSettings = GetTrendingSettings();
            if (trendingSettings == null) return;

            TraktLogger.Debug("Loading Trakt Trending Shows facade");

            // if no trending, then nothing to do
            if (trendingItems == null || trendingItems.Count() == 0)
                return;

            // stop any existing image downloads
            GUIShowListItem.StopDownload = true;

            // clear facade
            GUIControl.ClearControl(GUIWindowManager.ActiveWindow, facade.GetID);

            int itemId = 0;
            var showImages = new List<GUITmdbImage>();

            // filter shows
            if (TraktSettings.FilterTrendingOnDashboard)
                trendingItems = GUICommon.FilterTrendingShows(trendingItems);

            // Add each activity item to the facade
            foreach (var trendingItem in trendingItems.Take(trendingSettings.FacadeMaxItems))
            {
                if (trendingItem.Show == null)
                    continue;

                // add image for download
                var images = new GUITmdbImage { ShowImages = new TmdbShowImages { Id = trendingItem.Show.Ids.Tmdb } };
                showImages.Add(images);

                var item = new GUIShowListItem(trendingItem.Show.Title, GUIWindowManager.ActiveWindow);

                item.Label2 = trendingItem.Show.Year.ToString();
                item.TVTag = trendingItem;
                item.Show = trendingItem.Show;
                item.Images = images;
                item.ItemId = Int32.MaxValue - itemId;
                item.IconImage = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnTrendingShowSelected;
                try
                {
                    facade.Add(item);
                }
                catch { }
                itemId++;
            }

            // Set Facade Layout
            facade.SetCurrentLayout(trendingSettings.FacadeType);
            facade.SetVisibleFromSkinCondition();

            // set facade properties
            GUIUtils.SetProperty("#Trakt.Trending.Shows.Items", string.Format("{0} {1}", trendingItems.Count().ToString(), trendingItems.Count() > 1 ? Translation.SeriesPlural : Translation.Series));
            GUIUtils.SetProperty("#Trakt.Trending.Shows.PeopleCount", trendingItems.Sum(t => t.Watchers).ToString());
            GUIUtils.SetProperty("#Trakt.Trending.Shows.Description", string.Format(Translation.TrendingTVShowsPeople, trendingItems.Sum(t => t.Watchers).ToString(), trendingItems.Count().ToString()));

            // Download images Async and set to facade
            GUIShowListItem.StopDownload = false;
            GUIShowListItem.GetImages(showImages);

            TraktLogger.Debug("Finished Loading Trending Shows facade");
        }
        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.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}", filteredCrew.Count, filteredCrew.Count > 1 ? Translation.Shows : Translation.Show));

            // Download Show images Async and set to facade
            GUIShowListItem.GetImages(ShowImages);
        }
        private void SendRelatedShowsToFacade(IEnumerable <TraktShowSummary> shows)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (shows == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (shows.Count() == 0)
            {
                string title = string.IsNullOrEmpty(relatedShow.Title) ? relatedShow.Slug : relatedShow.Title;
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoRelatedShows, title));
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (HideWatched)
            {
                // not interested if we have watched any underlying episodes
                shows = shows.Where(s => s.Plays() == 0);
            }

            int itemId     = 0;
            var showImages = new List <GUITmdbImage>();

            foreach (var show in shows)
            {
                var item = new GUIShowListItem(show.Title, (int)TraktGUIWindows.RelatedShows);

                // add image for download
                var images = new GUITmdbImage {
                    ShowImages = new TmdbShowImages {
                        Id = show.Ids.Tmdb
                    }
                };
                showImages.Add(images);

                item.Label2          = show.Year.ToString();
                item.TVTag           = show;
                item.Show            = show;
                item.Show            = 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.CurrentLayout = 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);
        }