Ejemplo n.º 1
0
        private void SendAnticipatedShowsToFacade(TraktShowsAnticipated anticipatedItems)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

            // filter shows
            var filteredAnticipatedList = FilterAnticipatedShows(anticipatedItems.Shows).Where(s => !string.IsNullOrEmpty(s.Show.Title)).ToList();

            // sort shows
            filteredAnticipatedList.Sort(new GUIListItemShowSorter(TraktSettings.SortByAnticipatedShows.Field, TraktSettings.SortByAnticipatedShows.Direction));

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

            // Add Previous Page Button
            if (anticipatedItems.CurrentPage != 1)
            {
                var prevPageItem = new GUIShowListItem(Translation.PreviousPage, (int)TraktGUIWindows.AnticipatedShows);
                prevPageItem.IsPrevPageItem  = true;
                prevPageItem.IconImage       = "traktPreviousPage.png";
                prevPageItem.IconImageBig    = "traktPreviousPage.png";
                prevPageItem.ThumbnailImage  = "traktPreviousPage.png";
                prevPageItem.OnItemSelected += OnPreviousPageSelected;
                prevPageItem.IsFolder        = true;
                Facade.Add(prevPageItem);
                itemId++;
            }

            foreach (var anticipatedItem in filteredAnticipatedList)
            {
                var item = new GUIShowListItem(anticipatedItem.Show.Title, (int)TraktGUIWindows.AnticipatedShows);

                // add image for download
                var image = new GUITmdbImage {
                    ShowImages = new TmdbShowImages {
                        Id = anticipatedItem.Show.Ids.Tmdb
                    }
                };
                showImages.Add(image);

                item.Label2          = anticipatedItem.Show.Year.ToString();
                item.TVTag           = anticipatedItem;
                item.Show            = anticipatedItem.Show;
                item.Images          = image;
                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++;
            }

            // Add Next Page Button
            if (anticipatedItems.CurrentPage != anticipatedItems.TotalPages)
            {
                var nextPageItem = new GUIShowListItem(Translation.NextPage, (int)TraktGUIWindows.AnticipatedShows);
                nextPageItem.IsNextPageItem  = true;
                nextPageItem.IconImage       = "traktNextPage.png";
                nextPageItem.IconImageBig    = "traktNextPage.png";
                nextPageItem.ThumbnailImage  = "traktNextPage.png";
                nextPageItem.OnItemSelected += OnNextPageSelected;
                nextPageItem.IsFolder        = true;
                Facade.Add(nextPageItem);
                itemId++;
            }

            // Set Facade Layout
            Facade.CurrentLayout = CurrentLayout;
            GUIControl.FocusControl(GetID, Facade.GetID);

            Facade.SelectIndex(PreviousSelectedIndex);

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

            // Page Properties
            GUIUtils.SetProperty("#Trakt.Facade.CurrentPage", anticipatedItems.CurrentPage.ToString());
            GUIUtils.SetProperty("#Trakt.Facade.TotalPages", anticipatedItems.TotalPages.ToString());
            GUIUtils.SetProperty("#Trakt.Facade.TotalItemsPerPage", TraktSettings.MaxAnticipatedShowsRequest.ToString());

            // Download show images Async and set to facade
            GUIShowListItem.GetImages(showImages);
        }
Ejemplo n.º 2
0
        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.CurrentLayout = 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);
        }
Ejemplo n.º 3
0
        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.UserHasNoRecentAddedEpisodes);
                PreviousUser = CurrentUser;
                CurrentUser  = TraktSettings.Username;
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

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

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

                // trakt returns an episode array per activity
                // you may add more than one in bulk
                foreach (var episode in activity.Episodes)
                {
                    // prevent too many episodes loading in facade
                    // its possible that 1 activity item can represent many episodes
                    // e.g. user could of added 400 episodes of The Simpsons
                    if (episodeCount >= 100)
                    {
                        continue;
                    }

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

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

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

                    // add images for download
                    var images = new GUITmdbImage
                    {
                        EpisodeImages = new TmdbEpisodeImages
                        {
                            Id      = episodeSummary.Show.Ids.Tmdb,
                            Season  = episodeSummary.Episode.Season,
                            Episode = episodeSummary.Episode.Number,
                            AirDate = episodeSummary.Episode.FirstAired == null ? null : episodeSummary.Episode.FirstAired.FromISO8601().ToLocalTime().ToShortDateString()
                        }
                    };
                    showImages.Add(images);

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

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

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

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

            // Download show images Async and set to facade
            GUIEpisodeListItem.GetImages(showImages);
        }
Ejemplo n.º 4
0
        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;
            List <TraktEpisode.ShowImages> episodeImages = new List <TraktEpisode.ShowImages>();

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

                GUITraktSeasonEpisodeListItem item = new GUITraktSeasonEpisodeListItem(itemLabel);

                // add image for download
                episodeImages.Add(episode.Images);

                item.Label2          = episode.FirstAired == 0 ? " " : episode.FirstAired.FromEpoch().ToShortDateString();
                item.TVTag           = episode;
                item.IsPlayed        = episode.Watched;
                item.Item            = episode.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(episodeImages);
        }
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedMovie = selectedItem.Movie;

            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUICommon.CreateMoviesContextMenu(ref dlg, selectedMovie, false);

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)MediaContextMenuItem.MarkAsWatched):
                TraktHelper.AddMovieToWatchHistory(selectedMovie);
                selectedItem.IsPlayed = true;
                OnItemSelected(selectedItem, Facade);
                selectedItem.Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.CreditMoviesHideWatched)
                {
                    LoadCredits();
                }
                break;

            case ((int)MediaContextMenuItem.MarkAsUnWatched):
                TraktHelper.RemoveMovieFromWatchHistory(selectedMovie);
                selectedItem.IsPlayed = false;
                OnItemSelected(selectedItem, Facade);
                selectedItem.Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)MediaContextMenuItem.AddToWatchList):
                TraktHelper.AddMovieToWatchList(selectedMovie, true);
                OnItemSelected(selectedItem, Facade);
                selectedItem.Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.CreditMoviesHideWatchlisted)
                {
                    LoadCredits();
                }
                break;

            case ((int)MediaContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveMovieFromWatchList(selectedMovie, true);
                OnItemSelected(selectedItem, Facade);
                selectedItem.Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)MediaContextMenuItem.AddToList):
                TraktHelper.AddRemoveMovieInUserList(selectedMovie, false);
                break;

            case ((int)MediaContextMenuItem.AddToLibrary):
                TraktHelper.AddMovieToCollection(selectedMovie);
                OnItemSelected(selectedItem, Facade);
                selectedItem.Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.CreditMoviesHideCollected)
                {
                    LoadCredits();
                }
                break;

            case ((int)MediaContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromCollection(selectedMovie);
                OnItemSelected(selectedItem, Facade);
                selectedItem.Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)MediaContextMenuItem.Related):
                TraktHelper.ShowRelatedMovies(selectedMovie);
                break;

            case ((int)MediaContextMenuItem.Rate):
                GUICommon.RateMovie(selectedMovie);
                OnItemSelected(selectedItem, Facade);
                selectedItem.Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.CreditMoviesHideRated)
                {
                    LoadCredits();
                }
                break;

            case ((int)MediaContextMenuItem.Filters):
                if (ShowMovieFiltersMenu())
                {
                    PreviousSelectedIndex = 0;
                    UpdateButtonState();
                    LoadCredits();
                }
                break;

            case ((int)MediaContextMenuItem.Shouts):
                TraktHelper.ShowMovieShouts(selectedMovie);
                break;

            case ((int)MediaContextMenuItem.Cast):
                GUICreditsMovie.Movie  = selectedMovie;
                GUICreditsMovie.Type   = GUICreditsMovie.CreditType.Cast;
                GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie);
                break;

            case ((int)MediaContextMenuItem.Crew):
                GUICreditsMovie.Movie  = selectedMovie;
                GUICreditsMovie.Type   = GUICreditsMovie.CreditType.Crew;
                GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie);
                break;

            case ((int)MediaContextMenuItem.Trailers):
                GUICommon.ShowMovieTrailersMenu(selectedMovie);
                break;

            case ((int)MediaContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

            case ((int)MediaContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0}", selectedMovie.Title);
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)MediaContextMenuItem.SearchTorrent):
                string loadParm = selectedMovie.Title;
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadParm);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 6
0
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktMovie selectedMovie = (TraktMovie)selectedItem.TVTag;

            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem listItem = null;

            // Hide/Show Watched items
            listItem = new GUIListItem(HideWatched ? Translation.ShowWatched : Translation.HideWatched);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.HideShowWatched;

            // Mark As Watched
            if (!selectedMovie.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
            }

            // Mark As UnWatched
            if (selectedMovie.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsUnWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched;
            }

            // Add/Remove Watch List
            if (!selectedMovie.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

            // Add to Custom list
            listItem = new GUIListItem(Translation.AddToList + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToList;

            // Add to Library
            // Don't allow if it will be removed again on next sync
            // movie could be part of a DVD collection
            if (!selectedMovie.InCollection && !TraktSettings.KeepTraktLibraryClean)
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }

            if (selectedMovie.InCollection)
            {
                listItem = new GUIListItem(Translation.RemoveFromLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary;
            }

            // Related Movies
            listItem = new GUIListItem(Translation.RelatedMovies + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            // Rate Movie
            listItem = new GUIListItem(Translation.RateMovie);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Rate;

            // Shouts
            listItem = new GUIListItem(Translation.Shouts + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            // Trailers
            if (TraktHelper.IsOnlineVideosAvailableAndEnabled)
            {
                listItem = new GUIListItem(Translation.Trailers);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Trailers;
            }

            // Change Layout
            listItem = new GUIListItem(Translation.ChangeLayout);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ChangeLayout;

            if (!selectedMovie.InCollection && TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for movie with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (!selectedMovie.InCollection && TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for movie with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
            }

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.HideShowWatched):
                HideWatched = !HideWatched;
                if (hideWatchedButton != null)
                {
                    hideWatchedButton.Selected = HideWatched;
                }
                dictRelatedMovies.Remove(relatedMovie.Slug);
                LoadRelatedMovies();
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                MarkMovieAsWatched(selectedMovie);
                if (!HideWatched)
                {
                    if (selectedMovie.Plays == 0)
                    {
                        selectedMovie.Plays = 1;
                    }
                    selectedMovie.Watched = true;
                    selectedItem.IsPlayed = true;
                    OnMovieSelected(selectedItem, Facade);
                    selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    dictRelatedMovies.Remove(relatedMovie.Slug);
                    LoadRelatedMovies();
                }
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                MarkMovieAsUnWatched(selectedMovie);
                selectedMovie.Watched = false;
                selectedItem.IsPlayed = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                AddMovieToWatchList(selectedMovie);
                selectedMovie.InWatchList = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveMovieFromWatchList(selectedMovie);
                selectedMovie.InWatchList = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveMovieInUserList(selectedMovie.Title, selectedMovie.Year, selectedMovie.IMDBID, false);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                AddMovieToLibrary(selectedMovie);
                selectedMovie.InCollection = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                RemoveMovieFromLibrary(selectedMovie);
                selectedMovie.InCollection = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.Related):
                RelatedMovie relMovie = new RelatedMovie
                {
                    Title  = selectedMovie.Title,
                    IMDbId = selectedMovie.IMDBID,
                    Year   = Convert.ToInt32(selectedMovie.Year)
                };
                relatedMovie = relMovie;
                GUIUtils.SetProperty("#Trakt.Related.Movie", relMovie.Title);
                LoadRelatedMovies();
                RelationChanged = true;
                break;

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateMovie(selectedMovie);
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.movie;
                GUIShouts.MovieInfo = new MovieShout {
                    IMDbId = selectedMovie.IMDBID, TMDbId = selectedMovie.TMDBID, Title = selectedMovie.Title, Year = selectedMovie.Year
                };
                GUIShouts.Fanart = selectedMovie.Images.FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowMovieTrailersMenu(selectedMovie);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout);
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0}", selectedMovie.Title);
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = selectedMovie.Title;
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
        private void SendTrendingMoviesToFacade(TraktMoviesTrending trendingItems)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

            if (trendingItems.Movies.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoTrendingMovies);
                GUIWindowManager.ShowPreviousWindow();
                TrendingMoviePages = null;
                return;
            }

            // filter movies
            var filteredTrendingList = GUICommon.FilterTrendingMovies(trendingItems.Movies).Where(m => !string.IsNullOrEmpty(m.Movie.Title)).ToList();

            // sort movies
            filteredTrendingList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByTrendingMovies.Field, TraktSettings.SortByTrendingMovies.Direction));

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

            // Add Previous Page Button
            if (trendingItems.CurrentPage != 1)
            {
                var prevPageItem = new GUIMovieListItem(Translation.PreviousPage, (int)TraktGUIWindows.TrendingMovies);
                prevPageItem.IsPrevPageItem  = true;
                prevPageItem.IconImage       = "traktPreviousPage.png";
                prevPageItem.IconImageBig    = "traktPreviousPage.png";
                prevPageItem.ThumbnailImage  = "traktPreviousPage.png";
                prevPageItem.OnItemSelected += OnPreviousPageSelected;
                prevPageItem.IsFolder        = true;
                Facade.Add(prevPageItem);
                itemId++;
            }

            // Add each movie mark remote if not in collection
            foreach (var trendingItem in filteredTrendingList)
            {
                // add image for download
                var images = new GUITmdbImage {
                    MovieImages = new TmdbMovieImages {
                        Id = trendingItem.Movie.Ids.Tmdb
                    }
                };
                movieImages.Add(images);

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

                item.Label2          = trendingItem.Movie.Year == null ? "----" : trendingItem.Movie.Year.ToString();
                item.TVTag           = trendingItem;
                item.Movie           = trendingItem.Movie;
                item.Images          = images;
                item.IsPlayed        = trendingItem.Movie.IsWatched();
                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++;
            }

            // Add Next Page Button
            if (trendingItems.CurrentPage != trendingItems.TotalPages)
            {
                var nextPageItem = new GUIMovieListItem(Translation.NextPage, (int)TraktGUIWindows.TrendingMovies);
                nextPageItem.IsNextPageItem  = true;
                nextPageItem.IconImage       = "traktNextPage.png";
                nextPageItem.IconImageBig    = "traktNextPage.png";
                nextPageItem.ThumbnailImage  = "traktNextPage.png";
                nextPageItem.OnItemSelected += OnNextPageSelected;
                nextPageItem.IsFolder        = true;
                Facade.Add(nextPageItem);
                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", filteredTrendingList.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", filteredTrendingList.Count(), filteredTrendingList.Count() > 1 ? Translation.Movies : Translation.Movie));

            // set global trending properties
            GUIUtils.SetProperty("#Trakt.Trending.PeopleCount", trendingItems.TotalWatchers.ToString());
            GUIUtils.SetProperty("#Trakt.Trending.Description", string.Format(Translation.TrendingMoviePeople, trendingItems.TotalWatchers.ToString(), trendingItems.TotalItems.ToString()));

            // Page Properties
            GUIUtils.SetProperty("#Trakt.Facade.CurrentPage", trendingItems.CurrentPage.ToString());
            GUIUtils.SetProperty("#Trakt.Facade.TotalPages", trendingItems.TotalPages.ToString());
            GUIUtils.SetProperty("#Trakt.Facade.TotalItemsPerPage", TraktSettings.MaxTrendingMoviesRequest.ToString());

            // Download movie images Async and set to facade
            GUIMovieListItem.GetImages(movieImages);
        }
Ejemplo n.º 8
0
        private void SendPersonSummaryToFacade(TraktPersonSummary person)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

            // publish person properties
            PublishSkinProperties(person);

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

            // add image for download
            var images = new GUITmdbImage {
                PeopleImages = new TmdbPeopleImages {
                    Id = person.Ids.TmdbId
                }
            };

            personImages.Add(images);

            // Add movie and show credit items
            var item = new GUIPersonListItem(Translation.MovieCredits, (int)TraktGUIWindows.PersonSummary);

            item.TVTag           = View.MovieCredits.ToString();
            item.ItemId          = Int32.MaxValue - itemId;
            item.Images          = images;
            item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
            item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
            item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
            item.OnItemSelected += OnItemSelected;
            Utils.SetDefaultIcons(item);
            Facade.Add(item);
            itemId++;

            // add image for download
            images = new GUITmdbImage {
                PeopleImages = new TmdbPeopleImages {
                    Id = person.Ids.TmdbId
                }
            };
            personImages.Add(images);

            item = new GUIPersonListItem(Translation.ShowCredits, (int)TraktGUIWindows.PersonSummary);

            item.TVTag           = View.ShowCredits.ToString();
            item.ItemId          = Int32.MaxValue - itemId;
            item.Images          = images;
            item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
            item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
            item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
            item.OnItemSelected += OnItemSelected;
            Utils.SetDefaultIcons(item);
            Facade.Add(item);
            itemId++;

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

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

            // Download images Async
            DownloadFanart(person);

            GUIPersonListItem.GetImages(personImages, false);
        }
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            var selectedItem = this.Facade.SelectedListItem as GUIShowListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedShow = selectedItem.TVTag as TraktShowSummary;

            if (selectedShow == null)
            {
                return;
            }

            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem listItem = null;

            // Show Season Information
            listItem = new GUIListItem(Translation.ShowSeasonInfo);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo;

            // Hide/Show Watched items
            listItem = new GUIListItem(HideWatched ? Translation.ShowWatched : Translation.HideWatched);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.HideShowWatched;

            // Mark Show As Watched
            listItem = new GUIListItem(Translation.MarkAsWatched);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;

            // Add Show to Library
            listItem = new GUIListItem(Translation.AddToLibrary);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToLibrary;

            // Add/Remove Watchlist
            if (!selectedShow.IsWatchlisted())
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

            // Add to Custom List
            listItem = new GUIListItem(Translation.AddToList);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToList;

            // Cast and Crew
            listItem = new GUIListItem(Translation.Cast);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Cast;

            listItem = new GUIListItem(Translation.Crew);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Crew;

            // Related Shows
            listItem = new GUIListItem(Translation.RelatedShows);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            // Rate Show
            listItem = new GUIListItem(Translation.RateShow);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Rate;

            // Shouts
            listItem = new GUIListItem(Translation.Comments);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            // Change Layout
            listItem = new GUIListItem(Translation.ChangeLayout);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ChangeLayout;

            // Trailers
            if (TraktHelper.IsTrailersAvailableAndEnabled)
            {
                listItem = new GUIListItem(Translation.Trailers);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Trailers;
            }

            if (TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for show with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for show with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
            }

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON());
                break;

            case ((int)ContextMenuItem.HideShowWatched):
                HideWatched = !HideWatched;
                if (hideWatchedButton != null)
                {
                    hideWatchedButton.Selected = HideWatched;
                }
                dictRelatedShows.Remove(relatedShow.Slug);
                LoadRelatedShows();
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                GUICommon.MarkShowAsWatched(selectedShow);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                GUICommon.AddShowToCollection(selectedShow);
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddShowToWatchList(selectedShow);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveShowFromWatchList(selectedShow);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveShowInUserList(selectedShow, false);
                break;

            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowTVShowTrailersMenu(selectedShow);
                break;

            case ((int)ContextMenuItem.Shouts):
                TraktHelper.ShowTVShowShouts(selectedShow);
                break;

            case ((int)ContextMenuItem.Related):
                var relShow = new RelatedShow
                {
                    TraktId = selectedShow.Ids.Trakt,
                    TmdbId  = selectedShow.Ids.Tmdb,
                    TvdbId  = selectedShow.Ids.Tvdb,
                    Title   = selectedShow.Title,
                    Year    = selectedShow.Year
                };
                relatedShow = relShow;
                LoadRelatedShows();
                GUIUtils.SetProperty("#Trakt.Related.Show", relatedShow.Title);
                RelationChanged = true;
                break;

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateShow(selectedShow);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.Cast):
                GUICreditsShow.Show   = selectedShow;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Cast;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.Crew):
                GUICreditsShow.Show   = selectedShow;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Crew;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0}", selectedShow.Title);
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = selectedShow.Title;
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 10
0
        private void SendRecommendedShowsToFacade(IEnumerable <TraktShow> shows)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

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

            // sort shows
            var showList = shows.ToList();

            showList.Sort(new GUIListItemShowSorter(TraktSettings.SortByRecommendedShows.Field, TraktSettings.SortByRecommendedShows.Direction));

            int itemId = 0;
            List <TraktShow.ShowImages> showImages = new List <TraktShow.ShowImages>();

            foreach (var show in showList)
            {
                GUITraktRecommendedShowListItem item = new GUITraktRecommendedShowListItem(show.Title);

                item.Label2          = show.Year.ToString();
                item.TVTag           = show;
                item.Item            = show.Images;
                item.ItemId          = Int32.MaxValue - itemId;
                item.IconImage       = "defaultVideo.png";
                item.IconImageBig    = "defaultVideoBig.png";
                item.ThumbnailImage  = "defaultVideoBig.png";
                item.OnItemSelected += OnShowSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;

                // add image for download
                showImages.Add(show.Images);
            }

            // 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
            GetImages(showImages);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktShow selectedShow = (TraktShow)selectedItem.TVTag;

            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem listItem = null;

            listItem = new GUIListItem(Translation.DismissRecommendation);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.DismissRecommendation;

            // Show Season Information
            listItem = new GUIListItem(Translation.ShowSeasonInfo);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo;


            // Add/Remove Watch List
            if (!selectedShow.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

            listItem = new GUIListItem(Translation.AddToList + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToList;

            if (TraktHelper.IsOnlineVideosAvailableAndEnabled)
            {
                listItem = new GUIListItem(Translation.Trailers);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Trailers;
            }

            // Related Shows
            listItem = new GUIListItem(Translation.RelatedShows + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            // Rate Show
            listItem = new GUIListItem(Translation.RateShow);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Rate;

            // Shouts
            listItem = new GUIListItem(Translation.Shouts + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            // Change Layout
            listItem = new GUIListItem(Translation.ChangeLayout);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ChangeLayout;

            if (TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for show with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for show with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
            }

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.DismissRecommendation):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                DismissRecommendation(selectedShow);
                if (_RecommendedShows.Count() > 1)
                {
                    var showsToExcept = new List <TraktShow>();
                    showsToExcept.Add(selectedShow);
                    _RecommendedShows = RecommendedShows.Except(showsToExcept);
                }
                else
                {
                    // reload, none left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _RecommendedShows = null;
                }
                LoadRecommendedShows();
                break;

            case ((int)ContextMenuItem.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON());
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                AddShowToWatchList(selectedShow);
                selectedShow.InWatchList = true;
                OnShowSelected(selectedItem, Facade);
                selectedShow.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveShowFromWatchList(selectedShow);
                selectedShow.InWatchList = false;
                OnShowSelected(selectedItem, Facade);
                selectedShow.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveShowInUserList(selectedShow.Title, selectedShow.Year.ToString(), selectedShow.Tvdb, false);
                break;

            case ((int)ContextMenuItem.Related):
                RelatedShow relatedShow = new RelatedShow();
                relatedShow.Title           = selectedShow.Title;
                relatedShow.TVDbId          = selectedShow.Tvdb;
                GUIRelatedShows.relatedShow = relatedShow;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedShows);
                break;

            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowTVShowTrailersMenu(selectedShow);
                break;

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.show;
                GUIShouts.ShowInfo  = new ShowShout {
                    IMDbId = selectedShow.Imdb, TVDbId = selectedShow.Tvdb, Title = selectedShow.Title
                };
                GUIShouts.Fanart = selectedShow.Images.FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

            case ((int)ContextMenuItem.Rate):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                if (GUICommon.RateShow(selectedShow))
                {
                    // remove from recommendations
                    if (_RecommendedShows.Count() > 1)
                    {
                        var showsToExcept = new List <TraktShow>();
                        showsToExcept.Add(selectedShow);
                        _RecommendedShows = RecommendedShows.Except(showsToExcept);
                    }
                    else
                    {
                        // reload, none left
                        ClearProperties();
                        GUIControl.ClearControl(GetID, Facade.GetID);
                        _RecommendedShows = null;
                    }
                    LoadRecommendedShows();
                }
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout);
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0}", selectedShow.Title);
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = selectedShow.Title;
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 13
0
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem as GUIShowListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedShow = selectedItem.TVTag as TraktShowSummary;

            if (selectedShow == null)
            {
                return;
            }

            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem listItem = null;

            listItem = new GUIListItem(Translation.DismissRecommendation);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.DismissRecommendation;

            // Show Season Information
            listItem = new GUIListItem(Translation.ShowSeasonInfo);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo;

            // Add/Remove Watchlist
            if (!selectedShow.IsWatchlisted())
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

            listItem = new GUIListItem(Translation.AddToList);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToList;

            if (TraktHelper.IsTrailersAvailableAndEnabled)
            {
                listItem = new GUIListItem(Translation.Trailers);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Trailers;
            }

            // Related Shows
            listItem = new GUIListItem(Translation.RelatedShows);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            // Rate Show
            listItem = new GUIListItem(Translation.RateShow);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Rate;

            // Shouts
            listItem = new GUIListItem(Translation.Comments);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            // Cast and Crew
            listItem = new GUIListItem(Translation.Cast);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Cast;

            listItem = new GUIListItem(Translation.Crew);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Crew;

            // Change Layout
            listItem = new GUIListItem(Translation.ChangeLayout);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ChangeLayout;

            if (TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for show with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for show with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
            }

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.DismissRecommendation):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                DismissRecommendation(selectedShow);
                if (_RecommendedShows.Count() > 1)
                {
                    var showsToExcept = new List <TraktShowSummary>();
                    showsToExcept.Add(selectedShow);
                    _RecommendedShows = RecommendedShows.Except(showsToExcept);
                }
                else
                {
                    // reload, none left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _RecommendedShows = null;
                }
                LoadRecommendedShows();
                break;

            case ((int)ContextMenuItem.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON());
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddShowToWatchList(selectedShow);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveShowFromWatchList(selectedShow);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveShowInUserList(selectedShow, false);
                break;

            case ((int)ContextMenuItem.Related):
                TraktHelper.ShowRelatedShows(selectedShow);
                break;

            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowTVShowTrailersMenu(selectedShow);
                break;

            case ((int)ContextMenuItem.Shouts):
                TraktHelper.ShowTVShowShouts(selectedShow);
                break;

            case ((int)ContextMenuItem.Rate):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                if (GUICommon.RateShow(selectedShow))
                {
                    // remove from recommendations
                    if (_RecommendedShows.Count() > 1)
                    {
                        var showsToExcept = new List <TraktShowSummary>();
                        showsToExcept.Add(selectedShow);
                        _RecommendedShows = RecommendedShows.Except(showsToExcept);
                    }
                    else
                    {
                        // reload, none left
                        ClearProperties();
                        GUIControl.ClearControl(GetID, Facade.GetID);
                        _RecommendedShows = null;
                    }
                    LoadRecommendedShows();
                }
                break;

            case ((int)ContextMenuItem.Cast):
                GUICreditsShow.Show   = selectedShow;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Cast;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.Crew):
                GUICreditsShow.Show   = selectedShow;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Crew;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0}", selectedShow.Title);
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = selectedShow.Title;
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 14
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            // wait for any background action to finish
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            switch (controlId)
            {
            // Facade
            case (50):
                if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    if (TraktSettings.EnableJumpToForTVShows)
                    {
                        CheckAndPlayEpisode(true);
                    }
                    else
                    {
                        GUIListItem selectedItem = this.Facade.SelectedListItem;
                        if (selectedItem == null)
                        {
                            return;
                        }

                        var selectedShow = selectedItem.TVTag as TraktShowSummary;
                        if (selectedShow == null)
                        {
                            return;
                        }

                        GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON());
                    }
                }
                break;

            // Layout Button
            case (2):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

            // Genre Button
            case (3):
                GUIUtils.ShowNotifyDialog("Trakt", Translation.FeatureNotAvailable);
                break;
            //TODO
            //ShowGenreMenu();
            //break;

            // Hide Collected Toggle Button
            case (4):
                GUIUtils.ShowNotifyDialog("Trakt", Translation.FeatureNotAvailable);
                break;
            //TODO
            //HideCollected = hideCollectedButton.Selected;
            //ReloadRecommendations();
            //break;

            // Hide Watchlisted Toggle Button
            case (5):
                GUIUtils.ShowNotifyDialog("Trakt", Translation.FeatureNotAvailable);
                break;
            //TODO
            //HideWatchlisted = hideWatchlistedButton.Selected;
            //ReloadRecommendations();
            //break;

            // Start Year Button
            case (6):
                GUIUtils.ShowNotifyDialog("Trakt", Translation.FeatureNotAvailable);
                break;
            //TODO
            //string startYear = StartYear.ToString();
            //if (startYear == "0") startYear = "1919";
            //if (GUIUtils.GetStringFromKeyboard(ref startYear))
            //{
            //    int result;
            //    if (startYear.Length == 4 && int.TryParse(startYear, out result) && !startYear.Equals(StartYear.ToString()))
            //    {
            //        StartYear = result;
            //        GUIControl.SetControlLabel(GetID, startYearButton.GetID, GetStartYearTitle(StartYear));
            //        ReloadRecommendations();
            //    }
            //}
            //break;

            // End Year Button
            case (7):
                GUIUtils.ShowNotifyDialog("Trakt", Translation.FeatureNotAvailable);
                break;
            //TODO
            //string endYear = EndYear.ToString();
            //if (endYear == "0") endYear = DateTime.Now.AddYears(3).Year.ToString();
            //if (GUIUtils.GetStringFromKeyboard(ref endYear))
            //{
            //    int result;
            //    if (endYear.Length == 4 && int.TryParse(endYear, out result) && !endYear.Equals(EndYear.ToString()))
            //    {
            //        EndYear = result;
            //        GUIControl.SetControlLabel(GetID, endYearButton.GetID, GetEndYearTitle(EndYear));
            //        ReloadRecommendations();
            //    }
            //}
            //break;

            // Sort Button
            case (8):
                var newSortBy = GUICommon.ShowSortMenu(TraktSettings.SortByRecommendedShows);
                if (newSortBy != null)
                {
                    if (newSortBy.Field != TraktSettings.SortByRecommendedShows.Field)
                    {
                        TraktSettings.SortByRecommendedShows = newSortBy;
                        PreviousSelectedIndex = 0;
                        UpdateButtonState();
                        LoadRecommendedShows();
                    }
                }
                break;

            default:
                break;
            }
            base.OnClicked(controlId, control, actionType);
        }
Ejemplo n.º 15
0
        protected override void OnShowContextMenu()
        {
            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            var selectedItem = Facade.SelectedListItem as GUIEpisodeListItem;

            if (selectedItem == null)
            {
                return;
            }

            var calendarItem = selectedItem.TVTag as TraktShowCalendar;

            if (calendarItem == null)
            {
                return;
            }

            // Create Views Menu Item
            var listItem = new GUIListItem(Translation.ChangeView);

            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.View;

            // Start Date
            listItem = new GUIListItem(Translation.StartDate + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.StartDate;

            // Max Days
            listItem = new GUIListItem(Translation.MaxDays + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.MaxDays;

            // Show Season Information
            listItem = new GUIListItem(Translation.ShowSeasonInfo);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo;

            // Hide Show
            listItem = new GUIListItem(Translation.HideShow);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.HideShow;

            // Hide Season
            //listItem = new GUIListItem(Translation.HideSeason);
            //dlg.Add(listItem);
            //listItem.ItemId = (int)ContextMenuItem.HideSeason;

            // Related Shows
            listItem = new GUIListItem(Translation.RelatedShows);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            // Rate
            listItem = new GUIListItem(Translation.Rate + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Rate;

            // Mark As Watched
            if (!calendarItem.Episode.IsWatched(calendarItem.Show))
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
            }

            // Mark As UnWatched
            if (calendarItem.Episode.IsWatched(calendarItem.Show))
            {
                listItem = new GUIListItem(Translation.MarkAsUnWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched;
            }

            // Add/Remove Show Watchlist
            if (!calendarItem.Show.IsWatchlisted())
            {
                listItem = new GUIListItem(Translation.AddShowToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddShowToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveShowFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveShowFromWatchList;
            }

            // Add/Remove Episode Watchlist
            if (!calendarItem.Episode.IsWatchlisted())
            {
                listItem = new GUIListItem(Translation.AddEpisodeToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddEpisodeToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveEpisodeFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveEpisodeFromWatchList;
            }

            // Add Show to Custom List
            listItem = new GUIListItem(Translation.AddShowToList + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddShowToList;

            // Add Episode to Custom List
            listItem = new GUIListItem(Translation.AddEpisodeToList + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddEpisodeToList;

            // Shouts
            listItem = new GUIListItem(Translation.Comments);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            // Add/Remove Libary
            if (!calendarItem.Episode.IsCollected(calendarItem.Show))
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary;
            }

            // Cast and Crew
            listItem = new GUIListItem(Translation.Cast);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Cast;

            listItem = new GUIListItem(Translation.Crew);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Crew;

            if (TraktHelper.IsTrailersAvailableAndEnabled)
            {
                listItem = new GUIListItem(Translation.Trailers);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Trailers;
            }

            // Watchlist Filter
            if (CurrentCalendar == CalendarType.UserShows)
            {
                if (TraktSettings.CalendarHideTVShowsInWatchList)
                {
                    listItem = new GUIListItem(Translation.ShowTVShowsInWatchlist);
                }
                else
                {
                    listItem = new GUIListItem(Translation.HideTVShowsInWatchlist);
                }

                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.WatchlistFilter;
            }

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.View):
                ShowViewMenu();
                break;

            case ((int)ContextMenuItem.StartDate):
                ShowStartDateMenu();
                break;

            case ((int)ContextMenuItem.MaxDays):
                ShowMaxDaysMenu();
                break;

            case ((int)ContextMenuItem.HideShow):
                TraktHelper.AddHiddenShow(calendarItem.Show, "calendar");
                FilterHiddenShows = true;
                LoadCalendar();
                break;

            case ((int)ContextMenuItem.HideSeason):
                break;

            case ((int)ContextMenuItem.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, calendarItem.Show.ToJSON());
                break;

            case ((int)ContextMenuItem.Related):
                TraktHelper.ShowRelatedShows(calendarItem.Show);
                break;

            case ((int)ContextMenuItem.Shouts):
                TraktHelper.ShowEpisodeShouts(calendarItem.Show, calendarItem.Episode);
                break;

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateEpisode(calendarItem.Show, calendarItem.Episode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                TraktHelper.AddEpisodeToWatchHistory(calendarItem.Episode);
                TraktCache.AddEpisodeToWatchHistory(calendarItem.Show, calendarItem.Episode);
                Facade.SelectedListItem.IsPlayed = true;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                TraktHelper.RemoveEpisodeFromWatchHistory(calendarItem.Episode);
                TraktCache.RemoveEpisodeFromWatchHistory(calendarItem.Show, calendarItem.Episode);
                Facade.SelectedListItem.IsPlayed = false;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.AddShowToWatchList):
                TraktHelper.AddShowToWatchList(calendarItem.Show);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddEpisodeToWatchList):
                TraktHelper.AddEpisodeToWatchList(calendarItem.Episode);
                TraktCache.AddEpisodeToWatchlist(calendarItem.Show, calendarItem.Episode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveShowFromWatchList):
                TraktHelper.RemoveShowFromWatchList(calendarItem.Show);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveEpisodeFromWatchList):
                TraktHelper.RemoveEpisodeFromWatchList(calendarItem.Episode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddEpisodeToList):
                TraktHelper.AddRemoveEpisodeInUserList(calendarItem.Episode, false);
                break;

            case ((int)ContextMenuItem.AddShowToList):
                TraktHelper.AddRemoveShowInUserList(calendarItem.Show, false);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddEpisodeToCollection(calendarItem.Episode);
                TraktCache.AddEpisodeToCollection(calendarItem.Show, calendarItem.Episode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveEpisodeFromCollection(calendarItem.Episode);
                TraktCache.RemoveEpisodeFromCollection(calendarItem.Show, calendarItem.Episode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.Cast):
                GUICreditsShow.Show   = calendarItem.Show;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Cast;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.Crew):
                GUICreditsShow.Show   = calendarItem.Show;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Crew;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.Trailers):
                if (calendarItem != null)
                {
                    GUICommon.ShowTVShowTrailersMenu(calendarItem.Show, calendarItem.Episode);
                }
                break;

            case ((int)ContextMenuItem.WatchlistFilter):
                TraktSettings.CalendarHideTVShowsInWatchList = !TraktSettings.CalendarHideTVShowsInWatchList;
                SetHideWatchlisted();
                LoadCalendar();
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
        private void SendRelatedShowsToFacade(IEnumerable <TraktShowSummary> shows)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

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

            if (shows.Count() == 0)
            {
                string title = string.IsNullOrEmpty(relatedShow.Title) ? relatedShow.Slug : relatedShow.Title;
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoRelatedShows, title));
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (HideWatched)
            {
                // not interested if we have watched any underlying episodes
                shows = shows.Where(s => s.Plays() == 0);
            }

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

            foreach (var show in shows)
            {
                var item = new GUIShowListItem(show.Title, (int)TraktGUIWindows.RelatedShows);

                // add image for download
                var images = new GUITmdbImage {
                    ShowImages = new TmdbShowImages {
                        Id = show.Ids.Tmdb
                    }
                };
                showImages.Add(images);

                item.Label2          = show.Year.ToString();
                item.TVTag           = show;
                item.Show            = show;
                item.Show            = 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.CurrentLayout = 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);
        }
Ejemplo n.º 17
0
        private void SendCalendarToFacade(Dictionary <string, List <TraktShowCalendar> > calendar)
        {
            // check if we got a bad response
            if (calendar == null)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.ErrorCalendar);
                // set defaults
                TVShowCalendar = null;
                LastRequest    = new DateTime();
                return;
            }

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

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

            // Add Previous Days Item so user can go back to previous calendar entries
            var prevItem = new GUIListItem(string.Format(Translation.PreviousDays, TraktSettings.TvCalendarMaxDays))
            {
                IconImage      = "traktPrevWeek.png",
                IconImageBig   = "traktPrevWeek.png",
                ThumbnailImage = "traktPrevWeek.png",
                TVTag          = "previous",
                IsFolder       = true
            };

            prevItem.OnItemSelected += OnPrevWeekSelected;
            Facade.Add(prevItem);

            // Add each days episodes to the list
            // Use Label3 of facade for Day/Group Idenitfier
            foreach (var day in calendar)
            {
                // apply watchlist filter
                var episodesInDay = day.Value;
                if (TraktSettings.CalendarHideTVShowsInWatchList && !string.IsNullOrEmpty(TraktSettings.UserAccessToken))
                {
                    episodesInDay = day.Value.Where(e => !e.Show.IsWatchlisted()).ToList();
                }

                // filter hidden shows
                if (FilterHiddenShows && !string.IsNullOrEmpty(TraktSettings.UserAccessToken))
                {
                    // for each hidden trakt show in the calendar, remove from our request
                    // this only needs to be done if we have manually hidden a show whilst using a cached calendar
                    episodesInDay.RemoveAll(e => e.Show.IsHidden("calendar"));
                }

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

                    foreach (var calendarItem in episodesInDay)
                    {
                        var episodeItem = new GUIEpisodeListItem(calendarItem.ToString(), (int)TraktGUIWindows.CalendarTV);

                        // add image for download
                        var images = new GUITmdbImage
                        {
                            EpisodeImages = new TmdbEpisodeImages
                            {
                                Id      = calendarItem.Show.Ids.Tmdb,
                                Season  = calendarItem.Episode.Season,
                                Episode = calendarItem.Episode.Number,
                                AirDate = calendarItem.Episode.FirstAired == null ? null : calendarItem.Episode.FirstAired.FromISO8601().ToLocalTime().ToShortDateString()
                            }
                        };
                        showImages.Add(images);

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

                        episodeItem.Images          = images;
                        episodeItem.TVTag           = calendarItem;
                        episodeItem.Episode         = calendarItem.Episode;
                        episodeItem.Show            = calendarItem.Show;
                        episodeItem.ItemId          = Int32.MaxValue - itemCount;
                        episodeItem.IsPlayed        = calendarItem.Episode.IsWatched(calendarItem.Show);
                        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 (itemCount == 0)
            {
                var item = new GUIListItem()
                {
                    Label3         = Translation.NoEpisodesThisWeek,
                    IconImage      = "defaultTraktCalendar.png",
                    IconImageBig   = "defaultTraktCalendarBig.png",
                    ThumbnailImage = "defaultTraktCalendarBig.png"
                };

                item.OnItemSelected += OnCalendarDateSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
            }

            // Add Next Days Item so user can fetch next days calendar
            var nextItem = new GUIListItem(string.Format(Translation.NextDays, TraktSettings.TvCalendarMaxDays))
            {
                IconImage      = "traktNextWeek.png",
                IconImageBig   = "traktNextWeek.png",
                ThumbnailImage = "traktNextWeek.png",
                TVTag          = "next",
                IsFolder       = true
            };

            nextItem.OnItemSelected += OnNextWeekSelected;
            Facade.Add(nextItem);

            // Set Facade Layout
            Facade.CurrentLayout = GUIFacadeControl.Layout.List;
            GUIControl.FocusControl(GetID, Facade.GetID);

            // if we cached the last selected index then use it
            // e.g. returning from another window and the cache has not expired
            if (PreviousSelectedIndex > 0)
            {
                Facade.SelectedListItemIndex = PreviousSelectedIndex;
            }
            else
            {
                // beginning of a page has a previous button
                // and a date header, so skip 2 items
                Facade.SelectedListItemIndex = 2;
            }

            // 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);
        }
Ejemplo n.º 18
0
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            var selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedShout = selectedItem.TVTag as TraktShout;

            if (selectedShout == null)
            {
                return;
            }

            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem listItem = null;

            if (ShoutType == ShoutTypeEnum.episode)
            {
                listItem = new GUIListItem(Translation.NextEpisode);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.NextEpisode;

                if (int.Parse(EpisodeInfo.EpisodeIdx) > 1)
                {
                    listItem = new GUIListItem(Translation.PreviousEpisode);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.PrevEpisode;
                }
            }

            listItem = new GUIListItem(TraktSettings.HideSpoilersOnShouts ? Translation.ShowSpoilers : Translation.HideSpoilers);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Spoilers;

            // userprofile - only load for unprotected users
            if (!selectedShout.User.Protected)
            {
                listItem = new GUIListItem(Translation.UserProfile);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.UserProfile;
            }
            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.Spoilers):
                TraktSettings.HideSpoilersOnShouts = !TraktSettings.HideSpoilersOnShouts;
                if (hideSpoilersButton != null)
                {
                    hideSpoilersButton.Selected = TraktSettings.HideSpoilersOnShouts;
                }
                PublishShoutSkinProperties(selectedShout);
                break;

            case ((int)ContextMenuItem.NextEpisode):
                GetNextEpisodeShouts();
                break;

            case ((int)ContextMenuItem.PrevEpisode):
                GetPrevEpisodeShouts();
                break;

            case ((int)ContextMenuItem.UserProfile):
                GUIUserProfile.CurrentUser = selectedShout.User.Username;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.UserProfile);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 19
0
 private void ClearProperties()
 {
     GUIUtils.SetProperty("#Trakt.Related.Movie", string.Empty);
     GUICommon.ClearMovieProperties();
 }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedEpisode = selectedItem.TVTag as TraktEpisode;

            if (selectedEpisode == null)
            {
                return;
            }

            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem listItem = null;

            listItem = new GUIListItem(Translation.Trailers + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Trailers;

            if (selectedEpisode.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsUnWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched;
            }
            else
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
            }

            if (selectedEpisode.InCollection)
            {
                listItem = new GUIListItem(Translation.RemoveFromLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary;
            }
            else
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }

            if (selectedEpisode.InWatchList)
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.AddEpisodeToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }

            // Add to Custom List
            listItem = new GUIListItem(Translation.AddToList + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToList;

            // Rate
            listItem = new GUIListItem(Translation.Rate + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Rate;

            // Shouts
            listItem = new GUIListItem(Translation.Shouts + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            // Change Layout
            listItem = new GUIListItem(Translation.ChangeLayout);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ChangeLayout;

            if (TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for show with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for show with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
            }

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowTVShowTrailersMenu(Show, selectedEpisode);
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                MarkEpisodeAsWatched(selectedEpisode);
                selectedEpisode.Watched          = true;
                Facade.SelectedListItem.IsPlayed = true;
                if (selectedEpisode.Plays == 0)
                {
                    selectedEpisode.Plays = 1;
                }
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                MarkEpisodeAsUnWatched(selectedEpisode);
                selectedEpisode.Watched          = false;
                Facade.SelectedListItem.IsPlayed = false;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                AddEpisodeToLibrary(selectedEpisode);
                selectedEpisode.InCollection = true;
                OnEpisodeSelected(selectedItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                RemoveEpisodeFromLibrary(selectedEpisode);
                selectedEpisode.InCollection = false;
                OnEpisodeSelected(selectedItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                AddEpisodeToWatchList(selectedEpisode);
                selectedEpisode.InWatchList = true;
                OnEpisodeSelected(selectedItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveEpisodeFromWatchList(selectedEpisode);
                selectedEpisode.InWatchList = false;
                OnEpisodeSelected(selectedItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.Rate):
                RateEpisode(selectedEpisode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveEpisodeInUserList(Show.Title, Show.Year.ToString(), selectedEpisode.Season.ToString(), selectedEpisode.Number.ToString(), Show.Tvdb, false);
                break;

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType   = GUIShouts.ShoutTypeEnum.episode;
                GUIShouts.EpisodeInfo = new EpisodeShout
                {
                    TVDbId     = Show.Tvdb,
                    IMDbId     = Show.Imdb,
                    Title      = Show.Title,
                    SeasonIdx  = selectedEpisode.Season.ToString(),
                    EpisodeIdx = selectedEpisode.Number.ToString()
                };
                GUIShouts.Fanart = Show.Images.FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout);
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0} S{1}E{2}", Show.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = string.Format("{0} S{1}E{2}", Show.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 22
0
        private void SetProperty(string property, string value)
        {
            string propertyValue = string.IsNullOrEmpty(value) ? "N/A" : value;

            GUIUtils.SetProperty(property, propertyValue);
        }
Ejemplo n.º 23
0
        private void GetImages(List <TraktEpisode.ShowImages> itemsWithThumbs)
        {
            StopDownload = false;

            new Thread((o) =>
            {
                // download fanart if we need to
                if (!File.Exists(Show.Images.FanartImageFilename) && !string.IsNullOrEmpty(Show.Images.Fanart) && TraktSettings.DownloadFanart)
                {
                    if (GUIImageHandler.DownloadImage(Show.Images.Fanart, Show.Images.FanartImageFilename))
                    {
                        // notify that image has been downloaded
                        GUIUtils.SetProperty("#Trakt.Show.Fanart", Show.Images.FanartImageFilename);
                    }
                }
            })
            {
                IsBackground = true,
                Name         = "ImageDownloader"
            }.Start();

            // split the downloads in 5+ groups and do multithreaded downloading
            int groupSize = (int)Math.Max(1, Math.Floor((double)itemsWithThumbs.Count / 5));
            int groups    = (int)Math.Ceiling((double)itemsWithThumbs.Count() / groupSize);

            for (int i = 0; i < groups; i++)
            {
                List <TraktEpisode.ShowImages> groupList = new List <TraktEpisode.ShowImages>();
                for (int j = groupSize * i; j < groupSize * i + (groupSize * (i + 1) > itemsWithThumbs.Count ? itemsWithThumbs.Count - groupSize * i : groupSize); j++)
                {
                    groupList.Add(itemsWithThumbs[j]);
                }

                new Thread(delegate(object o)
                {
                    List <TraktEpisode.ShowImages> items = (List <TraktEpisode.ShowImages>)o;
                    foreach (TraktEpisode.ShowImages item in items)
                    {
                        #region Episode Image
                        // stop download if we have exited window
                        if (StopDownload)
                        {
                            break;
                        }

                        string remoteThumb = item.Screen;
                        string localThumb  = item.EpisodeImageFilename;

                        if (!string.IsNullOrEmpty(remoteThumb) && !string.IsNullOrEmpty(localThumb))
                        {
                            if (GUIImageHandler.DownloadImage(remoteThumb, localThumb))
                            {
                                // notify that image has been downloaded
                                item.NotifyPropertyChanged("EpisodeImageFilename");
                            }
                        }
                        #endregion
                    }
                })
                {
                    IsBackground = true,
                    Name         = "ImageDownloader" + i.ToString()
                }.Start(groupList);
            }
        }
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            // wait for any background action to finish
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            switch (controlId)
            {
            // Facade
            case (50):
                if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    CheckAndPlayMovie(true);
                }
                break;

            // Layout Button
            case (2):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout);
                break;

            // Genre Button
            case (3):
                ShowGenreMenu();
                break;

            // Hide Collected Toggle Button
            case (4):
                HideCollected = hideCollectedButton.Selected;
                ReloadRecommendations();
                break;

            // Hide Watchlisted Toggle Button
            case (5):
                HideWatchlisted = hideWatchlistedButton.Selected;
                ReloadRecommendations();
                break;

            // Start Year Button
            case (6):
                string startYear = StartYear.ToString();
                if (startYear == "0")
                {
                    startYear = "1888";
                }
                if (GUIUtils.GetStringFromKeyboard(ref startYear))
                {
                    int result;
                    if (startYear.Length == 4 && int.TryParse(startYear, out result))
                    {
                        StartYear = result;
                        GUIControl.SetControlLabel(GetID, startYearButton.GetID, GetStartYearTitle(StartYear));
                        ReloadRecommendations();
                    }
                }
                break;

            // End Year Button
            case (7):
                string endYear = EndYear.ToString();
                if (endYear == "0")
                {
                    endYear = DateTime.Now.AddYears(3).Year.ToString();
                }
                if (GUIUtils.GetStringFromKeyboard(ref endYear))
                {
                    int result;
                    if (endYear.Length == 4 && int.TryParse(endYear, out result))
                    {
                        EndYear = result;
                        GUIControl.SetControlLabel(GetID, endYearButton.GetID, GetEndYearTitle(EndYear));
                        ReloadRecommendations();
                    }
                }
                break;

            // Sort Button
            case (8):
                var newSortBy = GUICommon.ShowSortMenu(TraktSettings.SortByRecommendedMovies);
                if (newSortBy != null)
                {
                    if (newSortBy.Field != TraktSettings.SortByRecommendedMovies.Field)
                    {
                        TraktSettings.SortByRecommendedMovies = newSortBy;
                        PreviousSelectedIndex = 0;
                        UpdateButtonState();
                        LoadRecommendedMovies();
                    }
                }
                break;

            default:
                break;
            }
            base.OnClicked(controlId, control, actionType);
        }
Ejemplo n.º 25
0
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedWatchlistItem = selectedItem.TVTag as TraktEpisodeWatchList;

            if (selectedWatchlistItem == null)
            {
                return;
            }

            var selectedShow    = selectedWatchlistItem.Show;
            var selectedEpisode = selectedWatchlistItem.Episode;

            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem listItem = null;

            if (CurrentUser == TraktSettings.Username)
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

            if (TraktHelper.IsTrailersAvailableAndEnabled)
            {
                listItem = new GUIListItem(Translation.Trailers);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Trailers;
            }

            // Add to Custom List
            listItem = new GUIListItem(Translation.AddToList);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToList;

            // Shouts
            listItem = new GUIListItem(Translation.Comments);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            // Change Layout
            listItem = new GUIListItem(Translation.ChangeLayout);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ChangeLayout;

            if (TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for show with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for show with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
            }

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.RemoveFromWatchList):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                TraktHelper.RemoveEpisodeFromWatchList(selectedEpisode);
                if (this.Facade.Count >= 1)
                {
                    // remove from list
                    var currentWatchlist = _WatchListEpisodes.ToList();
                    currentWatchlist.RemoveAll(w => w.Episode.Ids.Trakt == selectedEpisode.Ids.Trakt);

                    userWatchList[CurrentUser] = currentWatchlist;
                    _WatchListEpisodes         = currentWatchlist;

                    // reload
                    LoadWatchListEpisodes();
                }
                else
                {
                    // no more shows left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _WatchListEpisodes = null;
                    userWatchList.Remove(CurrentUser);
                    // notify and exit
                    GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoShowWatchList);
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveEpisodeInUserList(selectedEpisode, false);
                break;

            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowTVShowTrailersMenu(selectedShow, selectedEpisode);
                break;

            case ((int)ContextMenuItem.Shouts):
                TraktHelper.ShowEpisodeShouts(selectedShow, selectedEpisode);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0} S{1}E{2}", selectedShow.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = string.Format("{0} S{1}E{2}", selectedShow.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktMovie selectedMovie = (TraktMovie)selectedItem.TVTag;

            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem listItem = null;

            // Dismiss Recommendation
            listItem = new GUIListItem(Translation.DismissRecommendation);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.DismissRecommendation;

            // Mark As Watched
            // This should remove item from recommendations if executed
            if (!selectedMovie.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
            }

            // Add/Remove Watch List
            if (!selectedMovie.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

            // Add to Custom List
            listItem = new GUIListItem(Translation.AddToList + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToList;

            // Add to Library
            // Don't allow if it will be removed again on next sync
            // movie could be part of a DVD collection
            if (!selectedMovie.InCollection && !TraktSettings.KeepTraktLibraryClean)
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }

            if (selectedMovie.InCollection)
            {
                listItem = new GUIListItem(Translation.RemoveFromLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary;
            }

            // Related Movies
            listItem = new GUIListItem(Translation.RelatedMovies + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            // Rate Movie
            listItem = new GUIListItem(Translation.RateMovie);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Rate;

            // Shouts
            listItem = new GUIListItem(Translation.Shouts + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            if (TraktHelper.IsOnlineVideosAvailableAndEnabled)
            {
                // Trailers
                listItem = new GUIListItem(Translation.Trailers);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Trailers;
            }

            // Change Layout
            listItem = new GUIListItem(Translation.ChangeLayout);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ChangeLayout;

            if (!selectedMovie.InCollection && TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for movie with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (!selectedMovie.InCollection && TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for movie with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
            }

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.DismissRecommendation):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                DismissRecommendation(selectedMovie);
                if (_RecommendedMovies.Count() > 1)
                {
                    var moviesToExcept = new List <TraktMovie>();
                    moviesToExcept.Add(selectedMovie);
                    _RecommendedMovies = RecommendedMovies.Except(moviesToExcept);
                }
                else
                {
                    // reload, none left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _RecommendedMovies = null;
                }
                LoadRecommendedMovies();
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                MarkMovieAsWatched(selectedMovie);
                if (_RecommendedMovies.Count() > 1)
                {
                    var moviesToExcept = new List <TraktMovie>();
                    moviesToExcept.Add(selectedMovie);
                    _RecommendedMovies = RecommendedMovies.Except(moviesToExcept);
                }
                else
                {
                    // reload, none left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _RecommendedMovies = null;
                }
                LoadRecommendedMovies();
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                AddMovieToWatchList(selectedMovie);
                selectedMovie.InWatchList = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveMovieFromWatchList(selectedMovie);
                selectedMovie.InWatchList = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveMovieInUserList(selectedMovie.Title, selectedMovie.Year, selectedMovie.IMDBID, false);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                AddMovieToLibrary(selectedMovie);
                selectedMovie.InCollection = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                RemoveMovieFromLibrary(selectedMovie);
                selectedMovie.InCollection = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.Related):
                RelatedMovie relatedMovie = new RelatedMovie();
                relatedMovie.IMDbId           = selectedMovie.IMDBID;
                relatedMovie.Title            = selectedMovie.Title;
                GUIRelatedMovies.relatedMovie = relatedMovie;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedMovies);
                break;

            case ((int)ContextMenuItem.Rate):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                if (GUICommon.RateMovie(selectedMovie))
                {
                    // also mark as watched
                    MarkMovieAsWatched(selectedMovie);
                    // remove from recommendations
                    if (_RecommendedMovies.Count() > 1)
                    {
                        var moviesToExcept = new List <TraktMovie>();
                        moviesToExcept.Add(selectedMovie);
                        _RecommendedMovies = RecommendedMovies.Except(moviesToExcept);
                    }
                    else
                    {
                        // reload, none left
                        ClearProperties();
                        GUIControl.ClearControl(GetID, Facade.GetID);
                        _RecommendedMovies = null;
                    }
                    LoadRecommendedMovies();
                }
                break;

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.movie;
                GUIShouts.MovieInfo = new MovieShout {
                    IMDbId = selectedMovie.IMDBID, TMDbId = selectedMovie.TMDBID, Title = selectedMovie.Title, Year = selectedMovie.Year
                };
                GUIShouts.Fanart = selectedMovie.Images.FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowMovieTrailersMenu(selectedMovie);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout);
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0}", selectedMovie.Title);
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = selectedMovie.Title;
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 27
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedEpisodeSummary = selectedItem.TVTag as TraktEpisodeSummaryEx;

            if (selectedEpisodeSummary == null)
            {
                return;
            }

            var selectedEpisode = selectedEpisodeSummary.Episode;

            if (selectedEpisode == null)
            {
                return;
            }

            var selectedShow = selectedEpisodeSummary.Show;

            if (selectedShow == null)
            {
                return;
            }

            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem listItem = null;

            // Show Season Information
            listItem = new GUIListItem(Translation.ShowSeasonInfo);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo;

            if (!selectedEpisode.IsWatchlisted())
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

            // Add to Custom List
            listItem = new GUIListItem(Translation.AddToList);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToList;

            // Mark As Watched
            if (!selectedEpisode.IsWatched(selectedShow))
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
            }

            // Mark As UnWatched
            if (selectedEpisode.IsWatched(selectedShow))
            {
                listItem = new GUIListItem(Translation.MarkAsUnWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched;
            }

            // Add to Library
            // Don't allow if it will be removed again on next sync
            // movie could be part of a DVD collection
            if (!selectedEpisode.IsCollected(selectedShow) && !TraktSettings.KeepTraktLibraryClean)
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }

            if (selectedEpisode.IsCollected(selectedShow))
            {
                listItem = new GUIListItem(Translation.RemoveFromLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary;
            }

            // Related Shows
            listItem = new GUIListItem(Translation.RelatedShows);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            // Rate Episode
            listItem = new GUIListItem(Translation.RateEpisode);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Rate;

            // Shouts
            listItem = new GUIListItem(Translation.Comments);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            if (TraktHelper.IsTrailersAvailableAndEnabled)
            {
                // Trailers
                listItem = new GUIListItem(Translation.Trailers);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Trailers;
            }

            // Change Layout
            listItem = new GUIListItem(Translation.ChangeLayout);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ChangeLayout;

            if (!selectedEpisode.IsCollected(selectedShow) && TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for movie with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (!selectedEpisode.IsCollected(selectedShow) && TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for movie with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
            }

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON());
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                TraktHelper.AddEpisodeToWatchHistory(selectedEpisode);
                TraktCache.AddEpisodeToWatchHistory(selectedShow, selectedEpisode);
                selectedItem.IsPlayed = true;
                OnEpisodeSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                TraktHelper.RemoveEpisodeFromWatchHistory(selectedEpisode);
                TraktCache.RemoveEpisodeFromWatchHistory(selectedShow, selectedEpisode);
                selectedItem.IsPlayed = false;
                OnEpisodeSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddEpisodeToWatchList(selectedEpisode);
                TraktCache.AddEpisodeToWatchlist(selectedShow, selectedEpisode);
                OnEpisodeSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveEpisodeFromWatchList(selectedEpisode);
                OnEpisodeSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveEpisodeInUserList(selectedEpisode, false);
                break;

            case ((int)ContextMenuItem.Trailers):
                PreviousUser = CurrentUser;
                GUICommon.ShowTVShowTrailersMenu(selectedShow, selectedEpisode);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddEpisodeToCollection(selectedEpisode);
                TraktCache.AddEpisodeToCollection(selectedShow, selectedEpisode);
                OnEpisodeSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveEpisodeFromCollection(selectedEpisode);
                TraktCache.RemoveEpisodeFromCollection(selectedShow, selectedEpisode);
                OnEpisodeSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.Related):
                TraktHelper.ShowRelatedShows(selectedShow);
                break;

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateEpisode(selectedShow, selectedEpisode);
                OnEpisodeSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.Shouts):
                TraktHelper.ShowEpisodeShouts(selectedShow, selectedEpisode);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0} S{1}E{2}", selectedShow.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = string.Format("{0} S{1}E{2}", selectedShow.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
        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;
            List <TraktMovie.MovieImages> movieImages = new List <TraktMovie.MovieImages>();

            // Add each movie mark remote if not in collection
            foreach (var movie in movieList)
            {
                GUITraktRecommendedMovieListItem item = new GUITraktRecommendedMovieListItem(movie.Title);

                item.Label2 = movie.Year;
                item.TVTag  = movie;
                item.Item   = movie.Images;
                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       = "defaultVideo.png";
                item.IconImageBig    = "defaultVideoBig.png";
                item.ThumbnailImage  = "defaultVideoBig.png";
                item.OnItemSelected += OnMovieSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;

                // add image for download
                movieImages.Add(movie.Images);
            }

            // 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
            GetImages(movieImages);
        }
Ejemplo n.º 29
0
 private void ClearProperties()
 {
     GUIUtils.SetProperty("#Trakt.Episode.AddedDate", string.Empty);
     GUICommon.ClearEpisodeProperties();
     GUICommon.ClearShowProperties();
 }
Ejemplo n.º 30
0
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem as GUIShowListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedAnticipatedItem = selectedItem.TVTag as TraktShowAnticipated;

            if (selectedAnticipatedItem == null)
            {
                return;
            }

            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUICommon.CreateShowsContextMenu(ref dlg, selectedAnticipatedItem.Show, false);

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)MediaContextMenuItem.AddToWatchList):
                TraktHelper.AddShowToWatchList(selectedAnticipatedItem.Show);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.AnticipatedShowsHideWatchlisted)
                {
                    LoadAnticipatedShows(CurrentPage);
                }
                break;

            case ((int)MediaContextMenuItem.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedAnticipatedItem.Show.ToJSON());
                break;

            case ((int)MediaContextMenuItem.MarkAsWatched):
                GUICommon.MarkShowAsWatched(selectedAnticipatedItem.Show);
                LoadAnticipatedShows(CurrentPage);
                break;

            case ((int)MediaContextMenuItem.AddToLibrary):
                GUICommon.AddShowToCollection(selectedAnticipatedItem.Show);
                LoadAnticipatedShows(CurrentPage);
                break;

            case ((int)MediaContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveShowFromWatchList(selectedAnticipatedItem.Show);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)MediaContextMenuItem.AddToList):
                TraktHelper.AddRemoveShowInUserList(selectedAnticipatedItem.Show, false);
                break;

            case ((int)MediaContextMenuItem.Filters):
                if (GUICommon.ShowTVShowFiltersMenu())
                {
                    PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
                    UpdateButtonState();
                    LoadAnticipatedShows(CurrentPage);
                }
                break;

            case ((int)MediaContextMenuItem.Related):
                TraktHelper.ShowRelatedShows(selectedAnticipatedItem.Show);
                break;

            case ((int)MediaContextMenuItem.Cast):
                GUICreditsShow.Show   = selectedAnticipatedItem.Show;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Cast;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)MediaContextMenuItem.Crew):
                GUICreditsShow.Show   = selectedAnticipatedItem.Show;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Crew;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)MediaContextMenuItem.Trailers):
                GUICommon.ShowTVShowTrailersMenu(selectedAnticipatedItem.Show);
                break;

            case ((int)MediaContextMenuItem.Shouts):
                TraktHelper.ShowTVShowShouts(selectedAnticipatedItem.Show);
                break;

            case ((int)MediaContextMenuItem.Rate):
                GUICommon.RateShow(selectedAnticipatedItem.Show);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                LoadAnticipatedShows(CurrentPage);
                break;

            case ((int)MediaContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

            case ((int)MediaContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0}", selectedAnticipatedItem.Show.Title);
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)MediaContextMenuItem.SearchTorrent):
                string loadPar = selectedAnticipatedItem.Show.Title;
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }