コード例 #1
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktTrendingShow selectedShow = (TraktTrendingShow)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUICommon.CreateTrendingShowsContextMenu(ref dlg, selectedShow, false);

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

            switch (dlg.SelectedId)
            {
            case ((int)TrendingContextMenuItem.AddToWatchList):
                TraktHelper.AddShowToWatchList(selectedShow);
                selectedShow.InWatchList = true;
                OnShowSelected(selectedItem, Facade);
                selectedShow.Images.NotifyPropertyChanged("PosterImageFilename");
                if (TraktSettings.TrendingShowsHideWatchlisted)
                {
                    LoadTrendingShows();
                }
                break;

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

            case ((int)TrendingContextMenuItem.MarkAsWatched):
                GUICommon.MarkShowAsSeen(selectedShow);
                if (TraktSettings.TrendingShowsHideWatched)
                {
                    LoadTrendingShows();
                }
                break;

            case ((int)TrendingContextMenuItem.AddToLibrary):
                GUICommon.AddShowToLibrary(selectedShow);
                if (TraktSettings.TrendingShowsHideCollected)
                {
                    LoadTrendingShows();
                }
                break;

            case ((int)TrendingContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveShowFromWatchList(selectedShow);
                selectedShow.InWatchList = false;
                OnShowSelected(selectedItem, Facade);
                selectedShow.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

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

            case ((int)TrendingContextMenuItem.Filters):
                if (GUICommon.ShowTVShowFiltersMenu())
                {
                    UpdateButtonState();
                    LoadTrendingShows();
                }
                break;

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

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

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

            case ((int)TrendingContextMenuItem.Rate):
                GUICommon.RateShow(selectedShow);
                OnShowSelected(selectedItem, Facade);
                selectedShow.Images.NotifyPropertyChanged("PosterImageFilename");
                if (TraktSettings.TrendingShowsHideRated)
                {
                    LoadTrendingShows();
                }
                break;

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

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }