Exemple #1
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedEpisodeSummary = selectedItem.TVTag as TraktEpisodeSummary;

            if (selectedEpisodeSummary == null)
            {
                return;
            }

            var selectedEpisode = selectedEpisodeSummary.Episode;

            if (selectedEpisode == null)
            {
                return;
            }

            var selectedShow = selectedEpisodeSummary.Show;

            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;

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

            if (!selectedEpisode.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;

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

            // Mark As UnWatched
            if (selectedEpisode.Watched)
            {
                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.InCollection && !TraktSettings.KeepTraktLibraryClean)
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }

            if (selectedEpisode.InCollection)
            {
                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.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 (!selectedEpisode.InCollection && TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for movie with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (!selectedEpisode.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.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON());
                break;

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

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

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

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

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

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

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

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveEpisodeFromLibrary(selectedShow, selectedEpisode);
                selectedEpisode.InCollection = false;
                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();
        }
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var userListItem = selectedItem.TVTag as TraktUserListItem;

            if (userListItem == 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 (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.episode)
            {
                // Mark As Watched
                if (!userListItem.Watched)
                {
                    listItem = new GUIListItem(Translation.MarkAsWatched);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
                }

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

            if (SelectedType != TraktItemType.season)
            {
                // Add/Remove Watch List
                if (!userListItem.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;

            // Remove from Custom list (Only if current user is the active user)
            if (TraktSettings.Username == CurrentUser)
            {
                listItem = new GUIListItem(Translation.RemoveFromList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromList;
            }

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

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

            // Related Movies/Shows
            listItem = new GUIListItem(SelectedType == TraktItemType.movie ? Translation.RelatedMovies : Translation.RelatedShows + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            if (SelectedType != TraktItemType.season)
            {
                // 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;
            }

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

            // Search with mpNZB
            if (TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                if ((userListItem.Movie != null && !userListItem.Movie.InCollection) || userListItem.Episode != null)
                {
                    listItem = new GUIListItem(Translation.SearchWithMpNZB);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
                }
            }

            // Search with MyTorrents
            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                if ((userListItem.Movie != null && !userListItem.Movie.InCollection) || userListItem.Episode != null)
                {
                    listItem = new GUIListItem(Translation.SearchTorrent);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
                }
            }

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

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.MarkAsWatched):
                MarkItemAsWatched(userListItem);
                if (userListItem.Plays == 0)
                {
                    userListItem.Plays = 1;
                }
                userListItem.Watched  = true;
                selectedItem.IsPlayed = true;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                MarkItemAsUnWatched(userListItem);
                userListItem.Watched  = false;
                selectedItem.IsPlayed = false;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                AddItemToWatchList(userListItem);
                userListItem.InWatchList = true;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveItemFromWatchList(userListItem);
                userListItem.InWatchList = false;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddToList):
                if (SelectedType == TraktItemType.movie)
                {
                    TraktHelper.AddRemoveMovieInUserList(userListItem.Title, userListItem.Year, userListItem.ImdbId, false);
                }
                else if (SelectedType == TraktItemType.show)
                {
                    TraktHelper.AddRemoveShowInUserList(userListItem.Title, userListItem.Year, userListItem.Show.Tvdb, false);
                }
                else if (SelectedType == TraktItemType.season)
                {
                    TraktHelper.AddRemoveSeasonInUserList(userListItem.Title, userListItem.Year, userListItem.SeasonNumber, userListItem.Show.Tvdb, false);
                }
                else if (SelectedType == TraktItemType.episode)
                {
                    TraktHelper.AddRemoveEpisodeInUserList(userListItem.Title, userListItem.Year, userListItem.SeasonNumber, userListItem.EpisodeNumber, userListItem.Show.Tvdb, false);
                }
                break;

            case ((int)ContextMenuItem.RemoveFromList):
                if (!GUIUtils.ShowYesNoDialog(Translation.DeleteListItem, Translation.ConfirmDeleteListItem))
                {
                    break;
                }

                // Only do remove from current list
                // We could do same as Add (ie remove from multile lists) but typically you only remove from the current list
                if (SelectedType == TraktItemType.movie)
                {
                    TraktListItem item = new TraktListItem {
                        Type = "movie", ImdbId = userListItem.ImdbId, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year)
                    };
                    TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true);
                }
                else if (SelectedType == TraktItemType.show)
                {
                    TraktListItem item = new TraktListItem {
                        Type = "show", TvdbId = userListItem.Show.Tvdb, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year)
                    };
                    TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true);
                }
                else if (SelectedType == TraktItemType.season)
                {
                    TraktListItem item = new TraktListItem {
                        Type = "season", TvdbId = userListItem.Show.Tvdb, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year), Season = Convert.ToInt32(userListItem.SeasonNumber)
                    };
                    TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true);
                }
                else if (SelectedType == TraktItemType.episode)
                {
                    TraktListItem item = new TraktListItem {
                        Type = "episode", TvdbId = userListItem.Show.Tvdb, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year), Season = Convert.ToInt32(userListItem.SeasonNumber), Episode = Convert.ToInt32(userListItem.EpisodeNumber)
                    };
                    TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true);
                }

                // Remove from view
                if (Facade.Count > 1)
                {
                    PreviousSelectedIndex = Facade.SelectedListItemIndex;
                    CurrentList.Items.Remove(userListItem);
                    SendListItemsToFacade(CurrentList);
                }
                else
                {
                    CurrentList.Items.Remove(userListItem);

                    // no more items left
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    ClearProperties();
                    GUIWindowManager.Process();

                    // nothing left, exit
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                AddItemToLibrary(userListItem);
                userListItem.InCollection = true;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                RemoveItemFromLibrary(userListItem);
                userListItem.InCollection = false;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                break;

            case ((int)ContextMenuItem.Related):
                if (SelectedType == TraktItemType.movie)
                {
                    RelatedMovie relatedMovie = new RelatedMovie();
                    relatedMovie.IMDbId           = userListItem.Movie.IMDBID;
                    relatedMovie.Title            = userListItem.Movie.Title;
                    GUIRelatedMovies.relatedMovie = relatedMovie;
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedMovies);
                }
                else
                {
                    //series, season & episode
                    RelatedShow relatedShow = new RelatedShow();
                    relatedShow.Title           = userListItem.Show.Title;
                    relatedShow.TVDbId          = userListItem.Show.Tvdb;
                    GUIRelatedShows.relatedShow = relatedShow;
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedShows);
                }
                break;

            case ((int)ContextMenuItem.Rate):
                RateItem(userListItem);
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                break;

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType = (GUIShouts.ShoutTypeEnum)Enum.Parse(typeof(GUIShouts.ShoutTypeEnum), SelectedType.ToString(), true);
                if (SelectedType == TraktItemType.movie)
                {
                    GUIShouts.MovieInfo = new MovieShout {
                        IMDbId = userListItem.ImdbId, TMDbId = userListItem.Movie.TMDBID, Title = userListItem.Title, Year = userListItem.Year
                    }
                }
                ;
                else if (SelectedType == TraktItemType.show)
                {
                    GUIShouts.ShowInfo = new ShowShout {
                        IMDbId = userListItem.ImdbId, TVDbId = userListItem.Show.Tvdb, Title = userListItem.Title
                    }
                }
                ;
                else
                {
                    GUIShouts.EpisodeInfo = new EpisodeShout {
                        IMDbId = userListItem.ImdbId, TVDbId = userListItem.Show.Tvdb, Title = userListItem.Title, SeasonIdx = userListItem.SeasonNumber, EpisodeIdx = userListItem.EpisodeNumber
                    }
                };
                GUIShouts.Fanart = SelectedType == TraktItemType.movie ? userListItem.Movie.Images.Fanart.LocalImageFilename(ArtworkType.MovieFanart) : userListItem.Show.Images.Fanart.LocalImageFilename(ArtworkType.ShowFanart);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

            case ((int)ContextMenuItem.Trailers):
                if (SelectedType == TraktItemType.movie)
                {
                    GUICommon.ShowMovieTrailersMenu(userListItem.Movie);
                }
                else if (SelectedType == TraktItemType.episode)
                {
                    userListItem.Episode.Season = Convert.ToInt32(userListItem.SeasonNumber);
                    userListItem.Episode.Number = Convert.ToInt32(userListItem.EpisodeNumber);

                    GUICommon.ShowTVShowTrailersMenu(userListItem.Show, userListItem.Episode);
                }
                else if (SelectedType == TraktItemType.season && TraktSettings.UseTrailersPlugin && TraktHelper.IsTrailersAvailableAndEnabled)
                {
                    GUICommon.ShowTVSeasonTrailersPluginMenu(userListItem.Show, int.Parse(userListItem.SeasonNumber));
                }
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = String.Empty;
                if (userListItem.Movie != null)
                {
                    loadingParam = string.Format("search:{0}", userListItem.Movie.Title);
                }
                else if (userListItem.Episode != null)
                {
                    loadingParam = string.Format("search:{0} S{1}E{2}", userListItem.Show.Title, userListItem.Episode.Season.ToString("D2"), userListItem.Episode.Number.ToString("D2"));
                }
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = String.Empty;
                if (userListItem.Movie != null)
                {
                    loadPar = userListItem.Movie.Title;
                }
                else if (userListItem.Episode != null)
                {
                    loadPar = string.Format("{0} S{1}E{2}", userListItem.Show.Title, userListItem.Episode.Season.ToString("D2"), userListItem.Episode.Number.ToString("D2"));
                }
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

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

            default:
                break;
            }

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

            if (selectedItem == null)
            {
                return;
            }

            var selectedListItem = selectedItem.TVTag as TraktListItem;

            if (selectedListItem == 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 (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.episode)
            {
                // Mark As Watched
                if (!selectedListItem.IsWatched())
                {
                    listItem = new GUIListItem(Translation.MarkAsWatched);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
                }

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

            if (SelectedType != TraktItemType.season && SelectedType != TraktItemType.person)
            {
                // Add/Remove Watchlist
                if (!selectedListItem.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;

            // Remove from Custom list (only if current user is the active user)
            if (TraktSettings.Username == CurrentUser)
            {
                listItem = new GUIListItem(Translation.RemoveFromList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromList;
            }

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

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

            // Related Movies/Shows
            if (SelectedType != TraktItemType.person)
            {
                listItem = new GUIListItem(SelectedType == TraktItemType.movie ? Translation.RelatedMovies : Translation.RelatedShows);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Related;
            }

            if (SelectedType != TraktItemType.season && SelectedType != TraktItemType.person)
            {
                // Rate
                listItem = new GUIListItem(Translation.Rate + "...");
                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
            if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.show)
            {
                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;
            }

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

            // Search with mpNZB
            if (TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                if ((selectedListItem.Movie != null && !selectedListItem.Movie.IsCollected()) || selectedListItem.Episode != null)
                {
                    listItem = new GUIListItem(Translation.SearchWithMpNZB);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
                }
            }

            // Search with MyTorrents
            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                if ((selectedListItem.Movie != null && !selectedListItem.Movie.IsCollected()) || selectedListItem.Episode != null)
                {
                    listItem = new GUIListItem(Translation.SearchTorrent);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
                }
            }

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

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.MarkAsWatched):
                AddItemToWatchedHistory(selectedListItem);
                selectedItem.IsPlayed = true;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                RemoveItemFromWatchedHistory(selectedListItem);
                selectedItem.IsPlayed = false;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                AddItemToWatchList(selectedListItem);
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }

                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveItemFromWatchList(selectedListItem);
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }

                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddToList):
                if (SelectedType == TraktItemType.movie)
                {
                    TraktHelper.AddRemoveMovieInUserList(selectedListItem.Movie, false);
                }
                else if (SelectedType == TraktItemType.show)
                {
                    TraktHelper.AddRemoveShowInUserList(selectedListItem.Show, false);
                }
                else if (SelectedType == TraktItemType.season)
                {
                    TraktHelper.AddRemoveSeasonInUserList(selectedListItem.Season, false);
                }
                else if (SelectedType == TraktItemType.episode)
                {
                    TraktHelper.AddRemoveEpisodeInUserList(selectedListItem.Episode, false);
                }
                else if (SelectedType == TraktItemType.person)
                {
                    TraktHelper.AddRemovePersonInUserList(selectedListItem.Person, false);
                }
                break;

            case ((int)ContextMenuItem.RemoveFromList):
                if (!GUIUtils.ShowYesNoDialog(Translation.DeleteListItem, Translation.ConfirmDeleteListItem))
                {
                    break;
                }

                // Only do remove from current list
                // We could do same as Add (ie remove from multiple lists) but typically you only remove from the current list
                TraktHelper.AddRemoveItemInList((int)CurrentList.Ids.Trakt, GetSyncItems(selectedListItem), true);

                // clear the list item cache
                TraktLists.ClearListItemCache(CurrentUser, CurrentList.Ids.Trakt.ToString());

                // remove item from collection
                CurrentListItems.RemoveAll(l => ListItemMatch(l, selectedListItem));

                // clear the cache
                TraktLists.ClearListItemCache(TraktSettings.Username, CurrentList.Ids.Trakt.ToString());

                // Remove from view
                if (Facade.Count > 1)
                {
                    PreviousSelectedIndex = Facade.SelectedListItemIndex;
                    SendListItemsToFacade(CurrentListItems);
                }
                else
                {
                    // no more items left
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    ClearProperties();
                    GUIWindowManager.Process();

                    // nothing left, exit
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                AddItemToCollection(selectedListItem);
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                RemoveItemFromCollection(selectedListItem);
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                break;

            case ((int)ContextMenuItem.Related):
                if (SelectedType == TraktItemType.movie)
                {
                    TraktHelper.ShowRelatedMovies(selectedListItem.Movie);
                }
                else
                {
                    //series, season & episode
                    TraktHelper.ShowRelatedShows(selectedListItem.Show);
                }
                break;

            case ((int)ContextMenuItem.Rate):
                RateItem(selectedListItem);
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster");
                }
                else
                {
                    (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster");
                }
                break;

            case ((int)ContextMenuItem.Shouts):
                if (SelectedType == TraktItemType.movie)
                {
                    TraktHelper.ShowMovieShouts(selectedListItem.Movie);
                }
                else if (SelectedType == TraktItemType.show)
                {
                    TraktHelper.ShowTVShowShouts(selectedListItem.Show);
                }
                else
                {
                    TraktHelper.ShowEpisodeShouts(selectedListItem.Show, selectedListItem.Episode);
                }
                break;

            case ((int)ContextMenuItem.Cast):
                if (SelectedType == TraktItemType.movie)
                {
                    GUICreditsMovie.Movie  = selectedListItem.Movie;
                    GUICreditsMovie.Type   = GUICreditsMovie.CreditType.Cast;
                    GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUICustomListItem).Images.MovieImages);
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie);
                }
                else if (SelectedType == TraktItemType.show)
                {
                    GUICreditsShow.Show   = selectedListItem.Show;
                    GUICreditsShow.Type   = GUICreditsShow.CreditType.Cast;
                    GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUICustomListItem).Images.ShowImages);
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                }
                break;

            case ((int)ContextMenuItem.Crew):
                if (SelectedType == TraktItemType.movie)
                {
                    GUICreditsMovie.Movie  = selectedListItem.Movie;
                    GUICreditsMovie.Type   = GUICreditsMovie.CreditType.Crew;
                    GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUICustomListItem).Images.MovieImages);
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie);
                }
                else if (SelectedType == TraktItemType.show)
                {
                    GUICreditsShow.Show   = selectedListItem.Show;
                    GUICreditsShow.Type   = GUICreditsShow.CreditType.Crew;
                    GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUICustomListItem).Images.ShowImages);
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                }
                break;

            case ((int)ContextMenuItem.Trailers):
                if (SelectedType == TraktItemType.movie)
                {
                    GUICommon.ShowMovieTrailersMenu(selectedListItem.Movie);
                }
                else if (SelectedType == TraktItemType.episode)
                {
                    GUICommon.ShowTVShowTrailersMenu(selectedListItem.Show, selectedListItem.Episode);
                }
                else if (SelectedType == TraktItemType.season && TraktHelper.IsTrailersAvailableAndEnabled)
                {
                    GUICommon.ShowTVSeasonTrailersPluginMenu(selectedListItem.Show, selectedListItem.Season.Number);
                }
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = String.Empty;
                if (selectedListItem.Movie != null)
                {
                    loadingParam = string.Format("search:{0}", selectedListItem.Movie.Title);
                }
                else if (selectedListItem.Episode != null)
                {
                    loadingParam = string.Format("search:{0} S{1}E{2}", selectedListItem.Show.Title, selectedListItem.Episode.Season.ToString("D2"), selectedListItem.Episode.Number.ToString("D2"));
                }
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = String.Empty;
                if (selectedListItem.Movie != null)
                {
                    loadPar = selectedListItem.Movie.Title;
                }
                else if (selectedListItem.Episode != null)
                {
                    loadPar = string.Format("{0} S{1}E{2}", selectedListItem.Show.Title, selectedListItem.Episode.Season.ToString("D2"), selectedListItem.Episode.Number.ToString("D2"));
                }
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

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

            default:
                break;
            }

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

            if (selectedItem == null)
            {
                return;
            }

            var selectedComment = selectedItem.TVTag as TraktCommentItem;

            if (selectedComment == 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;

            // Like or Unlike Comment
            if (CurrentUser != TraktSettings.Username)
            {
                // Like
                if (!selectedComment.Comment.IsLiked())
                {
                    listItem = new GUIListItem(Translation.Like);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ActivityContextMenuItem.Like;
                }
                else
                {
                    // UnLike
                    listItem = new GUIListItem(Translation.UnLike);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ActivityContextMenuItem.Unlike;
                }
            }

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

            // if selected activity is an episode or show, add 'Season Info'
            if (selectedComment.Show != null)
            {
                listItem = new GUIListItem(Translation.ShowSeasonInfo);
                dlg.Add(listItem);
                listItem.ItemId = (int)ActivityContextMenuItem.ShowSeasonInfo;
            }

            // get a list of common actions to perform on the selected item
            if (selectedComment.Movie != null || selectedComment.Show != null)
            {
                var listItems = GetContextMenuItemsForComment(selectedComment);
                foreach (var item in listItems)
                {
                    int itemId = item.ItemId;
                    dlg.Add(item);
                    item.ItemId = itemId;
                }
            }

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

            switch (dlg.SelectedId)
            {
            case (int)ActivityContextMenuItem.Like:
                GUICommon.LikeComment(selectedComment.Comment);
                selectedComment.Comment.Likes++;
                PublishCommentSkinProperties(selectedComment);
                break;

            case (int)ActivityContextMenuItem.Unlike:
                GUICommon.UnLikeComment(selectedComment.Comment);
                if (selectedComment.Comment.Likes > 0)
                {
                    selectedComment.Comment.Likes--;
                    PublishCommentSkinProperties(selectedComment);
                }
                break;

            case ((int)ActivityContextMenuItem.Spoilers):
                TraktSettings.HideSpoilersOnShouts = !TraktSettings.HideSpoilersOnShouts;
                if (hideSpoilersButton != null)
                {
                    hideSpoilersButton.Selected = TraktSettings.HideSpoilersOnShouts;
                }
                PublishCommentSkinProperties(selectedComment);
                break;

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

            case ((int)ActivityContextMenuItem.AddToList):
                if (selectedComment.Movie != null)
                {
                    TraktHelper.AddRemoveMovieInUserList(selectedComment.Movie, false);
                }
                else if (selectedComment.Episode != null)
                {
                    TraktHelper.AddRemoveEpisodeInUserList(selectedComment.Episode, false);
                }
                else
                {
                    TraktHelper.AddRemoveShowInUserList(selectedComment.Show, false);
                }
                break;

            case ((int)ActivityContextMenuItem.AddToWatchList):
                if (selectedComment.Movie != null)
                {
                    TraktHelper.AddMovieToWatchList(selectedComment.Movie, true);
                }
                else if (selectedComment.Episode != null)
                {
                    TraktHelper.AddEpisodeToWatchList(selectedComment.Episode);
                }
                else
                {
                    TraktHelper.AddShowToWatchList(selectedComment.Show);
                }
                break;

            case ((int)ActivityContextMenuItem.Shouts):
                if (selectedComment.Movie != null)
                {
                    TraktHelper.ShowMovieShouts(selectedComment.Movie);
                }
                else if (selectedComment.Episode != null)
                {
                    TraktHelper.ShowEpisodeShouts(selectedComment.Show, selectedComment.Episode);
                }
                else
                {
                    TraktHelper.ShowTVShowShouts(selectedComment.Show);
                }
                break;

            case ((int)ActivityContextMenuItem.Rate):
                if (selectedComment.Movie != null)
                {
                    GUICommon.RateMovie(selectedComment.Movie);
                }
                else if (selectedComment.Episode != null)
                {
                    GUICommon.RateEpisode(selectedComment.Show, selectedComment.Episode);
                }
                else
                {
                    GUICommon.RateShow(selectedComment.Show);
                }
                break;

            case ((int)ActivityContextMenuItem.Cast):
                if (selectedComment.Movie != null)
                {
                    GUICreditsMovie.Movie  = selectedComment.Movie;
                    GUICreditsMovie.Type   = GUICreditsMovie.CreditType.Cast;
                    GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUIMovieListItem).Images.MovieImages);
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie);
                }
                else if (selectedComment.Show != null)
                {
                    GUICreditsShow.Show   = selectedComment.Show;
                    GUICreditsShow.Type   = GUICreditsShow.CreditType.Cast;
                    GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUIShowListItem).Images.ShowImages);
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                }
                break;

            case ((int)ActivityContextMenuItem.Crew):
                if (selectedComment.Movie != null)
                {
                    GUICreditsMovie.Movie  = selectedComment.Movie;
                    GUICreditsMovie.Type   = GUICreditsMovie.CreditType.Crew;
                    GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUIMovieListItem).Images.MovieImages);
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie);
                }
                else if (selectedComment.Show != null)
                {
                    GUICreditsShow.Show   = selectedComment.Show;
                    GUICreditsShow.Type   = GUICreditsShow.CreditType.Crew;
                    GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUIShowListItem).Images.ShowImages);
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                }
                break;

            case ((int)ActivityContextMenuItem.Trailers):
                if (selectedComment.Movie != null)
                {
                    GUICommon.ShowMovieTrailersMenu(selectedComment.Movie);
                }
                else
                {
                    GUICommon.ShowTVShowTrailersMenu(selectedComment.Show, selectedComment.Episode);
                }
                break;
            }

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

            if (selectedItem == null)
            {
                return;
            }

            var selectedEpisodeSummary = selectedItem.TVTag as TraktEpisodeSummary;

            if (selectedEpisodeSummary == null)
            {
                return;
            }

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

            var 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):
                TraktHelper.MarkEpisodeAsWatched(Show, selectedEpisode);
                selectedEpisode.Watched          = true;
                Facade.SelectedListItem.IsPlayed = true;
                if (selectedEpisode.Plays == 0)
                {
                    selectedEpisode.Plays = 1;
                }
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                TraktHelper.MarkEpisodeAsUnWatched(Show, selectedEpisode);
                selectedEpisode.Watched          = false;
                Facade.SelectedListItem.IsPlayed = false;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddEpisodeToLibrary(Show, selectedEpisode);
                selectedEpisode.InCollection = true;
                OnEpisodeSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveEpisodeFromLibrary(Show, selectedEpisode);
                selectedEpisode.InCollection = false;
                OnEpisodeSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddEpisodeToWatchList(Show, selectedEpisode);
                selectedEpisode.InWatchList = true;
                OnEpisodeSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

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

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateEpisode(Show, selectedEpisode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                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):
                TraktHelper.ShowEpisodeShouts(Show, 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}", 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();
        }
        protected override void OnShowContextMenu()
        {
            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

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

            var episodeItem = Facade.SelectedListItem.TVTag as TraktEpisodeSummary;

            if (episodeItem == null)
            {
                return;
            }

            // Create Views Menu Item
            GUIListItem 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;

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

            // 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 (!episodeItem.Episode.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
            }

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

            // Add/Remove Show Watch List
            if (!episodeItem.Show.InWatchList)
            {
                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 Watch List
            if (!episodeItem.Episode.InWatchList)
            {
                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.Shouts + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            // Add/Remove Libary
            if (!episodeItem.Episode.InCollection)
            {
                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;
            }

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

            // Watch List Filter
            if (CurrentCalendar == CalendarType.MyShows)
            {
                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.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, episodeItem.Show.ToJSON());
                break;

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

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

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

            case ((int)ContextMenuItem.MarkAsWatched):
                TraktHelper.MarkEpisodeAsWatched(episodeItem.Show, episodeItem.Episode);
                episodeItem.Episode.Watched      = true;
                Facade.SelectedListItem.IsPlayed = true;
                if (episodeItem.Episode.Plays == 0)
                {
                    episodeItem.Episode.Plays = 1;
                }
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

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

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

            case ((int)ContextMenuItem.AddEpisodeToWatchList):
                TraktHelper.AddEpisodeToWatchList(episodeItem.Show, episodeItem.Episode);
                episodeItem.Episode.InWatchList = true;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

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

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

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

            case ((int)ContextMenuItem.AddShowToList):
                TraktHelper.AddRemoveShowInUserList(episodeItem.Show.Title, episodeItem.Show.Year.ToString(), episodeItem.Show.Tvdb, false);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddEpisodeToLibrary(episodeItem.Show, episodeItem.Episode);
                episodeItem.Episode.InCollection = true;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveEpisodeFromLibrary(episodeItem.Show, episodeItem.Episode);
                episodeItem.Episode.InCollection = false;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
        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();
        }
Exemple #8
0
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedActivity = selectedItem.TVTag as TraktActivity.Activity;

            if (selectedActivity == null)
            {
                return;
            }

            var type = (ActivityType)Enum.Parse(typeof(ActivityType), selectedActivity.Type);

            var 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(TraktSettings.HideSpoilersOnShouts ? Translation.ShowSpoilers : Translation.HideSpoilers);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Spoilers;

            // if selected activity is an episode or show, add 'Season Info'
            if (selectedActivity.Show != null)
            {
                listItem = new GUIListItem(Translation.ShowSeasonInfo);
                dlg.Add(listItem);
                listItem.ItemId = (int)ActivityContextMenuItem.ShowSeasonInfo;
            }

            // get a list of common actions to perform on the selected item
            if (selectedActivity.Movie != null || selectedActivity.Show != null)
            {
                var listItems = GUICommon.GetContextMenuItemsForActivity();
                foreach (var item in listItems)
                {
                    int itemId = item.ItemId;
                    dlg.Add(item);
                    item.ItemId = itemId;
                }
            }

            // 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(selectedActivity);
                break;

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

            case ((int)ActivityContextMenuItem.AddToList):
                if (selectedActivity.Movie != null)
                {
                    TraktHelper.AddRemoveMovieInUserList(selectedActivity.Movie, false);
                }
                else if (selectedActivity.Episode != null)
                {
                    TraktHelper.AddRemoveEpisodeInUserList(selectedActivity.Show, selectedActivity.Episode, false);
                }
                else
                {
                    TraktHelper.AddRemoveShowInUserList(selectedActivity.Show, false);
                }
                break;

            case ((int)ActivityContextMenuItem.AddToWatchList):
                if (selectedActivity.Movie != null)
                {
                    TraktHelper.AddMovieToWatchList(selectedActivity.Movie, true);
                }
                else if (selectedActivity.Episode != null)
                {
                    TraktHelper.AddEpisodeToWatchList(selectedActivity.Show, selectedActivity.Episode);
                }
                else
                {
                    TraktHelper.AddShowToWatchList(selectedActivity.Show);
                }
                break;

            case ((int)ActivityContextMenuItem.Shouts):
                if (selectedActivity.Movie != null)
                {
                    TraktHelper.ShowMovieShouts(selectedActivity.Movie);
                }
                else if (selectedActivity.Episode != null)
                {
                    TraktHelper.ShowEpisodeShouts(selectedActivity.Show, selectedActivity.Episode);
                }
                else
                {
                    TraktHelper.ShowTVShowShouts(selectedActivity.Show);
                }
                break;

            case ((int)ActivityContextMenuItem.Rate):
                if (selectedActivity.Movie != null)
                {
                    GUICommon.RateMovie(selectedActivity.Movie);
                }
                else if (selectedActivity.Episode != null)
                {
                    GUICommon.RateEpisode(selectedActivity.Show, selectedActivity.Episode);
                }
                else
                {
                    GUICommon.RateShow(selectedActivity.Show);
                }
                break;

            case ((int)ActivityContextMenuItem.Trailers):
                if (selectedActivity.Movie != null)
                {
                    GUICommon.ShowMovieTrailersMenu(selectedActivity.Movie);
                }
                else
                {
                    GUICommon.ShowTVShowTrailersMenu(selectedActivity.Show, selectedActivity.Episode);
                }
                break;
            }

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

            if (selectedItem == null)
            {
                return;
            }

            var item            = (KeyValuePair <TraktShow, TraktWatchListEpisode.Episode>)selectedItem.TVTag;
            var selectedSeries  = item.Key;
            var selectedEpisode = item.Value;

            IDialogbox 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.IsOnlineVideosAvailableAndEnabled)
            {
                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.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.RemoveFromWatchList):
                RemovingWatchListItem = true;
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                RemoveEpisodeFromWatchList(item);
                if (this.Facade.Count >= 1)
                {
                    // remove from list
                    _WatchListEpisodes = null;
                    userWatchList.Remove(CurrentUser);
                    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(selectedSeries.Title, selectedSeries.Year.ToString(), selectedEpisode.Season.ToString(), selectedEpisode.Number.ToString(), selectedSeries.Tvdb, false);
                break;

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

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType   = GUIShouts.ShoutTypeEnum.episode;
                GUIShouts.EpisodeInfo = new EpisodeShout
                {
                    TVDbId     = selectedSeries.Tvdb,
                    IMDbId     = selectedSeries.Imdb,
                    Title      = selectedSeries.Title,
                    SeasonIdx  = selectedEpisode.Season.ToString(),
                    EpisodeIdx = selectedEpisode.Number.ToString()
                };
                GUIShouts.Fanart = selectedSeries.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}", selectedSeries.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}", selectedSeries.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Exemple #10
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();
        }