private void SendWatchListEpisodesToFacade(IEnumerable<TraktWatchListEpisode> shows) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (shows.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoEpisodeWatchList, CurrentUser)); CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } int itemCount = 0; List<TraktImage> showImages = new List<TraktImage>(); // Add each show and underlying episodes // Should we do facade levels (Series,Season,Episodes)? foreach (var show in shows) { foreach (var episode in show.Episodes) { string itemLabel = string.Format("{0} - {1}x{2}{3}", show.Title, episode.Season.ToString(), episode.Number.ToString(), string.IsNullOrEmpty(episode.Title) ? string.Empty : " - " + episode.Title); GUITraktWatchListEpisodeListItem item = new GUITraktWatchListEpisodeListItem(itemLabel); // add image for download TraktImage images = new TraktImage { EpisodeImages = episode.Images, ShowImages = show.Images }; showImages.Add(images); item.Label2 = episode.FirstAired.FromEpoch().ToShortDateString(); item.TVTag = new KeyValuePair<TraktShow, TraktWatchListEpisode.Episode>(show, episode); item.Item = 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 GetImages(showImages); }
private void SendWatchListEpisodesToFacade(IEnumerable <TraktWatchListEpisode> shows) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (shows.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoEpisodeWatchList, CurrentUser)); CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } int itemCount = 0; List <TraktImage> showImages = new List <TraktImage>(); // Add each show and underlying episodes // Should we do facade levels (Series,Season,Episodes)? foreach (var show in shows) { foreach (var episode in show.Episodes) { string itemLabel = string.Format("{0} - {1}x{2}{3}", show.Title, episode.Season.ToString(), episode.Number.ToString(), string.IsNullOrEmpty(episode.Title) ? string.Empty : " - " + episode.Title); GUITraktWatchListEpisodeListItem item = new GUITraktWatchListEpisodeListItem(itemLabel); // add image for download TraktImage images = new TraktImage { EpisodeImages = episode.Images, ShowImages = show.Images }; showImages.Add(images); item.Label2 = episode.FirstAired.FromEpoch().ToShortDateString(); item.TVTag = new KeyValuePair <TraktShow, TraktWatchListEpisode.Episode>(show, episode); item.Item = 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 GetImages(showImages); }