private void RemoveItemFromWatchList(TraktListItem item)
 {
     if (SelectedType == TraktItemType.movie)
     {
         TraktHelper.RemoveMovieFromWatchList(item.Movie, true);
     }
     else if (SelectedType == TraktItemType.show)
     {
         TraktHelper.RemoveShowFromWatchList(item.Show);
     }
     else if (SelectedType == TraktItemType.episode)
     {
         TraktHelper.RemoveEpisodeFromWatchList(item.Episode);
     }
 }
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedMovie = selectedItem.TVTag as TraktWatchListMovie;

            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;

            // only allow removal if viewing your own watch list
            if (CurrentUser == TraktSettings.Username)
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }
            else if (!selectedMovie.InWatchList)
            {
                // viewing someone else's watch list 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 (!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 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.MarkAsWatched):
                TraktHelper.MarkMovieAsWatched(selectedMovie);
                if (CurrentUser != TraktSettings.Username)
                {
                    if (selectedMovie.Plays == 0)
                    {
                        selectedMovie.Plays = 1;
                    }
                    selectedMovie.Watched = true;
                    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 watch list
                    // we should do the same in GUI
                    PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                    if (_WatchListMovies.Count() >= 1)
                    {
                        // remove from list
                        var moviesToExcept = new List <TraktWatchListMovie>();
                        moviesToExcept.Add(selectedMovie);
                        _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.MarkMovieAsUnWatched(selectedMovie);
                selectedMovie.Watched = false;
                selectedItem.IsPlayed = false;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

            case ((int)ContextMenuItem.RemoveFromWatchList):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                TraktHelper.RemoveMovieFromWatchList(selectedMovie, true);
                if (_WatchListMovies.Count() >= 1)
                {
                    // remove from list
                    var moviesToExcept = new List <TraktWatchListMovie>();
                    moviesToExcept.Add(selectedMovie);
                    _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(selectedMovie.Title, selectedMovie.Year, selectedMovie.IMDBID, false);
                break;

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

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

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromLibrary(selectedMovie);
                selectedMovie.InCollection = false;
                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(selectedMovie);
                break;

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateMovie(selectedMovie);
                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(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 dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

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

            var selectedItem = Facade.SelectedListItem as GUIMovieListItem;

            if (selectedItem == null)
            {
                return;
            }

            var calendarItem = selectedItem.TVTag as TraktMovieCalendar;

            if (calendarItem == null)
            {
                return;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            case ((int)ContextMenuItem.HideMovie):
                TraktHelper.AddHiddenMovie(calendarItem.Movie, "calendar");
                FilterHiddenMovies = true;
                LoadCalendar();
                break;

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

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

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

            case ((int)ContextMenuItem.MarkAsWatched):
                TraktHelper.AddMovieToWatchHistory(calendarItem.Movie);
                Facade.SelectedListItem.IsPlayed = true;
                OnMovieSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

            case ((int)ContextMenuItem.AddMovieToWatchlist):
                TraktHelper.AddMovieToWatchList(calendarItem.Movie, true);
                OnMovieSelected(Facade.SelectedListItem, Facade);
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveMovieFromWatchlist):
                TraktHelper.RemoveMovieFromWatchList(calendarItem.Movie, true);
                OnMovieSelected(Facade.SelectedListItem, Facade);
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddMovieToList):
                TraktHelper.AddRemoveMovieInUserList(calendarItem.Movie, false);
                break;

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

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

            case ((int)ContextMenuItem.Cast):
                GUICreditsMovie.Movie  = calendarItem.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  = calendarItem.Movie;
                GUICreditsMovie.Type   = GUICreditsMovie.CreditType.Crew;
                GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie);
                break;

            case ((int)ContextMenuItem.Trailers):
                if (calendarItem != null)
                {
                    GUICommon.ShowMovieTrailersMenu(calendarItem.Movie);
                }
                break;

            default:
                break;
            }

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

            if (selectedItem == null)
            {
                return;
            }

            var selectedPopularMovie = selectedItem.TVTag as TraktMovieSummary;

            if (selectedPopularMovie == 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, selectedPopularMovie, false);

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

            switch (dlg.SelectedId)
            {
            case ((int)MediaContextMenuItem.MarkAsWatched):
                TraktHelper.AddMovieToWatchHistory(selectedPopularMovie);
                selectedItem.IsPlayed = true;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.PopularMoviesHideWatched)
                {
                    LoadPopularMovies(CurrentPage);
                }
                break;

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

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

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

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

            case ((int)MediaContextMenuItem.AddToLibrary):
                TraktHelper.AddMovieToCollection(selectedPopularMovie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.PopularMoviesHideCollected)
                {
                    LoadPopularMovies(CurrentPage);
                }
                break;

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

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

            case ((int)MediaContextMenuItem.Rate):
                GUICommon.RateMovie(selectedPopularMovie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.PopularMoviesHideRated)
                {
                    LoadPopularMovies(CurrentPage);
                }
                break;

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

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

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

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

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

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

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

            case ((int)MediaContextMenuItem.SearchTorrent):
                string loadParm = selectedPopularMovie.Title;
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadParm);
                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.Movie;

            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;

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

            if (selectedItem == null)
            {
                return;
            }

            var selectedMovie = selectedItem.TVTag as TraktMovie;

            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;

            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;

            // 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 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.MarkAsWatched):
                TraktHelper.MarkMovieAsWatched(selectedMovie);
                if (selectedMovie.Plays == 0)
                {
                    selectedMovie.Plays = 1;
                }
                selectedMovie.Watched = true;
                selectedItem.IsPlayed = true;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

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

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

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

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

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

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromLibrary(selectedMovie);
                selectedMovie.InCollection = false;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                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):
                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();
        }
Ejemplo n.º 7
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();
        }
        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;
                TraktHelper.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):
                TraktHelper.AddMovieToWatchList(selectedMovie, true);
                selectedMovie.InWatchList = true;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

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

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

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

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromLibrary(selectedMovie);
                selectedMovie.InCollection = false;
                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.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):
                TraktHelper.ShowMovieShouts(selectedMovie);
                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();
        }