protected override void OnShowContextMenu() { IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return; dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); TraktCalendar.TraktEpisodes episodeItem = Facade.SelectedListItem.TVTag as TraktCalendar.TraktEpisodes; if (episodeItem == null) return; // Create Views Menu Item GUIListItem listItem = new GUIListItem(Translation.ChangeView); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.View; // Start Date listItem = new GUIListItem(Translation.StartDate + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.StartDate; // Related Shows listItem = new GUIListItem(Translation.RelatedShows + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate listItem = new GUIListItem(Translation.Rate + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Mark As Watched if (!episodeItem.Episode.Watched) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (episodeItem.Episode.Watched) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } // Add/Remove Show Watch List if (!episodeItem.Show.InWatchList) { listItem = new GUIListItem(Translation.AddShowToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddShowToWatchList; } else { listItem = new GUIListItem(Translation.RemoveShowFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveShowFromWatchList; } // Add/Remove Episode Watch List if (!episodeItem.Episode.InWatchList) { listItem = new GUIListItem(Translation.AddEpisodeToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddEpisodeToWatchList; } else { listItem = new GUIListItem(Translation.RemoveEpisodeFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveEpisodeFromWatchList; } // Add Show to Custom List listItem = new GUIListItem(Translation.AddShowToList + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddShowToList; // Add Episode to Custom List listItem = new GUIListItem(Translation.AddEpisodeToList + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddEpisodeToList; // Shouts listItem = new GUIListItem(Translation.Shouts + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Add/Remove Libary if (!episodeItem.Episode.InCollection) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } else { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } if (TraktHelper.IsOnlineVideosAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Watch List Filter if (CurrentCalendar == CalendarType.MyShows) { if (TraktSettings.CalendarHideTVShowsInWatchList) listItem = new GUIListItem(Translation.ShowTVShowsInWatchlist); else listItem = new GUIListItem(Translation.HideTVShowsInWatchlist); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.WatchlistFilter; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) return; switch (dlg.SelectedId) { case ((int)ContextMenuItem.View): ShowViewMenu(); break; case ((int)ContextMenuItem.StartDate): ShowStartDateMenu(); break; case ((int)ContextMenuItem.Related): RelatedShow relatedShow = new RelatedShow(); relatedShow.Title = episodeItem.Show.Title; relatedShow.TVDbId = episodeItem.Show.Tvdb; GUIRelatedShows.relatedShow = relatedShow; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedShows); break; case ((int)ContextMenuItem.Shouts): GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.episode; GUIShouts.EpisodeInfo = new EpisodeShout { TVDbId = episodeItem.Show.Tvdb, IMDbId = episodeItem.Show.Imdb, Title = episodeItem.Show.Title, SeasonIdx = episodeItem.Episode.Season.ToString(), EpisodeIdx = episodeItem.Episode.Number.ToString() }; GUIShouts.Fanart = episodeItem.Show.Images.FanartImageFilename; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts); break; case ((int)ContextMenuItem.Rate): RateEpisode(episodeItem); OnEpisodeSelected(Facade.SelectedListItem, Facade); ((Facade.SelectedListItem as GUITraktCalendarListItem).Item as TraktImage).NotifyPropertyChanged("EpisodeImages"); break; case ((int)ContextMenuItem.MarkAsWatched): MarkEpisodeAsWatched(episodeItem); episodeItem.Episode.Watched = true; Facade.SelectedListItem.IsPlayed = true; if (episodeItem.Episode.Plays == 0) episodeItem.Episode.Plays = 1; OnEpisodeSelected(Facade.SelectedListItem, Facade); ((Facade.SelectedListItem as GUITraktCalendarListItem).Item as TraktImage).NotifyPropertyChanged("EpisodeImages"); break; case ((int)ContextMenuItem.MarkAsUnWatched): MarkEpisodeAsUnWatched(episodeItem); episodeItem.Episode.Watched = false; Facade.SelectedListItem.IsPlayed = false; OnEpisodeSelected(Facade.SelectedListItem, Facade); ((Facade.SelectedListItem as GUITraktCalendarListItem).Item as TraktImage).NotifyPropertyChanged("EpisodeImages"); break; case ((int)ContextMenuItem.AddShowToWatchList): AddShowToWatchList(episodeItem); episodeItem.Show.InWatchList = true; OnEpisodeSelected(Facade.SelectedListItem, Facade); GUIWatchListShows.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.AddEpisodeToWatchList): AddEpisodeToWatchList(episodeItem); episodeItem.Episode.InWatchList = true; OnEpisodeSelected(Facade.SelectedListItem, Facade); ((Facade.SelectedListItem as GUITraktCalendarListItem).Item as TraktImage).NotifyPropertyChanged("EpisodeImages"); GUIWatchListShows.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.RemoveShowFromWatchList): RemoveShowFromWatchList(episodeItem); episodeItem.Show.InWatchList = false; OnEpisodeSelected(Facade.SelectedListItem, Facade); GUIWatchListShows.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.RemoveEpisodeFromWatchList): RemoveEpisodeFromWatchList(episodeItem); episodeItem.Episode.InWatchList = false; OnEpisodeSelected(Facade.SelectedListItem, Facade); ((Facade.SelectedListItem as GUITraktCalendarListItem).Item as TraktImage).NotifyPropertyChanged("EpisodeImages"); GUIWatchListShows.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.AddEpisodeToList): TraktHelper.AddRemoveEpisodeInUserList(episodeItem.Show.Title, episodeItem.Show.Year.ToString(), episodeItem.Episode.Season.ToString(), episodeItem.Episode.Number.ToString(), episodeItem.Show.Tvdb, false); break; case ((int)ContextMenuItem.AddShowToList): TraktHelper.AddRemoveShowInUserList(episodeItem.Show.Title, episodeItem.Show.Year.ToString(), episodeItem.Show.Tvdb, false); break; case ((int)ContextMenuItem.AddToLibrary): AddEpisodeToLibrary(episodeItem); episodeItem.Episode.InCollection = true; OnEpisodeSelected(Facade.SelectedListItem, Facade); ((Facade.SelectedListItem as GUITraktCalendarListItem).Item as TraktImage).NotifyPropertyChanged("EpisodeImages"); break; case ((int)ContextMenuItem.RemoveFromLibrary): RemoveEpisodeFromLibrary(episodeItem); episodeItem.Episode.InCollection = false; OnEpisodeSelected(Facade.SelectedListItem, Facade); ((Facade.SelectedListItem as GUITraktCalendarListItem).Item as TraktImage).NotifyPropertyChanged("EpisodeImages"); break; case ((int)ContextMenuItem.Trailers): if (episodeItem != null) GUICommon.ShowTVShowTrailersMenu(episodeItem.Show); break; case ((int)ContextMenuItem.WatchlistFilter): TraktSettings.CalendarHideTVShowsInWatchList = !TraktSettings.CalendarHideTVShowsInWatchList; LoadCalendar(); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { GUIListItem selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } TraktWatchListShow selectedShow = (TraktWatchListShow)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; // Show Season Information listItem = new GUIListItem(Translation.ShowSeasonInfo); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo; if (CurrentUser == TraktSettings.Username) { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } else if (!selectedShow.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; if (TraktHelper.IsOnlineVideosAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Related Shows listItem = new GUIListItem(Translation.RelatedShows + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Show listItem = new GUIListItem(Translation.RateShow); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Shouts + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for show with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for show with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON()); break; case ((int)ContextMenuItem.AddToWatchList): AddShowToWatchList(selectedShow); selectedShow.InWatchList = true; OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); GUIWatchListShows.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.RemoveFromWatchList): PreviousSelectedIndex = this.Facade.SelectedListItemIndex; RemoveShowFromWatchList(selectedShow); if (_WatchListShows.Count() >= 1) { // remove from list var showsToExcept = new List <TraktWatchListShow>(); showsToExcept.Add(selectedShow); _WatchListShows = WatchListShows.Except(showsToExcept); userWatchList[CurrentUser] = _WatchListShows; LoadWatchListShows(); } else { // no more shows left ClearProperties(); GUIControl.ClearControl(GetID, Facade.GetID); _WatchListShows = null; userWatchList.Remove(CurrentUser); // notify and exit GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoShowWatchList); GUIWindowManager.ShowPreviousWindow(); return; } break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveShowInUserList(selectedShow.Title, selectedShow.Year.ToString(), selectedShow.Tvdb, false); break; case ((int)ContextMenuItem.Related): RelatedShow relatedShow = new RelatedShow(); relatedShow.Title = selectedShow.Title; relatedShow.TVDbId = selectedShow.Tvdb; GUIRelatedShows.relatedShow = relatedShow; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedShows); break; case ((int)ContextMenuItem.Rate): GUICommon.RateShow(selectedShow); OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); if (CurrentUser != TraktSettings.Username) { GUIWatchListShows.ClearCache(TraktSettings.Username); } break; case ((int)ContextMenuItem.Shouts): GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.show; GUIShouts.ShowInfo = new ShowShout { IMDbId = selectedShow.Imdb, TVDbId = selectedShow.Tvdb, Title = selectedShow.Title }; GUIShouts.Fanart = selectedShow.Images.FanartImageFilename; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedShow); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedShow.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedShow.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 userListItem = selectedItem.TVTag as TraktUserListItem; if (userListItem == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.episode) { // Mark As Watched if (!userListItem.Watched) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (userListItem.Watched) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } } if (SelectedType != TraktItemType.season) { // Add/Remove Watch List if (!userListItem.InWatchList) { listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } else { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } } // Add to Custom list listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Remove from Custom list (Only if current user is the active user) if (TraktSettings.Username == CurrentUser) { listItem = new GUIListItem(Translation.RemoveFromList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromList; } if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.episode) { // Add to Library // Don't allow if it will be removed again on next sync // movie could be part of a DVD collection if (!userListItem.InCollection && !TraktSettings.KeepTraktLibraryClean) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (userListItem.InCollection) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } } // Related Movies/Shows listItem = new GUIListItem(SelectedType == TraktItemType.movie ? Translation.RelatedMovies : Translation.RelatedShows + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; if (SelectedType != TraktItemType.season) { // Rate listItem = new GUIListItem(Translation.Rate + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Shouts + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; } // Trailers if (TraktHelper.IsOnlineVideosAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Search with mpNZB if (TraktHelper.IsMpNZBAvailableAndEnabled) { if ((userListItem.Movie != null && !userListItem.Movie.InCollection) || userListItem.Episode != null) { listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } } // Search with MyTorrents if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { if ((userListItem.Movie != null && !userListItem.Movie.InCollection) || userListItem.Episode != null) { listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } } // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.MarkAsWatched): MarkItemAsWatched(userListItem); if (userListItem.Plays == 0) { userListItem.Plays = 1; } userListItem.Watched = true; selectedItem.IsPlayed = true; OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.MarkAsUnWatched): MarkItemAsUnWatched(userListItem); userListItem.Watched = false; selectedItem.IsPlayed = false; OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.AddToWatchList): AddItemToWatchList(userListItem); userListItem.InWatchList = true; OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } GUIWatchListMovies.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.RemoveFromWatchList): RemoveItemFromWatchList(userListItem); userListItem.InWatchList = false; OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } GUIWatchListMovies.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.AddToList): if (SelectedType == TraktItemType.movie) { TraktHelper.AddRemoveMovieInUserList(userListItem.Title, userListItem.Year, userListItem.ImdbId, false); } else if (SelectedType == TraktItemType.show) { TraktHelper.AddRemoveShowInUserList(userListItem.Title, userListItem.Year, userListItem.Show.Tvdb, false); } else if (SelectedType == TraktItemType.season) { TraktHelper.AddRemoveSeasonInUserList(userListItem.Title, userListItem.Year, userListItem.SeasonNumber, userListItem.Show.Tvdb, false); } else if (SelectedType == TraktItemType.episode) { TraktHelper.AddRemoveEpisodeInUserList(userListItem.Title, userListItem.Year, userListItem.SeasonNumber, userListItem.EpisodeNumber, userListItem.Show.Tvdb, false); } break; case ((int)ContextMenuItem.RemoveFromList): if (!GUIUtils.ShowYesNoDialog(Translation.DeleteListItem, Translation.ConfirmDeleteListItem)) { break; } // Only do remove from current list // We could do same as Add (ie remove from multile lists) but typically you only remove from the current list if (SelectedType == TraktItemType.movie) { TraktListItem item = new TraktListItem { Type = "movie", ImdbId = userListItem.ImdbId, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year) }; TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true); } else if (SelectedType == TraktItemType.show) { TraktListItem item = new TraktListItem { Type = "show", TvdbId = userListItem.Show.Tvdb, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year) }; TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true); } else if (SelectedType == TraktItemType.season) { TraktListItem item = new TraktListItem { Type = "season", TvdbId = userListItem.Show.Tvdb, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year), Season = Convert.ToInt32(userListItem.SeasonNumber) }; TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true); } else if (SelectedType == TraktItemType.episode) { TraktListItem item = new TraktListItem { Type = "episode", TvdbId = userListItem.Show.Tvdb, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year), Season = Convert.ToInt32(userListItem.SeasonNumber), Episode = Convert.ToInt32(userListItem.EpisodeNumber) }; TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true); } // Remove from view if (Facade.Count > 1) { PreviousSelectedIndex = Facade.SelectedListItemIndex; CurrentList.Items.Remove(userListItem); SendListItemsToFacade(CurrentList); } else { CurrentList.Items.Remove(userListItem); // no more items left GUIControl.ClearControl(GetID, Facade.GetID); ClearProperties(); GUIWindowManager.Process(); // nothing left, exit GUIWindowManager.ShowPreviousWindow(); return; } break; case ((int)ContextMenuItem.AddToLibrary): AddItemToLibrary(userListItem); userListItem.InCollection = true; OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.RemoveFromLibrary): RemoveItemFromLibrary(userListItem); userListItem.InCollection = false; OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.Related): if (SelectedType == TraktItemType.movie) { RelatedMovie relatedMovie = new RelatedMovie(); relatedMovie.IMDbId = userListItem.Movie.IMDBID; relatedMovie.Title = userListItem.Movie.Title; GUIRelatedMovies.relatedMovie = relatedMovie; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedMovies); } else { //series, season & episode RelatedShow relatedShow = new RelatedShow(); relatedShow.Title = userListItem.Show.Title; relatedShow.TVDbId = userListItem.Show.Tvdb; GUIRelatedShows.relatedShow = relatedShow; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedShows); } break; case ((int)ContextMenuItem.Rate): RateItem(userListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.Shouts): GUIShouts.ShoutType = (GUIShouts.ShoutTypeEnum)Enum.Parse(typeof(GUIShouts.ShoutTypeEnum), SelectedType.ToString(), true); if (SelectedType == TraktItemType.movie) { GUIShouts.MovieInfo = new MovieShout { IMDbId = userListItem.ImdbId, TMDbId = userListItem.Movie.TMDBID, Title = userListItem.Title, Year = userListItem.Year } } ; else if (SelectedType == TraktItemType.show) { GUIShouts.ShowInfo = new ShowShout { IMDbId = userListItem.ImdbId, TVDbId = userListItem.Show.Tvdb, Title = userListItem.Title } } ; else { GUIShouts.EpisodeInfo = new EpisodeShout { IMDbId = userListItem.ImdbId, TVDbId = userListItem.Show.Tvdb, Title = userListItem.Title, SeasonIdx = userListItem.SeasonNumber, EpisodeIdx = userListItem.EpisodeNumber } }; GUIShouts.Fanart = SelectedType == TraktItemType.movie ? userListItem.Movie.Images.Fanart.LocalImageFilename(ArtworkType.MovieFanart) : userListItem.Show.Images.Fanart.LocalImageFilename(ArtworkType.ShowFanart); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts); break; case ((int)ContextMenuItem.Trailers): if (SelectedType == TraktItemType.movie) { GUICommon.ShowMovieTrailersMenu(userListItem.Movie); } else if (SelectedType == TraktItemType.episode) { userListItem.Episode.Season = Convert.ToInt32(userListItem.SeasonNumber); userListItem.Episode.Number = Convert.ToInt32(userListItem.EpisodeNumber); GUICommon.ShowTVShowTrailersMenu(userListItem.Show, userListItem.Episode); } else if (SelectedType == TraktItemType.season && TraktSettings.UseTrailersPlugin && TraktHelper.IsTrailersAvailableAndEnabled) { GUICommon.ShowTVSeasonTrailersPluginMenu(userListItem.Show, int.Parse(userListItem.SeasonNumber)); } break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = String.Empty; if (userListItem.Movie != null) { loadingParam = string.Format("search:{0}", userListItem.Movie.Title); } else if (userListItem.Episode != null) { loadingParam = string.Format("search:{0} S{1}E{2}", userListItem.Show.Title, userListItem.Episode.Season.ToString("D2"), userListItem.Episode.Number.ToString("D2")); } GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = String.Empty; if (userListItem.Movie != null) { loadPar = userListItem.Movie.Title; } else if (userListItem.Episode != null) { loadPar = string.Format("{0} S{1}E{2}", userListItem.Show.Title, userListItem.Episode.Season.ToString("D2"), userListItem.Episode.Number.ToString("D2")); } GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { if (GUIBackgroundTask.Instance.IsBusy) { return; } var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedShow = (TraktShow)selectedItem.TVTag; var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Show Season Information listItem = new GUIListItem(Translation.ShowSeasonInfo); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo; // Hide/Show Watched items listItem = new GUIListItem(HideWatched ? Translation.ShowWatched : Translation.HideWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.HideShowWatched; // Mark Show As Watched listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; // Add Show to Library listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; // Add/Remove Watch List if (!selectedShow.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; if (TraktHelper.IsOnlineVideosAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Related Shows listItem = new GUIListItem(Translation.RelatedShows + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Show listItem = new GUIListItem(Translation.RateShow); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Shouts + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for show with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for show with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON()); break; case ((int)ContextMenuItem.HideShowWatched): HideWatched = !HideWatched; if (hideWatchedButton != null) { hideWatchedButton.Selected = HideWatched; } dictRelatedShows.Remove(relatedShow.Slug); LoadRelatedShows(); break; case ((int)ContextMenuItem.MarkAsWatched): GUICommon.MarkShowAsSeen(selectedShow); break; case ((int)ContextMenuItem.AddToLibrary): GUICommon.AddShowToLibrary(selectedShow); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddShowToWatchList(selectedShow); selectedShow.InWatchList = true; OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveShowFromWatchList(selectedShow); selectedShow.InWatchList = false; OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveShowInUserList(selectedShow.Title, selectedShow.Year.ToString(), selectedShow.Tvdb, false); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedShow); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowTVShowShouts(selectedShow); break; case ((int)ContextMenuItem.Related): RelatedShow relShow = new RelatedShow { Title = selectedShow.Title, TVDbId = selectedShow.Tvdb }; relatedShow = relShow; LoadRelatedShows(); GUIUtils.SetProperty("#Trakt.Related.Show", relatedShow.Title); RelationChanged = true; break; case ((int)ContextMenuItem.Rate): GUICommon.RateShow(selectedShow); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedShow.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedShow.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
public static void ShowRelatedShows(string tvdbid, string title) { if (!File.Exists(GUIGraphicsContext.Skin + @"\Trakt.Related.Shows.xml")) { // let user know they need to update skin or harass skin author GUIUtils.ShowOKDialog(GUIUtils.PluginName(), Translation.SkinOutOfDate); return; } RelatedShow relatedShow = new RelatedShow { TVDbId = tvdbid, Title = title }; GUIRelatedShows.relatedShow = relatedShow; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedShows); }
protected override void OnShowContextMenu() { GUIListItem selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) return; TraktShow selectedShow = (TraktShow)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; listItem = new GUIListItem(Translation.DismissRecommendation); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.DismissRecommendation; // Show Season Information listItem = new GUIListItem(Translation.ShowSeasonInfo); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo; // Add/Remove Watch List if (!selectedShow.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; } listItem = new GUIListItem(Translation.AddToList + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; if (TraktHelper.IsOnlineVideosAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Related Shows listItem = new GUIListItem(Translation.RelatedShows + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Show listItem = new GUIListItem(Translation.RateShow); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Shouts + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for show with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for show with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) return; switch (dlg.SelectedId) { case ((int)ContextMenuItem.DismissRecommendation): PreviousSelectedIndex = this.Facade.SelectedListItemIndex; DismissRecommendation(selectedShow); if (_RecommendedShows.Count() > 1) { var showsToExcept = new List<TraktShow>(); showsToExcept.Add(selectedShow); _RecommendedShows = RecommendedShows.Except(showsToExcept); } else { // reload, none left ClearProperties(); GUIControl.ClearControl(GetID, Facade.GetID); _RecommendedShows = null; } LoadRecommendedShows(); break; case ((int)ContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON()); break; case ((int)ContextMenuItem.AddToWatchList): AddShowToWatchList(selectedShow); selectedShow.InWatchList = true; OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); GUIWatchListShows.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.RemoveFromWatchList): RemoveShowFromWatchList(selectedShow); selectedShow.InWatchList = false; OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); GUIWatchListShows.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveShowInUserList(selectedShow.Title, selectedShow.Year.ToString(), selectedShow.Tvdb, false); break; case ((int)ContextMenuItem.Related): RelatedShow relatedShow = new RelatedShow(); relatedShow.Title = selectedShow.Title; relatedShow.TVDbId = selectedShow.Tvdb; GUIRelatedShows.relatedShow = relatedShow; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedShows); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedShow); break; case ((int)ContextMenuItem.Shouts): GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.show; GUIShouts.ShowInfo = new ShowShout { IMDbId = selectedShow.Imdb, TVDbId = selectedShow.Tvdb, Title = selectedShow.Title }; GUIShouts.Fanart = selectedShow.Images.FanartImageFilename; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts); break; case ((int)ContextMenuItem.Rate): PreviousSelectedIndex = this.Facade.SelectedListItemIndex; if (GUICommon.RateShow(selectedShow)) { // remove from recommendations if (_RecommendedShows.Count() > 1) { var showsToExcept = new List<TraktShow>(); showsToExcept.Add(selectedShow); _RecommendedShows = RecommendedShows.Except(showsToExcept); } else { // reload, none left ClearProperties(); GUIControl.ClearControl(GetID, Facade.GetID); _RecommendedShows = null; } LoadRecommendedShows(); } break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedShow.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedShow.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { if (GUIBackgroundTask.Instance.IsBusy) return; GUIListItem selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) return; TraktShow selectedShow = (TraktShow)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; // Show Season Information listItem = new GUIListItem(Translation.ShowSeasonInfo); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo; // Hide/Show Watched items listItem = new GUIListItem(HideWatched ? Translation.ShowWatched : Translation.HideWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.HideShowWatched; // Add/Remove Watch List if (!selectedShow.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; if (TraktHelper.IsOnlineVideosAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Related Shows listItem = new GUIListItem(Translation.RelatedShows + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Show listItem = new GUIListItem(Translation.RateShow); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Shouts + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for show with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for show with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) return; switch (dlg.SelectedId) { case ((int)ContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON()); break; case ((int)ContextMenuItem.HideShowWatched): HideWatched = !HideWatched; if (hideWatchedButton != null) hideWatchedButton.Selected = HideWatched; dictRelatedShows.Remove(relatedShow.Slug); LoadRelatedShows(); break; case ((int)ContextMenuItem.AddToWatchList): AddShowToWatchList(selectedShow); selectedShow.InWatchList = true; OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); GUIWatchListShows.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.RemoveFromWatchList): RemoveShowFromWatchList(selectedShow); selectedShow.InWatchList = false; OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); GUIWatchListShows.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveShowInUserList(selectedShow.Title, selectedShow.Year.ToString(), selectedShow.Tvdb, false); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedShow); break; case ((int)ContextMenuItem.Shouts): GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.show; GUIShouts.ShowInfo = new ShowShout { IMDbId = selectedShow.Imdb, TVDbId = selectedShow.Tvdb, Title = selectedShow.Title }; GUIShouts.Fanart = selectedShow.Images.FanartImageFilename; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts); break; case ((int)ContextMenuItem.Related): RelatedShow relShow = new RelatedShow { Title = selectedShow.Title, TVDbId = selectedShow.Tvdb }; relatedShow = relShow; LoadRelatedShows(); GUIUtils.SetProperty("#Trakt.Related.Show", relatedShow.Title); RelationChanged = true; break; case ((int)ContextMenuItem.Rate): GUICommon.RateShow(selectedShow); OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedShow.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedShow.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; 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.Imdb; 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.Tmdb, 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): ShowTrailersMenu(userListItem); 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): ShowLayoutMenu(); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { if (GUIBackgroundTask.Instance.IsBusy) return; var selectedItem = this.Facade.SelectedListItem as GUIShowListItem; if (selectedItem == null) return; var selectedShow = selectedItem.TVTag as TraktShowSummary; if (selectedShow == 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; // Show Season Information listItem = new GUIListItem(Translation.ShowSeasonInfo); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo; // Hide/Show Watched items listItem = new GUIListItem(HideWatched ? Translation.ShowWatched : Translation.HideWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.HideShowWatched; // Mark Show As Watched listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; // Add Show to Library listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; // Add/Remove Watchlist if (!selectedShow.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; // 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; // Related Shows listItem = new GUIListItem(Translation.RelatedShows); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Show listItem = new GUIListItem(Translation.RateShow); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; // Trailers if (TraktHelper.IsTrailersAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } if (TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for show with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for show with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) return; switch (dlg.SelectedId) { case ((int)ContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON()); break; case ((int)ContextMenuItem.HideShowWatched): HideWatched = !HideWatched; if (hideWatchedButton != null) hideWatchedButton.Selected = HideWatched; dictRelatedShows.Remove(relatedShow.Slug); LoadRelatedShows(); break; case ((int)ContextMenuItem.MarkAsWatched): GUICommon.MarkShowAsWatched(selectedShow); break; case ((int)ContextMenuItem.AddToLibrary): GUICommon.AddShowToCollection(selectedShow); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddShowToWatchList(selectedShow); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveShowFromWatchList(selectedShow); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveShowInUserList(selectedShow, false); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedShow); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowTVShowShouts(selectedShow); break; case ((int)ContextMenuItem.Related): var relShow = new RelatedShow { TraktId = selectedShow.Ids.Trakt, TmdbId = selectedShow.Ids.Tmdb, TvdbId = selectedShow.Ids.Tvdb, Title = selectedShow.Title, Year = selectedShow.Year }; relatedShow = relShow; LoadRelatedShows(); GUIUtils.SetProperty("#Trakt.Related.Show", relatedShow.Title); RelationChanged = true; break; case ((int)ContextMenuItem.Rate): GUICommon.RateShow(selectedShow); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.Cast): GUICreditsShow.Show = selectedShow; GUICreditsShow.Type = GUICreditsShow.CreditType.Cast; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); break; case ((int)ContextMenuItem.Crew): GUICreditsShow.Show = selectedShow; GUICreditsShow.Type = GUICreditsShow.CreditType.Crew; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedShow.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedShow.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }