Inheritance: MediaPortal.GUI.Library.GUIListItem
Exemple #1
0
        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 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 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);

                string itemLabel = season.Number == 0 ? Translation.Specials : string.Format("{0} {1}", Translation.Season, season.Number.ToString());
                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.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);
        }