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(); }