Esempio n. 1
0
        private void SendSearchResultsToFacade(IEnumerable <TraktEpisodeSummary> episodes)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

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

            // Add each show
            foreach (var episodeSummary in episodes)
            {
                // add images for download
                var images = new TraktImage
                {
                    EpisodeImages = episodeSummary.Episode.Images,
                    ShowImages    = episodeSummary.Show.Images
                };
                showImages.Add(images);

                var item = new GUIEpisodeListItem(episodeSummary.ToString(), (int)TraktGUIWindows.SearchEpisodes);

                item.Label2          = episodeSummary.Show.Year.ToString();
                item.TVTag           = episodeSummary;
                item.Images          = images;
                item.IsPlayed        = episodeSummary.Episode.Watched;
                item.ItemId          = Int32.MaxValue - itemId;
                item.IconImage       = "defaultTraktEpisode.png";
                item.IconImageBig    = "defaultTraktEpisodeBig.png";
                item.ThumbnailImage  = "defaultTraktEpisodeBig.png";
                item.OnItemSelected += OnEpisodeSelected;
                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", episodes.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", episodes.Count().ToString(), episodes.Count() > 1 ? Translation.Episodes : Translation.Episode));

            // Download images Async and set to facade
            GUIEpisodeListItem.GetImages(showImages);
        }
        private void SendSearchResultsToFacade(IEnumerable <TraktMovie> movies)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

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

            // Add each movie
            foreach (var movie in movies)
            {
                // add image for download
                var images = new TraktImage {
                    MovieImages = movie.Images
                };
                movieImages.Add(images);

                GUIMovieListItem item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.SearchMovies);

                item.Label2          = movie.Year == "0" ? "----" : movie.Year;
                item.TVTag           = movie;
                item.Images          = images;
                item.IsPlayed        = movie.Watched;
                item.ItemId          = Int32.MaxValue - itemId;
                item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnMovieSelected;
                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", movies.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movies.Count().ToString(), movies.Count() > 1 ? Translation.Movies : Translation.Movie));

            // Download movie images Async and set to facade
            GUIMovieListItem.GetImages(movieImages);
        }
        private void SendRelatedMoviesToFacade(IEnumerable <TraktMovie> movies)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (movies.Count() == 0)
            {
                string title = string.IsNullOrEmpty(relatedMovie.Title) ? relatedMovie.IMDbId : relatedMovie.Title;
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoRelatedMovies, title));
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

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

            // Add each movie
            foreach (var movie in movies.Where(m => !string.IsNullOrEmpty(m.Title)))
            {
                var item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.RelatedMovies);

                // add image for download
                var image = new TraktImage {
                    MovieImages = movie.Images
                };
                movieImages.Add(image);

                item.Label2   = movie.Year;
                item.TVTag    = movie;
                item.Images   = image;
                item.IsPlayed = movie.Watched;
                item.ItemId   = Int32.MaxValue - itemId;
                // movie in collection doesnt nessararily mean
                // that the movie is locally available on this computer
                // as 'keep library clean' might not be enabled
                //item.IsRemote = !movie.InCollection;
                item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnMovieSelected;
                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", movies.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movies.Count().ToString(), movies.Count() > 1 ? Translation.Movies : Translation.Movie));

            // Download movie images Async and set to facade
            GUIMovieListItem.GetImages(movieImages);
        }
Esempio n. 4
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 SendSearchResultsToFacade(IEnumerable <TraktPersonSummary> people)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

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

            // Add each movie
            foreach (var person in people)
            {
                // add image for download
                var images = new TraktImage {
                    PoepleImages = person.Images
                };
                personImages.Add(images);

                var item = new GUIPersonListItem(person.Name.Trim(), (int)TraktGUIWindows.SearchPeople);

                item.TVTag           = person;
                item.Images          = images;
                item.ItemId          = Int32.MaxValue - itemId;
                item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnPersonSelected;
                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", people.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", people.Count().ToString(), people.Count() > 1 ? Translation.People : Translation.Person));

            // Download images Async and set to facade
            GUIPersonListItem.GetImages(personImages);
        }
Esempio n. 6
0
        private void SendSearchResultsToFacade(IEnumerable <TraktUser> users)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

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

            // Add each user
            foreach (var user in users)
            {
                // add image to download
                var images = new TraktImage {
                    Avatar = user.Avatar
                };
                userImages.Add(images);

                var item = new GUIUserListItem(user.Username, (int)TraktGUIWindows.SearchUsers);

                item.Images          = images;
                item.TVTag           = user;
                item.ItemId          = Int32.MaxValue - itemId;
                item.IconImage       = "defaultTraktUser.png";
                item.IconImageBig    = "defaultTraktUserBig.png";
                item.ThumbnailImage  = "defaultTraktUserBig.png";
                item.OnItemSelected += OnUserSelected;
                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", users.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", users.Count().ToString(), users.Count() > 1 ? Translation.Users : Translation.User));

            // Download images Async and set to facade
            GUIUserListItem.GetImages(userImages);
        }
Esempio n. 7
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 TraktImage GetTraktImage(TraktUserListItem listItem)
        {
            TraktImage images = new TraktImage();

            switch (listItem.Type)
            {
            case "movie":
                images.MovieImages = listItem.Movie.Images;
                break;

            case "show":
            case "season":
            case "episode":
                images.ShowImages = listItem.Show.Images;
                break;
            }
            return(images);
        }
        private void SendSeasonEpisodesToFacade(IEnumerable <TraktEpisode> episodes)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

            // Set Common Show Properties
            GUICommon.SetShowProperties(Show);

            int itemCount     = 0;
            var episodeImages = new List <TraktImage>();

            foreach (var episode in episodes)
            {
                // use episode short string
                string itemLabel = string.Format("{0}. {1}", episode.Number.ToString(), string.IsNullOrEmpty(episode.Title) ? Translation.Episode + " " + episode.Number.ToString() : episode.Title);

                // add image for download
                var images = new TraktImage
                {
                    EpisodeImages = episode.Images,
                    ShowImages    = Show.Images
                };

                episodeImages.Add(images);

                var item = new GUIEpisodeListItem(itemLabel, (int)TraktGUIWindows.SeasonEpisodes);

                item.Label2 = episode.FirstAired == 0 ? " " : episode.FirstAired.FromEpoch().ToShortDateString();
                item.TVTag  = new TraktEpisodeSummary {
                    Episode = episode, Show = Show
                };
                item.IsPlayed        = episode.Watched;
                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(episodeImages);
        }
Esempio n. 10
0
        private void SendCalendarToFacade(IEnumerable <TraktCalendar> calendar)
        {
            // check if we got a bad response
            if (calendar.Count() < PreviousCalendarDayCount)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.ErrorCalendar);
                // set defaults
                _CalendarMyShows   = null;
                _CalendarPremieres = null;
                _CalendarAllShows  = null;
                LastRequest        = new DateTime();
                return;
            }

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

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

            // Add each days episodes to the list
            // Use Label3 of facade for Day/Group Idenitfier
            foreach (var day in calendar)
            {
                // apply watch list filter
                var episodes = day.Episodes;
                if (CurrentCalendar == CalendarType.MyShows)
                {
                    if (TraktSettings.CalendarHideTVShowsInWatchList)
                    {
                        episodes = day.Episodes.Where(e => !e.Show.InWatchList).ToList();
                    }
                }

                if (episodes.Count > 0)
                {
                    // add day header
                    GUIListItem item = new GUIListItem();
                    item.Label3          = GetDayHeader(DateTime.Parse(day.Date));
                    item.IconImage       = "defaultTraktCalendar.png";
                    item.IconImageBig    = "defaultTraktCalendarBig.png";
                    item.ThumbnailImage  = "defaultTraktCalendarBig.png";
                    item.OnItemSelected += OnCalendarDateSelected;
                    Utils.SetDefaultIcons(item);
                    Facade.Add(item);

                    foreach (var episode in episodes)
                    {
                        GUIEpisodeListItem episodeItem = new GUIEpisodeListItem(episode.ToString(), (int)TraktGUIWindows.Calendar);

                        // add image for download
                        TraktImage images = new TraktImage
                        {
                            EpisodeImages = episode.Episode.Images,
                            ShowImages    = episode.Show.Images
                        };
                        showImages.Add(images);

                        // extended skin properties
                        episodeItem.Date          = DateTime.Parse(day.Date).ToLongDateString();
                        episodeItem.SelectedIndex = (itemCount + 1).ToString();

                        episodeItem.Images          = images;
                        episodeItem.TVTag           = episode;
                        episodeItem.ItemId          = Int32.MaxValue - itemCount;
                        episodeItem.IsPlayed        = episode.Episode.Watched;
                        episodeItem.IconImage       = "defaultTraktEpisode.png";
                        episodeItem.IconImageBig    = "defaultTraktEpisodeBig.png";
                        episodeItem.ThumbnailImage  = "defaultTraktEpisodeBig.png";
                        episodeItem.OnItemSelected += OnEpisodeSelected;
                        Utils.SetDefaultIcons(episodeItem);
                        Facade.Add(episodeItem);
                        itemCount++;
                    }
                }
            }

            // if nothing airing this week, then indicate to user
            if (!IsCached && (calendar.Count() == PreviousCalendarDayCount))
            {
                GUIListItem item = new GUIListItem();

                item.Label3          = Translation.NoEpisodesThisWeek;
                item.IconImage       = "defaultTraktCalendar.png";
                item.IconImageBig    = "defaultTraktCalendarBig.png";
                item.ThumbnailImage  = "defaultTraktCalendarBig.png";
                item.OnItemSelected += OnCalendarDateSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);

                // Stay on Next Week Item
                if (PreviousSelectedIndex > 0)
                {
                    PreviousSelectedIndex--;
                }
            }

            // Add Next Week Item so user can fetch next weeks calendar
            GUIListItem nextItem = new GUIListItem(Translation.NextWeek);

            nextItem.IconImage       = "traktNextWeek.png";
            nextItem.IconImageBig    = "traktNextWeek.png";
            nextItem.ThumbnailImage  = "traktNextWeek.png";
            nextItem.OnItemSelected += OnNextWeekSelected;
            nextItem.IsFolder        = true;
            Facade.Add(nextItem);

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

            // Set the first episode on calendar on initial request (Index 0 is a day header),
            // Set last position if paging to next week
            if (!IsCached)
            {
                Facade.SelectIndex(PreviousSelectedIndex + 1);
            }
            else // If cached just set to last position
            {
                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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        private void SendFriendsToFacade(IEnumerable <TraktNetworkUser> friends)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);
            ClearProperties();

            int friendCount = friends.Count();

            GUIUtils.SetProperty("#itemcount", friendCount.ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", friendCount.ToString(), friendCount > 1 ? Translation.Friends : Translation.Friend));

            if (friendCount == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoFriendsTaunt);
                if (viewButton != null)
                {
                    // let user select another view since there is nothing to show here
                    GUIControl.FocusControl(GetID, viewButton.GetID);
                }
                else
                {
                    GUIWindowManager.ShowPreviousWindow();
                }
                return;
            }

            int id = 0;

            var userImages = new List <TraktImage>();

            // Add each friend to the list
            foreach (var friend in friends.OrderBy(f => f.ApprovedDate))
            {
                // add image to download
                var images = new TraktImage {
                    Avatar = friend.Avatar
                };
                userImages.Add(images);

                var userItem = new GUIUserListItem(friend.Username, (int)TraktGUIWindows.Network);

                userItem.Label2          = friend.ApprovedDate.FromEpoch().ToShortDateString();
                userItem.Images          = images;
                userItem.TVTag           = friend;
                userItem.ItemId          = id++;
                userItem.IsFriend        = true;
                userItem.IconImage       = "defaultTraktUser.png";
                userItem.IconImageBig    = "defaultTraktUserBig.png";
                userItem.ThumbnailImage  = "defaultTraktUserBig.png";
                userItem.OnItemSelected += OnUserSelected;
                Utils.SetDefaultIcons(userItem);
                Facade.Add(userItem);
            }

            // restore previous selection
            if (Facade.Count <= PreviousUserSelectedIndex)
            {
                Facade.SelectedListItemIndex = 0;
            }
            else
            {
                Facade.SelectedListItemIndex = PreviousUserSelectedIndex;
            }

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

            // Download avatars Async and set to facade
            GUIUserListItem.GetImages(userImages);
        }
        /// <summary>
        /// Gets the local filename of an image from a Trakt URL
        /// </summary>
        /// <param name="url">The online URL of the trakt image</param>
        /// <param name="type">The Type of image to get</param>
        /// <returns>Retruns the local filename of the image</returns>
        public static string LocalImageFilename(this TraktImage image, ArtworkType type)
        {
            if (image == null)
            {
                return(string.Empty);
            }

            string filename = string.Empty;
            string folder   = string.Empty;

            switch (type)
            {
            case ArtworkType.Avatar:
                filename = image.FullSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\Avatars");
                break;

            case ArtworkType.PersonHeadshot:
                filename = image.ThumbSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\People");
                break;

            case ArtworkType.PersonFanart:
                filename = TraktSettings.DownloadFullSizeFanart ? image.FullSize.ToClearUrl() : image.MediumSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\People\Fanart");
                break;

            case ArtworkType.SeasonPoster:
                filename = image.ThumbSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\Shows\Seasons");
                break;

            case ArtworkType.MoviePoster:
                filename = image.ThumbSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\Movies\Posters");
                break;

            case ArtworkType.MovieFanart:
                filename = TraktSettings.DownloadFullSizeFanart ? image.FullSize.ToClearUrl() : image.MediumSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\Movies\Fanart");
                break;

            case ArtworkType.MovieBanner:
                filename = image.FullSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\Movies\Banners");
                break;

            case ArtworkType.ShowPoster:
                filename = image.ThumbSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\Shows\Posters");
                break;

            case ArtworkType.ShowBanner:
                filename = image.FullSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\Shows\Banners");
                break;

            case ArtworkType.ShowFanart:
                filename = TraktSettings.DownloadFullSizeFanart ? image.FullSize.ToClearUrl() : image.MediumSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\Shows\Fanart");
                break;

            case ArtworkType.EpisodeImage:
                filename = image.ThumbSize.ToClearUrl();
                folder   = Config.GetSubFolder(Config.Dir.Thumbs, @"Trakt\Episodes");
                break;
            }

            if (string.IsNullOrEmpty(filename))
            {
                return(null);
            }

            return(Path.Combine(folder, Path.GetFileName(new Uri(filename).LocalPath)));
        }
Esempio n. 14
0
        private void SendShoutsToFacade(IEnumerable <TraktShout> shouts)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (shouts == null || shouts.Count() == 0)
            {
                if (shouts != null)
                {
                    string title = string.Empty;
                    switch (ShoutType)
                    {
                    case ShoutTypeEnum.movie:
                        title = MovieInfo.Title;
                        break;

                    case ShoutTypeEnum.show:
                        title = ShowInfo.Title;
                        break;

                    case ShoutTypeEnum.episode:
                        title = string.Format(EpisodeInfo.ToString());
                        break;
                    }
                    ClearProperties();
                    GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoShoutsForItem, title));
                }
                if (ExitIfNoShoutsFound)
                {
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
            }

            GUIUtils.SetProperty("#itemcount", shouts.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", shouts.Count(), shouts.Count() > 1 ? Translation.Shouts : Translation.Shout));

            int id         = 0;
            var userImages = new List <TraktImage>();

            // Add each user that shouted to the list
            foreach (var shout in shouts)
            {
                // add image to download
                var images = new TraktImage {
                    Avatar = shout.User.Avatar
                };
                userImages.Add(images);

                var shoutItem = new GUIUserListItem(shout.User.Username, (int)TraktGUIWindows.Shouts);

                shoutItem.Label2          = shout.InsertedDate.FromEpoch().ToShortDateString();
                shoutItem.Images          = images;
                shoutItem.TVTag           = shout;
                shoutItem.ItemId          = id++;
                shoutItem.IconImage       = "defaultTraktUser.png";
                shoutItem.IconImageBig    = "defaultTraktUserBig.png";
                shoutItem.ThumbnailImage  = "defaultTraktUserBig.png";
                shoutItem.OnItemSelected += OnShoutSelected;
                Utils.SetDefaultIcons(shoutItem);
                Facade.Add(shoutItem);
            }

            // Enable / Disable GUI Controls
            EnableGUIButtons();

            // Set Facade Layout
            if (Facade.Count > 0)
            {
                Facade.SetCurrentLayout("List");
                GUIControl.FocusControl(GetID, Facade.GetID);

                Facade.SelectedListItemIndex = 0;
            }
            else
            {
                GUIControl.FocusControl(GetID, nextEpisodeButton.GetID);
            }

            // Download avatars Async and set to facade
            GUIUserListItem.GetImages(userImages);
        }
        private void SendTrendingMoviesToFacade(IEnumerable <TraktTrendingMovie> movies)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            if (movies.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoTrendingMovies);
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            // filter movies
            movies = GUICommon.FilterTrendingMovies(movies);

            // sort movies
            var movieList = movies.Where(m => !string.IsNullOrEmpty(m.Title)).ToList();

            movieList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByTrendingMovies.Field, TraktSettings.SortByTrendingMovies.Direction));

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

            // Add each movie mark remote if not in collection
            foreach (var movie in movieList)
            {
                // add image for download
                var images = new TraktImage {
                    MovieImages = movie.Images
                };
                movieImages.Add(images);

                var item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.TrendingMovies);

                item.Label2   = movie.Year == "0" ? "----" : movie.Year;
                item.TVTag    = movie;
                item.Images   = images;
                item.IsPlayed = movie.Watched;
                item.ItemId   = Int32.MaxValue - itemId;
                // movie in collection doesnt nessararily mean
                // that the movie is locally available on this computer
                // as 'keep library clean' might not be enabled
                //item.IsRemote = !movie.InCollection;
                item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnMovieSelected;
                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", movies.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movies.Count().ToString(), movies.Count() > 1 ? Translation.Movies : Translation.Movie));
            GUIUtils.SetProperty("#Trakt.Trending.PeopleCount", movies.Sum(m => m.Watchers).ToString());
            GUIUtils.SetProperty("#Trakt.Trending.Description", string.Format(Translation.TrendingMoviePeople, movies.Sum(m => m.Watchers).ToString(), movies.Count().ToString()));

            // Download movie images Async and set to facade
            GUIMovieListItem.GetImages(movieImages);
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        private void SendRecentShoutsToFacade(IEnumerable <TraktActivity.Activity> activities)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            // protected profiles might return null
            if (activities == null || activities.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.UserHasNoRecentShouts);
                PreviousUser = CurrentUser;
                CurrentUser  = TraktSettings.Username;
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

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

            // Add each item added
            foreach (var activity in activities)
            {
                // bad api data
                if (activity.Movie == null && activity.Show == null)
                {
                    continue;
                }

                var item = new GUICustomListItem(GUICommon.GetActivityListItemTitle(activity), (int)TraktGUIWindows.RecentShouts);

                // add images for download
                var images = new TraktImage
                {
                    ShowImages  = activity.Show != null ? activity.Show.Images : null,
                    MovieImages = activity.Movie != null ? activity.Movie.Images : null
                };
                shoutImages.Add(images);

                // add user shout date as second label
                item.Label2          = activity.Timestamp.FromEpoch().ToShortDateString();
                item.TVTag           = activity;
                item.Images          = images;
                item.ItemId          = Int32.MaxValue - itemId;
                item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                item.PinImage        = "traktActivityShout.png";
                item.OnItemSelected += OnShoutSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;
            }

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

            if (PreviousSelectedIndex >= activities.Count())
            {
                Facade.SelectIndex(PreviousSelectedIndex - 1);
            }
            else
            {
                Facade.SelectIndex(PreviousSelectedIndex);
            }

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

            // Download images Async and set to facade
            GUICustomListItem.GetImages(shoutImages);
        }
Esempio n. 18
0
        private void SendRecentlyWatchedToFacade(IEnumerable <TraktActivity.Activity> activities)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            // protected profiles might return null
            if (activities == null || activities.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.UserHasNotWatchedEpisodes);
                PreviousUser = CurrentUser;
                CurrentUser  = TraktSettings.Username;
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

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

            // Add each item watched
            foreach (var activity in activities)
            {
                // bad data in API
                if (activity.Show == null || activity.Episode == null)
                {
                    continue;
                }

                var episodeSummary = new TraktEpisodeSummary {
                    Episode = activity.Episode, Show = activity.Show
                };

                // skip invalid episodes
                if (episodeSummary.Episode.Number == 0)
                {
                    continue;
                }

                var item = new GUIEpisodeListItem(episodeSummary.ToString(), (int)TraktGUIWindows.RecentWatchedEpisodes);

                // add images for download
                var images = new TraktImage
                {
                    EpisodeImages = activity.Episode.Images,
                    ShowImages    = activity.Show.Images
                };
                showImages.Add(images);

                // add user watched date as second label
                item.Label2          = activity.Timestamp.FromEpoch().ToShortDateString();
                item.TVTag           = episodeSummary;
                item.Date            = activity.Timestamp.FromEpoch().ToLongDateString();
                item.Images          = images;
                item.ItemId          = Int32.MaxValue - itemId;
                item.IsPlayed        = activity.Episode.Watched;
                item.IconImage       = "defaultTraktEpisode.png";
                item.IconImageBig    = "defaultTraktEpisodeBig.png";
                item.ThumbnailImage  = "defaultTraktEpisodeBig.png";
                item.OnItemSelected += OnEpisodeSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;
            }

            // set Facade Layout
            Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout));
            GUIControl.FocusControl(GetID, Facade.GetID);

            if (PreviousSelectedIndex >= activities.Count())
            {
                Facade.SelectIndex(PreviousSelectedIndex - 1);
            }
            else
            {
                Facade.SelectIndex(PreviousSelectedIndex);
            }

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

            // Download show images Async and set to facade
            GUIEpisodeListItem.GetImages(showImages);
        }
        private void SendRecentlyAddedToFacade(IEnumerable <TraktActivity.Activity> activities)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            // protected profiles might return null
            if (activities == null || activities.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.UserHasNoRecentAddedMovies);
                PreviousUser = CurrentUser;
                CurrentUser  = TraktSettings.Username;
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

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

            // Add each item added
            foreach (var activity in activities)
            {
                // bad data in API
                if (activity.Movie == null)
                {
                    continue;
                }

                // add image for download
                var images = new TraktImage {
                    MovieImages = activity.Movie.Images
                };
                movieImages.Add(images);

                var item = new GUIMovieListItem(activity.Movie.Title, (int)TraktGUIWindows.RecentAddedMovies);

                // add user added date as second label
                item.Label2          = activity.Timestamp.FromEpoch().ToShortDateString();
                item.TVTag           = activity.Movie;
                item.Images          = images;
                item.Date            = activity.Timestamp.FromEpoch().ToLongDateString();
                item.ItemId          = Int32.MaxValue - itemId;
                item.IsPlayed        = activity.Movie.Watched;
                item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnMovieSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;
            }

            // set Facade Layout
            Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout));
            GUIControl.FocusControl(GetID, Facade.GetID);

            if (PreviousSelectedIndex >= activities.Count())
            {
                Facade.SelectIndex(PreviousSelectedIndex - 1);
            }
            else
            {
                Facade.SelectIndex(PreviousSelectedIndex);
            }

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

            // Download movie images Async and set to facade
            GUIMovieListItem.GetImages(movieImages);
        }
        private void SendWatchListMoviesToFacade(IEnumerable <TraktWatchListMovie> movies)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

            // sort movies
            var movieList = movies.Where(m => !string.IsNullOrEmpty(m.Title)).ToList();

            movieList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByWatchListMovies.Field, TraktSettings.SortByWatchListMovies.Direction));

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

            // Add each movie
            foreach (var movie in movieList)
            {
                // add image for download
                var images = new TraktImage {
                    MovieImages = movie.Images
                };
                movieImages.Add(images);

                var item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.WatchedListMovies);

                item.Label2          = movie.Year;
                item.TVTag           = movie;
                item.Images          = images;
                item.ItemId          = Int32.MaxValue - itemId;
                item.IsPlayed        = movie.Watched;
                item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnMovieSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;
            }

            // Set Facade Layout
            Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout));
            GUIControl.FocusControl(GetID, Facade.GetID);

            if (PreviousSelectedIndex >= movies.Count())
            {
                Facade.SelectIndex(PreviousSelectedIndex - 1);
            }
            else
            {
                Facade.SelectIndex(PreviousSelectedIndex);
            }

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

            // Download movie images Async and set to facade
            GUIMovieListItem.GetImages(movieImages);
        }
        private void SendRecommendedMoviesToFacade(IEnumerable <TraktMovie> movies)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

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

            // sort movies
            var movieList = movies.ToList();

            movieList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByRecommendedMovies.Field, TraktSettings.SortByRecommendedMovies.Direction));

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

            // Add each movie
            foreach (var movie in movieList)
            {
                var item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.RecommendationsMovies);

                // add image for download
                var image = new TraktImage {
                    MovieImages = movie.Images
                };
                movieImages.Add(image);

                item.Label2 = movie.Year;
                item.TVTag  = movie;
                item.Images = image;
                item.ItemId = Int32.MaxValue - itemId;
                // movie in collection doesnt nessararily mean
                // that the movie is locally available on this computer
                // as 'keep library clean' might not be enabled
                //item.IsRemote = !movie.InCollection;
                item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnMovieSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;
            }

            // Set Facade Layout
            Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout));
            GUIControl.FocusControl(GetID, Facade.GetID);

            if (PreviousSelectedIndex >= movies.Count())
            {
                Facade.SelectIndex(PreviousSelectedIndex - 1);
            }
            else
            {
                Facade.SelectIndex(PreviousSelectedIndex);
            }

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

            // Download movie images Async and set to facade
            GUIMovieListItem.GetImages(movieImages);
        }