TraktPlugin.GUI.GUIWatchListEpisodes.SendWatchListEpisodesToFacade C# (CSharp) Méthode

SendWatchListEpisodesToFacade() private méthode

private SendWatchListEpisodesToFacade ( IEnumerable episodeWatchlist ) : void
episodeWatchlist IEnumerable
Résultat void
        private void SendWatchListEpisodesToFacade(IEnumerable<TraktEpisodeWatchList> episodeWatchlist)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

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

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

            // Add each show and underlying episodes
            // Should we do facade levels (Series,Season,Episodes)?
            foreach (var watchlistItem in episodeWatchlist)
            {
                // add image for download
                var images = new GUITmdbImage
                {
                    EpisodeImages = new TmdbEpisodeImages
                    {
                        Id = watchlistItem.Show.Ids.Tmdb,
                        Season = watchlistItem.Episode.Season,
                        Episode = watchlistItem.Episode.Number,
                        AirDate = watchlistItem.Episode.FirstAired == null ? null : watchlistItem.Episode.FirstAired.FromISO8601().ToLocalTime().ToShortDateString()
                    }
                };
                showImages.Add(images);

                var item = new GUIEpisodeListItem(watchlistItem.ToString(), (int)TraktGUIWindows.WatchedListEpisodes);

                item.Label2 = watchlistItem.Episode.FirstAired == null ? " " : watchlistItem.Episode.FirstAired.FromISO8601().ToLocalTime().ToShortDateString();
                item.TVTag = watchlistItem;
                item.Episode = watchlistItem.Episode;
                item.Show = watchlistItem.Show;
                item.Date = watchlistItem.ListedAt.FromISO8601().ToShortDateString();
                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(showImages);
        }