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();
        }
Beispiel #2
0
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedAnticipatedItem = selectedItem.TVTag as TraktMovieAnticipated;

            if (selectedAnticipatedItem == null)
            {
                return;
            }

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

            if (dlg == null)
            {
                return;
            }

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

            GUICommon.CreateMoviesContextMenu(ref dlg, selectedAnticipatedItem.Movie, false);

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

            switch (dlg.SelectedId)
            {
            case ((int)MediaContextMenuItem.MarkAsWatched):
                TraktHelper.AddMovieToWatchHistory(selectedAnticipatedItem.Movie);
                selectedItem.IsPlayed = true;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                LoadAnticipatedMovies(CurrentPage);
                break;

            case ((int)MediaContextMenuItem.MarkAsUnWatched):
                TraktHelper.RemoveMovieFromWatchHistory(selectedAnticipatedItem.Movie);
                selectedItem.IsPlayed = false;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)MediaContextMenuItem.AddToWatchList):
                TraktHelper.AddMovieToWatchList(selectedAnticipatedItem.Movie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.AnticipatedMoviesHideWatchlisted)
                {
                    LoadAnticipatedMovies(CurrentPage);
                }
                break;

            case ((int)MediaContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveMovieFromWatchList(selectedAnticipatedItem.Movie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

            case ((int)MediaContextMenuItem.AddToLibrary):
                TraktHelper.AddMovieToCollection(selectedAnticipatedItem.Movie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                LoadAnticipatedMovies(CurrentPage);
                break;

            case ((int)MediaContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromCollection(selectedAnticipatedItem.Movie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

            case ((int)MediaContextMenuItem.Rate):
                GUICommon.RateMovie(selectedAnticipatedItem.Movie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                LoadAnticipatedMovies(CurrentPage);
                break;

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

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

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

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

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

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

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

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

            default:
                break;
            }

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

            if (selectedItem == null)
            {
                return;
            }

            var selectedMovie = selectedItem.TVTag as TraktMovieSummary;

            if (selectedMovie == 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 (!selectedMovie.IsWatchlisted())
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

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

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

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

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

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

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

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

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

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

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

            if (!selectedMovie.IsCollected() && 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.MarkAsWatched):
                TraktHelper.AddMovieToWatchHistory(selectedMovie);
                selectedItem.IsPlayed = true;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                TraktHelper.RemoveMovieFromWatchHistory(selectedMovie);
                selectedItem.IsPlayed = false;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddMovieToWatchList(selectedMovie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveMovieFromWatchList(selectedMovie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

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

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddMovieToCollection(selectedMovie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromCollection(selectedMovie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

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

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

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

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

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

            default:
                break;
            }

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

            if (selectedItem == null)
            {
                return;
            }

            var selectedMovie = selectedItem.TVTag as TraktMovieSummary;

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

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

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

            // Add/Remove Watchlist
            if (!selectedMovie.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;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddMovieToWatchList(selectedMovie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveMovieFromWatchList(selectedMovie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddMovieToCollection(selectedMovie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromCollection(selectedMovie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

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

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

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

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

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

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

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Beispiel #5
0
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedWatchlistItem = selectedItem.TVTag as TraktMovieWatchList;

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

            // only allow removal if viewing your own watchlist
            if (CurrentUser == TraktSettings.Username)
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }
            else if (!selectedWatchlistItem.Movie.IsWatchlisted())
            {
                // viewing someone else's watchlist and not in yours
                listItem = new GUIListItem(Translation.AddToWatchList);
                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;

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

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

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

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

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

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

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

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

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

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

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

            if (!selectedWatchlistItem.Movie.IsCollected() && 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.MarkAsWatched):
                TraktHelper.AddMovieToWatchHistory(selectedWatchlistItem.Movie);
                if (CurrentUser != TraktSettings.Username)
                {
                    selectedItem.IsPlayed = true;
                    OnMovieSelected(selectedItem, Facade);
                    (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                    GUIWatchListMovies.ClearCache(TraktSettings.Username);
                }
                else
                {
                    // when marking a movie as seen via API, it will remove from watchlist
                    // we should do the same in GUI
                    PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                    if (_WatchListMovies.Count() >= 1)
                    {
                        // remove from list
                        var moviesToExcept = new List <TraktMovieWatchList>();
                        moviesToExcept.Add(selectedWatchlistItem);
                        _WatchListMovies           = WatchListMovies.Except(moviesToExcept);
                        userWatchList[CurrentUser] = _WatchListMovies;
                        LoadWatchListMovies();
                    }
                    else
                    {
                        // no more movies left
                        ClearProperties();
                        GUIControl.ClearControl(GetID, Facade.GetID);
                        _WatchListMovies = null;
                        userWatchList.Remove(CurrentUser);
                        // notify and exit
                        GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoMovieWatchList);
                        GUIWindowManager.ShowPreviousWindow();
                        return;
                    }
                }
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                TraktHelper.RemoveMovieFromWatchHistory(selectedWatchlistItem.Movie);
                selectedItem.IsPlayed = false;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddMovieToWatchList(selectedWatchlistItem.Movie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                TraktHelper.RemoveMovieFromWatchList(selectedWatchlistItem.Movie, true);
                if (_WatchListMovies.Count() >= 1)
                {
                    // remove from list
                    var moviesToExcept = new List <TraktMovieWatchList>();
                    moviesToExcept.Add(selectedWatchlistItem);
                    _WatchListMovies           = WatchListMovies.Except(moviesToExcept);
                    userWatchList[CurrentUser] = _WatchListMovies;
                    LoadWatchListMovies();
                }
                else
                {
                    // no more movies left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _WatchListMovies = null;
                    userWatchList.Remove(CurrentUser);
                    // notify and exit
                    GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoMovieWatchList);
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveMovieInUserList(selectedWatchlistItem.Movie, false);
                break;

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

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddMovieToCollection(selectedWatchlistItem.Movie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                if (CurrentUser != TraktSettings.Username)
                {
                    GUIWatchListMovies.ClearCache(TraktSettings.Username);
                }
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromCollection(selectedWatchlistItem.Movie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                if (CurrentUser != TraktSettings.Username)
                {
                    GUIWatchListMovies.ClearCache(TraktSettings.Username);
                }
                break;

            case ((int)ContextMenuItem.Related):
                TraktHelper.ShowRelatedMovies(selectedWatchlistItem.Movie);
                break;

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateMovie(selectedWatchlistItem.Movie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                if (CurrentUser != TraktSettings.Username)
                {
                    GUIWatchListMovies.ClearCache(TraktSettings.Username);
                }
                break;

            case ((int)ContextMenuItem.Shouts):
                TraktHelper.ShowMovieShouts(selectedWatchlistItem.Movie);
                break;

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

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

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

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Beispiel #6
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();
        }
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktUserListItem userListItem = (TraktUserListItem)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

            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)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                MarkItemAsUnWatched(userListItem);
                userListItem.Watched  = false;
                selectedItem.IsPlayed = false;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                break;

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

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveItemFromWatchList(userListItem);
                userListItem.InWatchList = false;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                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)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                RemoveItemFromLibrary(userListItem);
                userListItem.InCollection = false;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                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)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                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.Images as TraktMovie.MovieImages).FanartImageFilename : (userListItem.Images as TraktShow.ShowImages).FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

            case ((int)ContextMenuItem.Trailers):
                if (SelectedType == TraktItemType.movie)
                {
                    GUICommon.ShowMovieTrailersMenu(userListItem.Movie);
                }
                else
                {
                    GUICommon.ShowTVShowTrailersMenu(userListItem.Show, userListItem.Episode);
                }
                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);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedMovie = selectedItem.TVTag as TraktMovieSummary;

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

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

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

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

            // Add/Remove Watchlist
            if (!selectedMovie.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;

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

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

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

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

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

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

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

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

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

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

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

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

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

            case ((int)ContextMenuItem.MarkAsWatched):
                TraktHelper.AddMovieToWatchHistory(selectedMovie);
                if (!HideWatched)
                {
                    selectedItem.IsPlayed = true;
                    OnMovieSelected(selectedItem, Facade);
                    (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                }
                else
                {
                    dictRelatedMovies.Remove(relatedMovie.Slug);
                    LoadRelatedMovies();
                }
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                TraktHelper.RemoveMovieFromWatchHistory(selectedMovie);
                selectedItem.IsPlayed = false;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddMovieToWatchList(selectedMovie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveMovieFromWatchList(selectedMovie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddMovieToCollection(selectedMovie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromCollection(selectedMovie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.Related):
                var relMovie = new RelatedMovie
                {
                    Title   = selectedMovie.Title,
                    Year    = selectedMovie.Year,
                    TraktId = selectedMovie.Ids.Trakt,
                    TmdbId  = selectedMovie.Ids.Tmdb,
                    ImdbId  = selectedMovie.Ids.Imdb
                };
                relatedMovie = relMovie;
                GUIUtils.SetProperty("#Trakt.Related.Movie", relMovie.Title);
                LoadRelatedMovies();
                RelationChanged = true;
                break;

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

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

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

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

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

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

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

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

            default:
                break;
            }

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

            if (selectedItem == null)
            {
                return;
            }

            TraktTrendingMovie selectedMovie = (TraktTrendingMovie)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

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

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

            switch (dlg.SelectedId)
            {
            case ((int)TrendingContextMenuItem.MarkAsWatched):
                TraktHelper.MarkMovieAsWatched(selectedMovie);
                if (selectedMovie.Plays == 0)
                {
                    selectedMovie.Plays = 1;
                }
                selectedMovie.Watched = true;
                selectedItem.IsPlayed = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                if (TraktSettings.TrendingMoviesHideWatched)
                {
                    LoadTrendingMovies();
                }
                break;

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

            case ((int)TrendingContextMenuItem.AddToWatchList):
                TraktHelper.AddMovieToWatchList(selectedMovie, true);
                selectedMovie.InWatchList = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                if (TraktSettings.TrendingMoviesHideWatchlisted)
                {
                    LoadTrendingMovies();
                }
                break;

            case ((int)TrendingContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveMovieFromWatchList(selectedMovie, true);
                selectedMovie.InWatchList = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

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

            case ((int)TrendingContextMenuItem.AddToLibrary):
                TraktHelper.AddMovieToLibrary(selectedMovie);
                selectedMovie.InCollection = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                if (TraktSettings.TrendingMoviesHideCollected)
                {
                    LoadTrendingMovies();
                }
                break;

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

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

            case ((int)TrendingContextMenuItem.Rate):
                GUICommon.RateMovie(selectedMovie);
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                if (TraktSettings.TrendingMoviesHideRated)
                {
                    LoadTrendingMovies();
                }
                break;

            case ((int)TrendingContextMenuItem.Filters):
                if (GUICommon.ShowMovieFiltersMenu())
                {
                    UpdateButtonState();
                    LoadTrendingMovies();
                }
                break;

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

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

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

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Beispiel #10
0
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktMovie selectedMovie = (TraktMovie)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            default:
                break;
            }

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

            if (selectedItem == null)
            {
                return;
            }

            TraktMovie selectedMovie = (TraktMovie)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
        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 GUIMovieListItem).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 GUIShowListItem).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 GUIMovieListItem).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 GUIShowListItem).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();
        }