TraktPlugin.GUI.GUIPersonSummary.SendShowCreditsToFacade C# (CSharp) Méthode

SendShowCreditsToFacade() private méthode

private SendShowCreditsToFacade ( TraktPersonShowCredits credits ) : void
credits TraktPlugin.TraktAPI.DataStructures.TraktPersonShowCredits
Résultat void
        private void SendShowCreditsToFacade(TraktPersonShowCredits credits)
        {
            if (credits == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                CurrentView = View.Summary;
                LoadPersonSummary();
                return;
            }

            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            // set the current view
            CurrentView = View.ShowCredits;

            var personImages = new List<GUITmdbImage>();

            int itemId = 0;
            GUIPersonListItem item = null;

            #region Cast
            // Add all the Cast and Crew items
            if (credits.Cast != null && credits.Cast.Count > 0)
            {
                // add image for download
                var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = CurrentPerson.Ids.TmdbId } };
                personImages.Add(images);

                item = new GUIPersonListItem(Translation.Actor, (int)TraktGUIWindows.PersonSummary);
                item.Label2 = string.Format(Translation.ShowCount, credits.Cast.Count);
                item.TVTag = Credit.Cast;
                item.Images = images;
                item.MusicTag = credits;
                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++;
            }
            #endregion

            #region Crew
            if (credits.Crew != null)
            {
                #region Production
                if (credits.Crew.Production != null && credits.Crew.Production.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = CurrentPerson.Ids.TmdbId } };
                    personImages.Add(images);

                    item = new GUIPersonListItem(Translation.Production, (int)TraktGUIWindows.PersonSummary);
                    item.Label2 = string.Format(Translation.ShowCount, credits.Crew.Production.Count);
                    item.TVTag = Credit.Production;
                    item.MusicTag = credits;
                    item.Images = images;
                    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++;
                }
                #endregion

                #region Directing
                if (credits.Crew.Directing != null && credits.Crew.Directing.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = CurrentPerson.Ids.TmdbId } };
                    personImages.Add(images);

                    item = new GUIPersonListItem(Translation.Directing, (int)TraktGUIWindows.PersonSummary);
                    item.Label2 = string.Format(Translation.ShowCount, credits.Crew.Directing.Count);
                    item.TVTag = Credit.Directing;
                    item.MusicTag = credits;
                    item.Images = images;
                    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++;
                }
                #endregion

                #region Writing
                if (credits.Crew.Writing != null && credits.Crew.Writing.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = CurrentPerson.Ids.TmdbId } };
                    personImages.Add(images);

                    item = new GUIPersonListItem(Translation.Writing, (int)TraktGUIWindows.PersonSummary);
                    item.Label2 = string.Format(Translation.ShowCount, credits.Crew.Writing.Count);
                    item.TVTag = Credit.Writing;
                    item.MusicTag = credits;
                    item.Images = images;
                    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++;
                }
                #endregion

                #region Art
                if (credits.Crew.Art != null && credits.Crew.Art.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = CurrentPerson.Ids.TmdbId } };
                    personImages.Add(images);

                    item = new GUIPersonListItem(Translation.Art, (int)TraktGUIWindows.PersonSummary);
                    item.Label2 = string.Format(Translation.ShowCount, credits.Crew.Art.Count);
                    item.TVTag = Credit.Art;
                    item.MusicTag = credits;
                    item.Images = images;
                    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++;
                }
                #endregion

                #region Camera
                if (credits.Crew.Camera != null && credits.Crew.Camera.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = CurrentPerson.Ids.TmdbId } };
                    personImages.Add(images);

                    item = new GUIPersonListItem(Translation.Camera, (int)TraktGUIWindows.PersonSummary);
                    item.Label2 = string.Format(Translation.ShowCount, credits.Crew.Camera.Count);
                    item.TVTag = Credit.Camera;
                    item.MusicTag = credits;
                    item.Images = images;
                    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++;
                }
                #endregion

                #region Costume and Makeup
                if (credits.Crew.CostumeAndMakeUp != null && credits.Crew.CostumeAndMakeUp.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = CurrentPerson.Ids.TmdbId } };
                    personImages.Add(images);

                    item = new GUIPersonListItem(Translation.CostumeAndMakeUp, (int)TraktGUIWindows.PersonSummary);
                    item.Label2 = string.Format(Translation.ShowCount, credits.Crew.CostumeAndMakeUp.Count);
                    item.TVTag = Credit.CostumeAndMakeUp;
                    item.MusicTag = credits;
                    item.Images = images;
                    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++;
                }
                #endregion

                #region Sound
                if (credits.Crew.Sound != null && credits.Crew.Sound.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = CurrentPerson.Ids.TmdbId } };
                    personImages.Add(images);

                    item = new GUIPersonListItem(Translation.Sound, (int)TraktGUIWindows.PersonSummary);
                    item.Label2 = string.Format(Translation.MovieCount, credits.Crew.Sound.Count);
                    item.TVTag = Credit.Sound;
                    item.MusicTag = credits;
                    item.Images = images;
                    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++;
                }
                #endregion
            }
            #endregion

            if (Facade.Count == 0)
            {
                GUIUtils.ShowNotifyDialog(Translation.ShowCredits, Translation.NoCreditsFound);
                CurrentView = View.Summary;
                LoadPersonSummary();
                return;
            }

            // Set Facade Layout
            Facade.SetCurrentLayout("List");
            GUIControl.FocusControl(GetID, Facade.GetID);

            // set facade properties
            GUIUtils.SetProperty("#itemcount", Facade.Count.ToString());

            GUIPersonListItem.GetImages(personImages, false);
        }