private void UpdateButtonState() { // update layout button label GUIControl.SetControlLabel(GetID, layoutButton.GetID, GUICommon.GetLayoutTranslation(CurrentLayout)); }
private void PublishWatchlistSkinProperties(TraktMovieWatchList item) { GUICommon.SetProperty("#Trakt.Movie.WatchList.Inserted", item.ListedAt.FromISO8601().ToShortDateString()); GUICommon.SetMovieProperties(item.Movie); }
protected override void OnShowContextMenu() { if (GUIBackgroundTask.Instance.IsBusy) { return; } GUIListItem selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedEpisodeSummary = selectedItem.TVTag as TraktEpisodeSummaryEx; if (selectedEpisodeSummary == null) { return; } var selectedEpisode = selectedEpisodeSummary.Episode; if (selectedEpisode == null) { return; } var selectedShow = selectedEpisodeSummary.Show; if (selectedShow == 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; // Show Season Information listItem = new GUIListItem(Translation.ShowSeasonInfo); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo; if (!selectedEpisode.IsWatchlisted()) { listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } else { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } // Add to Custom List listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Mark As Watched if (!selectedEpisode.IsWatched(selectedShow)) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (selectedEpisode.IsWatched(selectedShow)) { 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 (!selectedEpisode.IsCollected(selectedShow) && !TraktSettings.KeepTraktLibraryClean) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedEpisode.IsCollected(selectedShow)) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } // Related Shows listItem = new GUIListItem(Translation.RelatedShows); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Episode listItem = new GUIListItem(Translation.RateEpisode); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; if (TraktHelper.IsTrailersAvailableAndEnabled) { // Trailers listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (!selectedEpisode.IsCollected(selectedShow) && TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for movie with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (!selectedEpisode.IsCollected(selectedShow) && 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.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON()); break; case ((int)ContextMenuItem.MarkAsWatched): TraktHelper.AddEpisodeToWatchHistory(selectedEpisode); TraktCache.AddEpisodeToWatchHistory(selectedShow, selectedEpisode); selectedItem.IsPlayed = true; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.MarkAsUnWatched): TraktHelper.RemoveEpisodeFromWatchHistory(selectedEpisode); TraktCache.RemoveEpisodeFromWatchHistory(selectedShow, selectedEpisode); selectedItem.IsPlayed = false; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddEpisodeToWatchList(selectedEpisode); TraktCache.AddEpisodeToWatchlist(selectedShow, selectedEpisode); OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveEpisodeFromWatchList(selectedEpisode); OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveEpisodeInUserList(selectedEpisode, false); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedShow, selectedEpisode); break; case ((int)ContextMenuItem.AddToLibrary): TraktHelper.AddEpisodeToCollection(selectedEpisode); TraktCache.AddEpisodeToCollection(selectedShow, selectedEpisode); OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveEpisodeFromCollection(selectedEpisode); TraktCache.RemoveEpisodeFromCollection(selectedShow, selectedEpisode); OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.Related): TraktHelper.ShowRelatedShows(selectedShow); break; case ((int)ContextMenuItem.Rate): GUICommon.RateEpisode(selectedShow, selectedEpisode); OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowEpisodeShouts(selectedShow, selectedEpisode); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0} S{1}E{2}", selectedShow.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2")); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = string.Format("{0} S{1}E{2}", selectedShow.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2")); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); 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(); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem; if (selectedItem == null) { return; } var selectedWatchlistItem = selectedItem.TVTag as TraktMovieWatchList; if (selectedWatchlistItem == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // only allow removal if viewing your own watchlist if (CurrentUser == TraktSettings.Username) { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } else if (!selectedWatchlistItem.Movie.IsWatchlisted()) { // viewing someone else's watchlist and not in yours listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } // Add to Custom List listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Mark As Watched if (!selectedWatchlistItem.Movie.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (selectedWatchlistItem.Movie.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } // Add to Library // Don't allow if it will be removed again on next sync // movie could be part of a DVD collection if (!selectedWatchlistItem.Movie.IsCollected() && !TraktSettings.KeepTraktLibraryClean) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedWatchlistItem.Movie.IsCollected()) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } // Related Movies listItem = new GUIListItem(Translation.RelatedMovies); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Movie listItem = new GUIListItem(Translation.RateMovie); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Cast and Crew listItem = new GUIListItem(Translation.Cast); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Cast; listItem = new GUIListItem(Translation.Crew); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Crew; // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; // Trailers if (TraktHelper.IsTrailersAvailableAndEnabled) { // Trailers listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } if (!selectedWatchlistItem.Movie.IsCollected() && TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for movie with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (!selectedWatchlistItem.Movie.IsCollected() && TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for movie with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.MarkAsWatched): TraktHelper.AddMovieToWatchHistory(selectedWatchlistItem.Movie); if (CurrentUser != TraktSettings.Username) { selectedItem.IsPlayed = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); GUIWatchListMovies.ClearCache(TraktSettings.Username); } else { // when marking a movie as seen via API, it will remove from watchlist // we should do the same in GUI PreviousSelectedIndex = this.Facade.SelectedListItemIndex; if (_WatchListMovies.Count() >= 1) { // remove from list var moviesToExcept = new List <TraktMovieWatchList>(); moviesToExcept.Add(selectedWatchlistItem); _WatchListMovies = WatchListMovies.Except(moviesToExcept); userWatchList[CurrentUser] = _WatchListMovies; LoadWatchListMovies(); } else { // no more movies left ClearProperties(); GUIControl.ClearControl(GetID, Facade.GetID); _WatchListMovies = null; userWatchList.Remove(CurrentUser); // notify and exit GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoMovieWatchList); GUIWindowManager.ShowPreviousWindow(); return; } } break; case ((int)ContextMenuItem.MarkAsUnWatched): TraktHelper.RemoveMovieFromWatchHistory(selectedWatchlistItem.Movie); selectedItem.IsPlayed = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddMovieToWatchList(selectedWatchlistItem.Movie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromWatchList): PreviousSelectedIndex = this.Facade.SelectedListItemIndex; TraktHelper.RemoveMovieFromWatchList(selectedWatchlistItem.Movie, true); if (_WatchListMovies.Count() >= 1) { // remove from list var moviesToExcept = new List <TraktMovieWatchList>(); moviesToExcept.Add(selectedWatchlistItem); _WatchListMovies = WatchListMovies.Except(moviesToExcept); userWatchList[CurrentUser] = _WatchListMovies; LoadWatchListMovies(); } else { // no more movies left ClearProperties(); GUIControl.ClearControl(GetID, Facade.GetID); _WatchListMovies = null; userWatchList.Remove(CurrentUser); // notify and exit GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoMovieWatchList); GUIWindowManager.ShowPreviousWindow(); return; } break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveMovieInUserList(selectedWatchlistItem.Movie, false); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowMovieTrailersMenu(selectedWatchlistItem.Movie); break; case ((int)ContextMenuItem.AddToLibrary): TraktHelper.AddMovieToCollection(selectedWatchlistItem.Movie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (CurrentUser != TraktSettings.Username) { GUIWatchListMovies.ClearCache(TraktSettings.Username); } break; case ((int)ContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveMovieFromCollection(selectedWatchlistItem.Movie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (CurrentUser != TraktSettings.Username) { GUIWatchListMovies.ClearCache(TraktSettings.Username); } break; case ((int)ContextMenuItem.Related): TraktHelper.ShowRelatedMovies(selectedWatchlistItem.Movie); break; case ((int)ContextMenuItem.Rate): GUICommon.RateMovie(selectedWatchlistItem.Movie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (CurrentUser != TraktSettings.Username) { GUIWatchListMovies.ClearCache(TraktSettings.Username); } break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowMovieShouts(selectedWatchlistItem.Movie); break; case ((int)ContextMenuItem.Cast): GUICreditsMovie.Movie = selectedWatchlistItem.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)ContextMenuItem.Crew): GUICreditsMovie.Movie = selectedWatchlistItem.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedWatchlistItem.Movie.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedWatchlistItem.Movie.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { // wait for any background action to finish if (GUIBackgroundTask.Instance.IsBusy) { return; } switch (controlId) { // Facade case (50): if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { CheckAndPlayMovie(true); } break; // Layout Button case (2): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; // Sort Button case (8): var newSortBy = GUICommon.ShowSortMenu(TraktSettings.SortByTrendingMovies); if (newSortBy != null) { if (newSortBy.Field != TraktSettings.SortByTrendingMovies.Field) { TraktSettings.SortByTrendingMovies = newSortBy; PreviousSelectedIndex = 0; UpdateButtonState(); LoadTrendingMovies(); } } break; // Hide Watched case (9): TraktSettings.TrendingMoviesHideWatched = !TraktSettings.TrendingMoviesHideWatched; UpdateButtonState(); LoadTrendingMovies(); break; // Hide Watchlisted case (10): TraktSettings.TrendingMoviesHideWatchlisted = !TraktSettings.TrendingMoviesHideWatchlisted; UpdateButtonState(); LoadTrendingMovies(); break; // Hide Collected case (11): TraktSettings.TrendingMoviesHideCollected = !TraktSettings.TrendingMoviesHideCollected; UpdateButtonState(); LoadTrendingMovies(); break; // Hide Rated case (12): TraktSettings.TrendingMoviesHideRated = !TraktSettings.TrendingMoviesHideRated; UpdateButtonState(); LoadTrendingMovies(); break; default: break; } base.OnClicked(controlId, control, actionType); }
private void SendTrendingMoviesToFacade(IEnumerable <TraktTrendingMovie> movies) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (movies.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoTrendingMovies); GUIWindowManager.ShowPreviousWindow(); return; } // filter movies movies = GUICommon.FilterTrendingMovies(movies); // sort movies var movieList = movies.Where(m => !string.IsNullOrEmpty(m.Title)).ToList(); movieList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByTrendingMovies.Field, TraktSettings.SortByTrendingMovies.Direction)); int itemId = 0; var movieImages = new List <TraktImage>(); // Add each movie mark remote if not in collection foreach (var movie in movieList) { // add image for download var images = new TraktImage { MovieImages = movie.Images }; movieImages.Add(images); var item = new GUIMovieListItem(movie.Title, (int)TraktGUIWindows.TrendingMovies); item.Label2 = movie.Year == "0" ? "----" : movie.Year; item.TVTag = movie; item.Images = images; item.IsPlayed = movie.Watched; item.ItemId = Int32.MaxValue - itemId; // movie in collection doesnt nessararily mean // that the movie is locally available on this computer // as 'keep library clean' might not be enabled //item.IsRemote = !movie.InCollection; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", movies.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", movies.Count().ToString(), movies.Count() > 1 ? Translation.Movies : Translation.Movie)); GUIUtils.SetProperty("#Trakt.Trending.PeopleCount", movies.Sum(m => m.Watchers).ToString()); GUIUtils.SetProperty("#Trakt.Trending.Description", string.Format(Translation.TrendingMoviePeople, movies.Sum(m => m.Watchers).ToString(), movies.Count().ToString())); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedComment = selectedItem.TVTag as TraktCommentItem; if (selectedComment == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Like or Unlike Comment if (CurrentUser != TraktSettings.Username) { // Like if (!selectedComment.Comment.IsLiked()) { listItem = new GUIListItem(Translation.Like); dlg.Add(listItem); listItem.ItemId = (int)ActivityContextMenuItem.Like; } else { // UnLike listItem = new GUIListItem(Translation.UnLike); dlg.Add(listItem); listItem.ItemId = (int)ActivityContextMenuItem.Unlike; } } listItem = new GUIListItem(TraktSettings.HideSpoilersOnShouts ? Translation.ShowSpoilers : Translation.HideSpoilers); dlg.Add(listItem); listItem.ItemId = (int)ActivityContextMenuItem.Spoilers; // if selected activity is an episode or show, add 'Season Info' if (selectedComment.Show != null) { listItem = new GUIListItem(Translation.ShowSeasonInfo); dlg.Add(listItem); listItem.ItemId = (int)ActivityContextMenuItem.ShowSeasonInfo; } // get a list of common actions to perform on the selected item if (selectedComment.Movie != null || selectedComment.Show != null) { var listItems = GetContextMenuItemsForComment(selectedComment); foreach (var item in listItems) { int itemId = item.ItemId; dlg.Add(item); item.ItemId = itemId; } } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case (int)ActivityContextMenuItem.Like: GUICommon.LikeComment(selectedComment.Comment); selectedComment.Comment.Likes++; PublishCommentSkinProperties(selectedComment); break; case (int)ActivityContextMenuItem.Unlike: GUICommon.UnLikeComment(selectedComment.Comment); if (selectedComment.Comment.Likes > 0) { selectedComment.Comment.Likes--; PublishCommentSkinProperties(selectedComment); } break; case ((int)ActivityContextMenuItem.Spoilers): TraktSettings.HideSpoilersOnShouts = !TraktSettings.HideSpoilersOnShouts; if (hideSpoilersButton != null) { hideSpoilersButton.Selected = TraktSettings.HideSpoilersOnShouts; } PublishCommentSkinProperties(selectedComment); break; case ((int)ActivityContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedComment.Show.ToJSON()); break; case ((int)ActivityContextMenuItem.AddToList): if (selectedComment.Movie != null) { TraktHelper.AddRemoveMovieInUserList(selectedComment.Movie, false); } else if (selectedComment.Episode != null) { TraktHelper.AddRemoveEpisodeInUserList(selectedComment.Episode, false); } else { TraktHelper.AddRemoveShowInUserList(selectedComment.Show, false); } break; case ((int)ActivityContextMenuItem.AddToWatchList): if (selectedComment.Movie != null) { TraktHelper.AddMovieToWatchList(selectedComment.Movie, true); } else if (selectedComment.Episode != null) { TraktHelper.AddEpisodeToWatchList(selectedComment.Episode); } else { TraktHelper.AddShowToWatchList(selectedComment.Show); } break; case ((int)ActivityContextMenuItem.Shouts): if (selectedComment.Movie != null) { TraktHelper.ShowMovieShouts(selectedComment.Movie); } else if (selectedComment.Episode != null) { TraktHelper.ShowEpisodeShouts(selectedComment.Show, selectedComment.Episode); } else { TraktHelper.ShowTVShowShouts(selectedComment.Show); } break; case ((int)ActivityContextMenuItem.Rate): if (selectedComment.Movie != null) { GUICommon.RateMovie(selectedComment.Movie); } else if (selectedComment.Episode != null) { GUICommon.RateEpisode(selectedComment.Show, selectedComment.Episode); } else { GUICommon.RateShow(selectedComment.Show); } break; case ((int)ActivityContextMenuItem.Cast): if (selectedComment.Movie != null) { GUICreditsMovie.Movie = selectedComment.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUIMovieListItem).Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); } else if (selectedComment.Show != null) { GUICreditsShow.Show = selectedComment.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Cast; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUIShowListItem).Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); } break; case ((int)ActivityContextMenuItem.Crew): if (selectedComment.Movie != null) { GUICreditsMovie.Movie = selectedComment.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUIMovieListItem).Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); } else if (selectedComment.Show != null) { GUICreditsShow.Show = selectedComment.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Crew; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUIShowListItem).Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); } break; case ((int)ActivityContextMenuItem.Trailers): if (selectedComment.Movie != null) { GUICommon.ShowMovieTrailersMenu(selectedComment.Movie); } else { GUICommon.ShowTVShowTrailersMenu(selectedComment.Show, selectedComment.Episode); } break; } base.OnShowContextMenu(); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { // wait for any background action to finish if (GUIBackgroundTask.Instance.IsBusy) { return; } switch (controlId) { // Facade case (50): if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { var item = Facade.SelectedListItem as GUIShowListItem; if (item == null) { return; } if (!item.IsFolder) { if (TraktSettings.EnableJumpToForTVShows) { CheckAndPlayEpisode(true); } else { if (item.Show == null) { return; } GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, item.Show.ToJSON()); } } else { if (item.IsPrevPageItem) { CurrentPage--; } else { CurrentPage++; } if (CurrentPage == 1) { PreviousSelectedIndex = 0; } else { PreviousSelectedIndex = 1; } // load next / previous page LoadTrendingShows(CurrentPage); } } break; // Layout Button case (2): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; // Sort Button case (8): var newSortBy = GUICommon.ShowSortMenu(TraktSettings.SortByTrendingShows); if (newSortBy != null) { if (newSortBy.Field != TraktSettings.SortByTrendingShows.Field) { TraktSettings.SortByTrendingShows = newSortBy; PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1; UpdateButtonState(); LoadTrendingShows(CurrentPage); } } break; // Hide Watched case (9): PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1; TraktSettings.TrendingShowsHideWatched = !TraktSettings.TrendingShowsHideWatched; UpdateButtonState(); LoadTrendingShows(CurrentPage); break; // Hide Watchlisted case (10): PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1; TraktSettings.TrendingShowsHideWatchlisted = !TraktSettings.TrendingShowsHideWatchlisted; UpdateButtonState(); LoadTrendingShows(CurrentPage); break; // Hide Collected case (11): PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1; TraktSettings.TrendingShowsHideCollected = !TraktSettings.TrendingShowsHideCollected; UpdateButtonState(); LoadTrendingShows(CurrentPage); break; // Hide Rated case (12): PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1; TraktSettings.TrendingShowsHideRated = !TraktSettings.TrendingShowsHideRated; UpdateButtonState(); LoadTrendingShows(CurrentPage); break; default: break; } base.OnClicked(controlId, control, actionType); }
private void PublishShowSkinProperties(TraktShowSummary show) { GUICommon.SetShowProperties(show); }
private void PublishSeasonSkinProperties(TraktSeasonSummary season) { GUICommon.SetSeasonProperties(Show, season); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedSeason = selectedItem.TVTag as TraktSeasonSummary; var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Trailers if (TraktHelper.IsTrailersAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Comments listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Comments; // Rate listItem = new GUIListItem(Translation.Rate + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Mark season as watched listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; // Add season to Library listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; // Add to Custom List listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Add to Watchlist listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchlist; // Sort By listItem = new GUIListItem(TraktSettings.SortSeasonsAscending ? Translation.SortSeasonsDescending : Translation.SortSeasonsAscending); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Sort; // 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.Trailers): GUICommon.ShowTVSeasonTrailersPluginMenu(Show, selectedSeason.Number); break; case ((int)ContextMenuItem.Comments): TraktHelper.ShowTVSeasonShouts(Show, selectedSeason); break; case ((int)ContextMenuItem.Rate): GUICommon.RateSeason(Show, selectedSeason); OnSeasonSelected(selectedItem, Facade); (Facade.SelectedListItem as GUISeasonListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.MarkAsWatched): GUICommon.MarkSeasonAsWatched(Show, selectedSeason.Number); OnSeasonSelected(selectedItem, Facade); (Facade.SelectedListItem as GUISeasonListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToLibrary): GUICommon.AddSeasonToLibrary(Show, selectedSeason.Number); OnSeasonSelected(selectedItem, Facade); (Facade.SelectedListItem as GUISeasonListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveSeasonInUserList(selectedSeason, false); break; case ((int)ContextMenuItem.AddToWatchlist): TraktHelper.AddSeasonToWatchList(Show, selectedSeason.Number); OnSeasonSelected(selectedItem, Facade); (Facade.SelectedListItem as GUISeasonListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.Sort): TraktSettings.SortSeasonsAscending = !TraktSettings.SortSeasonsAscending; LoadShowSeasons(); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; default: break; } base.OnShowContextMenu(); }
private void SendCreditResultsToFacade(TraktCredits credits) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (credits == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); Show = null; return; } int itemId = 0; var personImages = new List <GUITmdbImage>(); // Add each character if (Type == CreditType.Cast && credits.Cast != null) { foreach (var person in credits.Cast) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(string.IsNullOrEmpty(person.Character) ? person.Person.Name : string.Format(Translation.ActorAndRole, person.Person.Name, person.Character), (int)TraktGUIWindows.CreditsShow); item.Person = person.Person; item.CreditType = Credit.Cast; item.Character = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCastSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } // add each crew member if (Type == CreditType.Crew && credits.Crew != null) { if (credits.Crew.Directing != null) { foreach (var person in credits.Crew.Directing) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Directing; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.Writing != null) { foreach (var person in credits.Crew.Writing) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Writing; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.Production != null) { foreach (var person in credits.Crew.Production) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Production; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.Art != null) { foreach (var person in credits.Crew.Art) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Art; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.Camera != null) { foreach (var person in credits.Crew.Camera) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Camera; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.CostumeAndMakeUp != null) { foreach (var person in credits.Crew.CostumeAndMakeUp) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.CostumeAndMakeUp; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } if (credits.Crew.Sound != null) { foreach (var person in credits.Crew.Sound) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Person.Name, (int)TraktGUIWindows.CreditsShow); item.Label2 = GUICommon.GetTranslatedCreditJob(person.Job); item.Person = person.Person; item.CreditType = Credit.Sound; item.Job = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnCrewSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } } } // if nothing to display exit if (Facade.Count == 0) { GUIUtils.ShowNotifyDialog(Type == CreditType.Crew ? Translation.Crew : Translation.Cast, Translation.NoCreditsFound); GUIWindowManager.ShowPreviousWindow(); Show = null; return; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", Facade.Count.ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", Facade.Count.ToString(), Facade.Count > 1 ? Translation.People : Translation.Person)); // Download images Async and set to facade GUIPersonListItem.GetImages(personImages, false); }
private void ClearProperties() { GUIUtils.SetProperty("#Trakt.Movie.AddedDate", string.Empty); GUICommon.ClearMovieProperties(); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { // wait for any background action to finish if (GUIBackgroundTask.Instance.IsBusy) { return; } switch (controlId) { // Facade case (50): if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { if (SelectedType == TraktItemType.movie) { CheckAndPlayMovie(true); } else if (TraktSettings.EnableJumpToForTVShows || SelectedType == TraktItemType.episode) { CheckAndPlayEpisode(true); } else if (SelectedType == TraktItemType.show) { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var listItem = selectedItem.TVTag as TraktListItem; if (listItem == null) { return; } GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, listItem.Show.ToJSON()); } else if (SelectedType == TraktItemType.season) { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var listItem = selectedItem.TVTag as TraktListItem; if (listItem == null) { return; } // create loading parameter for episode listing var loadingParam = new SeasonLoadingParameter { Season = listItem.Season, Show = listItem.Show }; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.SeasonEpisodes, loadingParam.ToJSON()); } else if (SelectedType == TraktItemType.person) { var selectedItem = Facade.SelectedListItem; if (selectedItem == null) { return; } var listItem = selectedItem.TVTag as TraktListItem; if (listItem == null) { return; } // if we already have the person summary, parse it along to the window GUIPersonSummary.CurrentPerson = listItem.Person; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.PersonSummary); } } break; // Layout Button case (2): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; default: break; } base.OnClicked(controlId, control, actionType); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem as GUIShowListItem; if (selectedItem == null) { return; } var selectedTrendingItem = selectedItem.TVTag as TraktShowTrending; if (selectedTrendingItem == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUICommon.CreateShowsContextMenu(ref dlg, selectedTrendingItem.Show, false); // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)MediaContextMenuItem.AddToWatchList): TraktHelper.AddShowToWatchList(selectedTrendingItem.Show); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.TrendingShowsHideWatchlisted) { LoadTrendingShows(CurrentPage); } break; case ((int)MediaContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedTrendingItem.Show.ToJSON()); break; case ((int)MediaContextMenuItem.MarkAsWatched): GUICommon.MarkShowAsWatched(selectedTrendingItem.Show); if (TraktSettings.TrendingShowsHideWatched) { LoadTrendingShows(CurrentPage); } break; case ((int)MediaContextMenuItem.AddToLibrary): GUICommon.AddShowToCollection(selectedTrendingItem.Show); if (TraktSettings.TrendingShowsHideCollected) { LoadTrendingShows(CurrentPage); } break; case ((int)MediaContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveShowFromWatchList(selectedTrendingItem.Show); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.AddToList): TraktHelper.AddRemoveShowInUserList(selectedTrendingItem.Show, false); break; case ((int)MediaContextMenuItem.Filters): if (GUICommon.ShowTVShowFiltersMenu()) { PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1; UpdateButtonState(); LoadTrendingShows(CurrentPage); } break; case ((int)MediaContextMenuItem.Related): TraktHelper.ShowRelatedShows(selectedTrendingItem.Show); break; case ((int)MediaContextMenuItem.Cast): GUICreditsShow.Show = selectedTrendingItem.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Cast; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); break; case ((int)MediaContextMenuItem.Crew): GUICreditsShow.Show = selectedTrendingItem.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Crew; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); break; case ((int)MediaContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedTrendingItem.Show); break; case ((int)MediaContextMenuItem.Shouts): TraktHelper.ShowTVShowShouts(selectedTrendingItem.Show); break; case ((int)MediaContextMenuItem.Rate): GUICommon.RateShow(selectedTrendingItem.Show); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.TrendingShowsHideRated) { LoadTrendingShows(CurrentPage); } break; case ((int)MediaContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)MediaContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedTrendingItem.Show.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)MediaContextMenuItem.SearchTorrent): string loadPar = selectedTrendingItem.Show.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedListItem = selectedItem.TVTag as TraktListItem; if (selectedListItem == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.episode) { // Mark As Watched if (!selectedListItem.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (selectedListItem.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } } if (SelectedType != TraktItemType.season && SelectedType != TraktItemType.person) { // Add/Remove Watchlist if (!selectedListItem.IsWatchlisted()) { listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } else { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } } // Add to Custom list listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Remove from Custom list (only if current user is the active user) if (TraktSettings.Username == CurrentUser) { listItem = new GUIListItem(Translation.RemoveFromList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromList; } if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.episode) { // Add to Collection // Don't allow if it will be removed again on next sync // movie could be part of a DVD collection if (!selectedListItem.IsCollected() && !TraktSettings.KeepTraktLibraryClean) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedListItem.IsCollected()) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } } // Related Movies/Shows if (SelectedType != TraktItemType.person) { listItem = new GUIListItem(SelectedType == TraktItemType.movie ? Translation.RelatedMovies : Translation.RelatedShows); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; } if (SelectedType != TraktItemType.season && SelectedType != TraktItemType.person) { // Rate listItem = new GUIListItem(Translation.Rate + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; } // Cast and Crew if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.show) { listItem = new GUIListItem(Translation.Cast); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Cast; listItem = new GUIListItem(Translation.Crew); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Crew; } // Trailers if (SelectedType != TraktItemType.person) { if (TraktHelper.IsTrailersAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } } // Search with mpNZB if (TraktHelper.IsMpNZBAvailableAndEnabled) { if ((selectedListItem.Movie != null && !selectedListItem.Movie.IsCollected()) || selectedListItem.Episode != null) { listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } } // Search with MyTorrents if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { if ((selectedListItem.Movie != null && !selectedListItem.Movie.IsCollected()) || selectedListItem.Episode != null) { listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } } // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.MarkAsWatched): AddItemToWatchedHistory(selectedListItem); selectedItem.IsPlayed = true; OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.MarkAsUnWatched): RemoveItemFromWatchedHistory(selectedListItem); selectedItem.IsPlayed = false; OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.AddToWatchList): AddItemToWatchList(selectedListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } GUIWatchListMovies.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.RemoveFromWatchList): RemoveItemFromWatchList(selectedListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } GUIWatchListMovies.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.AddToList): if (SelectedType == TraktItemType.movie) { TraktHelper.AddRemoveMovieInUserList(selectedListItem.Movie, false); } else if (SelectedType == TraktItemType.show) { TraktHelper.AddRemoveShowInUserList(selectedListItem.Show, false); } else if (SelectedType == TraktItemType.season) { TraktHelper.AddRemoveSeasonInUserList(selectedListItem.Season, false); } else if (SelectedType == TraktItemType.episode) { TraktHelper.AddRemoveEpisodeInUserList(selectedListItem.Episode, false); } else if (SelectedType == TraktItemType.person) { TraktHelper.AddRemovePersonInUserList(selectedListItem.Person, false); } break; case ((int)ContextMenuItem.RemoveFromList): if (!GUIUtils.ShowYesNoDialog(Translation.DeleteListItem, Translation.ConfirmDeleteListItem)) { break; } // Only do remove from current list // We could do same as Add (ie remove from multiple lists) but typically you only remove from the current list TraktHelper.AddRemoveItemInList((int)CurrentList.Ids.Trakt, GetSyncItems(selectedListItem), true); // clear the list item cache TraktLists.ClearListItemCache(CurrentUser, CurrentList.Ids.Trakt.ToString()); // remove item from collection CurrentListItems.RemoveAll(l => ListItemMatch(l, selectedListItem)); // clear the cache TraktLists.ClearListItemCache(TraktSettings.Username, CurrentList.Ids.Trakt.ToString()); // Remove from view if (Facade.Count > 1) { PreviousSelectedIndex = Facade.SelectedListItemIndex; SendListItemsToFacade(CurrentListItems); } else { // no more items left GUIControl.ClearControl(GetID, Facade.GetID); ClearProperties(); GUIWindowManager.Process(); // nothing left, exit GUIWindowManager.ShowPreviousWindow(); return; } break; case ((int)ContextMenuItem.AddToLibrary): AddItemToCollection(selectedListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.RemoveFromLibrary): RemoveItemFromCollection(selectedListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.Related): if (SelectedType == TraktItemType.movie) { TraktHelper.ShowRelatedMovies(selectedListItem.Movie); } else { //series, season & episode TraktHelper.ShowRelatedShows(selectedListItem.Show); } break; case ((int)ContextMenuItem.Rate): RateItem(selectedListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.Shouts): if (SelectedType == TraktItemType.movie) { TraktHelper.ShowMovieShouts(selectedListItem.Movie); } else if (SelectedType == TraktItemType.show) { TraktHelper.ShowTVShowShouts(selectedListItem.Show); } else { TraktHelper.ShowEpisodeShouts(selectedListItem.Show, selectedListItem.Episode); } break; case ((int)ContextMenuItem.Cast): if (SelectedType == TraktItemType.movie) { GUICreditsMovie.Movie = selectedListItem.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUICustomListItem).Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); } else if (SelectedType == TraktItemType.show) { GUICreditsShow.Show = selectedListItem.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Cast; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUICustomListItem).Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); } break; case ((int)ContextMenuItem.Crew): if (SelectedType == TraktItemType.movie) { GUICreditsMovie.Movie = selectedListItem.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUICustomListItem).Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); } else if (SelectedType == TraktItemType.show) { GUICreditsShow.Show = selectedListItem.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Crew; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUICustomListItem).Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); } break; case ((int)ContextMenuItem.Trailers): if (SelectedType == TraktItemType.movie) { GUICommon.ShowMovieTrailersMenu(selectedListItem.Movie); } else if (SelectedType == TraktItemType.episode) { GUICommon.ShowTVShowTrailersMenu(selectedListItem.Show, selectedListItem.Episode); } else if (SelectedType == TraktItemType.season && TraktHelper.IsTrailersAvailableAndEnabled) { GUICommon.ShowTVSeasonTrailersPluginMenu(selectedListItem.Show, selectedListItem.Season.Number); } break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = String.Empty; if (selectedListItem.Movie != null) { loadingParam = string.Format("search:{0}", selectedListItem.Movie.Title); } else if (selectedListItem.Episode != null) { loadingParam = string.Format("search:{0} S{1}E{2}", selectedListItem.Show.Title, selectedListItem.Episode.Season.ToString("D2"), selectedListItem.Episode.Number.ToString("D2")); } GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = String.Empty; if (selectedListItem.Movie != null) { loadPar = selectedListItem.Movie.Title; } else if (selectedListItem.Episode != null) { loadPar = string.Format("{0} S{1}E{2}", selectedListItem.Show.Title, selectedListItem.Episode.Season.ToString("D2"), selectedListItem.Episode.Number.ToString("D2")); } GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; default: break; } base.OnShowContextMenu(); }
private void SendTrendingShowsToFacade(TraktShowsTrending trendingItems) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (trendingItems == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); TrendingShowPages = null; return; } if (trendingItems.Shows.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoTrendingShows); GUIWindowManager.ShowPreviousWindow(); TrendingShowPages = null; return; } // filter shows var filteredTrendingList = GUICommon.FilterTrendingShows(trendingItems.Shows).Where(s => !string.IsNullOrEmpty(s.Show.Title)).ToList(); // sort shows filteredTrendingList.Sort(new GUIListItemShowSorter(TraktSettings.SortByTrendingShows.Field, TraktSettings.SortByTrendingShows.Direction)); int itemId = 0; var showImages = new List <GUITmdbImage>(); // Add Previous Page Button if (trendingItems.CurrentPage != 1) { var prevPageItem = new GUIShowListItem(Translation.PreviousPage, (int)TraktGUIWindows.TrendingShows); prevPageItem.IsPrevPageItem = true; prevPageItem.IconImage = "traktPreviousPage.png"; prevPageItem.IconImageBig = "traktPreviousPage.png"; prevPageItem.ThumbnailImage = "traktPreviousPage.png"; prevPageItem.OnItemSelected += OnPreviousPageSelected; prevPageItem.IsFolder = true; Facade.Add(prevPageItem); itemId++; } foreach (var trendingItem in filteredTrendingList) { var item = new GUIShowListItem(trendingItem.Show.Title, (int)TraktGUIWindows.TrendingShows); // add image for download var image = new GUITmdbImage { ShowImages = new TmdbShowImages { Id = trendingItem.Show.Ids.Tmdb } }; showImages.Add(image); item.Label2 = trendingItem.Show.Year.ToString(); item.TVTag = trendingItem; item.Show = trendingItem.Show; item.Images = image; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnShowSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Add Next Page Button if (trendingItems.CurrentPage != trendingItems.TotalPages) { var nextPageItem = new GUIShowListItem(Translation.NextPage, (int)TraktGUIWindows.TrendingShows); nextPageItem.IsNextPageItem = true; nextPageItem.IconImage = "traktNextPage.png"; nextPageItem.IconImageBig = "traktNextPage.png"; nextPageItem.ThumbnailImage = "traktNextPage.png"; nextPageItem.OnItemSelected += OnNextPageSelected; nextPageItem.IsFolder = true; Facade.Add(nextPageItem); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", filteredTrendingList.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", filteredTrendingList.Count(), filteredTrendingList.Count() > 1 ? Translation.SeriesPlural : Translation.Series)); GUIUtils.SetProperty("#Trakt.Trending.PeopleCount", trendingItems.TotalWatchers.ToString()); GUIUtils.SetProperty("#Trakt.Trending.Description", string.Format(Translation.TrendingTVShowsPeople, trendingItems.TotalWatchers.ToString(), trendingItems.TotalItems.ToString())); // Page Properties GUIUtils.SetProperty("#Trakt.Facade.CurrentPage", trendingItems.CurrentPage.ToString()); GUIUtils.SetProperty("#Trakt.Facade.TotalPages", trendingItems.TotalPages.ToString()); GUIUtils.SetProperty("#Trakt.Facade.TotalItemsPerPage", TraktSettings.MaxTrendingShowsRequest.ToString()); // Download show images Async and set to facade GUIShowListItem.GetImages(showImages); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedMovie = selectedItem.TVTag as TraktTrendingMovie; 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()); 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); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.TrendingMoviesHideWatched) { LoadTrendingMovies(); } break; case ((int)TrendingContextMenuItem.MarkAsUnWatched): TraktHelper.MarkMovieAsUnWatched(selectedMovie); selectedMovie.Watched = false; selectedItem.IsPlayed = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)TrendingContextMenuItem.AddToWatchList): TraktHelper.AddMovieToWatchList(selectedMovie, true); selectedMovie.InWatchList = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.TrendingMoviesHideWatchlisted) { LoadTrendingMovies(); } break; case ((int)TrendingContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveMovieFromWatchList(selectedMovie, true); selectedMovie.InWatchList = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)TrendingContextMenuItem.AddToList): TraktHelper.AddRemoveMovieInUserList(selectedMovie, false); break; case ((int)TrendingContextMenuItem.AddToLibrary): TraktHelper.AddMovieToLibrary(selectedMovie); selectedMovie.InCollection = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.TrendingMoviesHideCollected) { LoadTrendingMovies(); } break; case ((int)TrendingContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveMovieFromLibrary(selectedMovie); selectedMovie.InCollection = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)TrendingContextMenuItem.Related): TraktHelper.ShowRelatedMovies(selectedMovie); break; case ((int)TrendingContextMenuItem.Rate): GUICommon.RateMovie(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); 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, PreviousSelectedIndex); 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(); }
private void PublishMovieSkinProperties(TraktWatchListMovie movie) { GUICommon.SetProperty("#Trakt.Movie.WatchList.Inserted", movie.Inserted.FromEpoch().ToShortDateString()); GUICommon.SetMovieProperties(movie); }
private void PublishMovieSkinProperties(TraktTrendingMovie movie) { GUICommon.SetProperty("#Trakt.Movie.Watchers", movie.Watchers.ToString()); GUICommon.SetProperty("#Trakt.Movie.Watchers.Extra", movie.Watchers > 1 ? string.Format(Translation.PeopleWatching, movie.Watchers) : Translation.PersonWatching); GUICommon.SetMovieProperties(movie); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedEpisodeSummary = selectedItem.TVTag as TraktEpisodeSummary; if (selectedEpisodeSummary == null) { return; } var selectedEpisode = selectedEpisodeSummary.Episode; var selectedShow = selectedEpisodeSummary.Show; 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(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; if (selectedEpisode.Watched) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } else { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } if (selectedEpisode.InCollection) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } else { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedEpisode.InWatchList) { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } else { listItem = new GUIListItem(Translation.AddEpisodeToWatchList); 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; // 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; // 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.Trailers): GUICommon.ShowTVShowTrailersMenu(Show, selectedEpisode); break; case ((int)ContextMenuItem.MarkAsWatched): TraktHelper.MarkEpisodeAsWatched(Show, selectedEpisode); selectedEpisode.Watched = true; Facade.SelectedListItem.IsPlayed = true; if (selectedEpisode.Plays == 0) { selectedEpisode.Plays = 1; } OnEpisodeSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.MarkAsUnWatched): TraktHelper.MarkEpisodeAsUnWatched(Show, selectedEpisode); selectedEpisode.Watched = false; Facade.SelectedListItem.IsPlayed = false; OnEpisodeSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.AddToLibrary): TraktHelper.AddEpisodeToLibrary(Show, selectedEpisode); selectedEpisode.InCollection = true; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveEpisodeFromLibrary(Show, selectedEpisode); selectedEpisode.InCollection = false; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddEpisodeToWatchList(Show, selectedEpisode); selectedEpisode.InWatchList = true; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveEpisodeFromWatchList(Show, selectedEpisode); selectedEpisode.InWatchList = false; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.Rate): GUICommon.RateEpisode(Show, selectedEpisode); OnEpisodeSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveEpisodeInUserList(Show.Title, Show.Year.ToString(), selectedEpisode.Season.ToString(), selectedEpisode.Number.ToString(), Show.Tvdb, false); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowEpisodeShouts(Show, selectedEpisode); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0} S{1}E{2}", Show.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2")); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = string.Format("{0} S{1}E{2}", Show.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2")); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
private void ClearProperties() { GUIUtils.SetProperty("#Trakt.Related.Show", string.Empty); GUICommon.ClearShowProperties(); }
private void SendSeasonEpisodesToFacade(IEnumerable <TraktEpisode> episodes) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (episodes == null || episodes.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoEpisodesInSeason); GUIWindowManager.ShowPreviousWindow(); return; } // Set Common Show Properties GUICommon.SetShowProperties(Show); int itemCount = 0; var episodeImages = new List <TraktImage>(); foreach (var episode in episodes) { // use episode short string string itemLabel = string.Format("{0}. {1}", episode.Number.ToString(), string.IsNullOrEmpty(episode.Title) ? Translation.Episode + " " + episode.Number.ToString() : episode.Title); // add image for download var images = new TraktImage { EpisodeImages = episode.Images, ShowImages = Show.Images }; episodeImages.Add(images); var item = new GUIEpisodeListItem(itemLabel, (int)TraktGUIWindows.SeasonEpisodes); item.Label2 = episode.FirstAired == 0 ? " " : episode.FirstAired.FromEpoch().ToShortDateString(); item.TVTag = new TraktEpisodeSummary { Episode = episode, Show = Show }; item.IsPlayed = episode.Watched; item.Images = images; item.ItemId = Int32.MaxValue - itemCount; item.IconImage = "defaultTraktEpisode.png"; item.IconImageBig = "defaultTraktEpisodeBig.png"; item.ThumbnailImage = "defaultTraktEpisodeBig.png"; item.OnItemSelected += OnEpisodeSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemCount++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= itemCount) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", itemCount.ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", itemCount.ToString(), itemCount > 1 ? Translation.Episodes : Translation.Episode)); // Download episode images Async and set to facade GUIEpisodeListItem.GetImages(episodeImages); }
private void ClearProperties() { GUIUtils.SetProperty("#Trakt.Movie.WatchList.Inserted", string.Empty); GUICommon.ClearMovieProperties(); }
private void ClearProperties() { GUICommon.ClearShowProperties(); GUICommon.ClearSeasonProperties(); GUICommon.ClearEpisodeProperties(); }
protected override void OnShowContextMenu() { if (GUIBackgroundTask.Instance.IsBusy) { return; } var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedComment = selectedItem.TVTag as TraktComment; if (selectedComment == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Like or Unlike Comment if (selectedComment.User.Username != TraktSettings.Username) { // Like if (!selectedComment.IsLiked()) { listItem = new GUIListItem(Translation.Like); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Like; } else { // UnLike listItem = new GUIListItem(Translation.UnLike); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.UnLike; } } if (ShoutType == ShoutTypeEnum.episode && (selectedComment.ParentId == null || selectedComment.ParentId == 0)) { listItem = new GUIListItem(Translation.NextEpisode); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.NextEpisode; if (EpisodeInfo.EpisodeIdx > 1) { listItem = new GUIListItem(Translation.PreviousEpisode); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.PrevEpisode; } } listItem = new GUIListItem(TraktSettings.HideSpoilersOnShouts ? Translation.ShowSpoilers : Translation.HideSpoilers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Spoilers; // userprofile - only load for unprotected users if (!selectedComment.User.IsPrivate) { listItem = new GUIListItem(Translation.UserProfile); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.UserProfile; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case (int)ContextMenuItem.Like: GUICommon.LikeComment(selectedComment); selectedComment.Likes++; PublishCommentSkinProperties(selectedComment); break; case (int)ContextMenuItem.UnLike: GUICommon.UnLikeComment(selectedComment); if (selectedComment.Likes > 0) { selectedComment.Likes--; PublishCommentSkinProperties(selectedComment); } break; case ((int)ContextMenuItem.Spoilers): TraktSettings.HideSpoilersOnShouts = !TraktSettings.HideSpoilersOnShouts; if (hideSpoilersButton != null) { hideSpoilersButton.Selected = TraktSettings.HideSpoilersOnShouts; } PublishCommentSkinProperties(selectedComment); break; case ((int)ContextMenuItem.NextEpisode): GetNextEpisodeComments(); break; case ((int)ContextMenuItem.PrevEpisode): GetPrevEpisodeComments(); break; case ((int)ContextMenuItem.UserProfile): GUIUserProfile.CurrentUser = selectedComment.User.Username; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.UserProfile); 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(); }
private void ClearProperties() { GUIUtils.SetProperty("#Trakt.Search.SearchTerm", string.Empty); GUICommon.ClearShowProperties(); GUICommon.ClearEpisodeProperties(); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedMovie = selectedItem.TVTag as TraktMovieSummary; if (selectedMovie == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; if (!selectedMovie.IsWatchlisted()) { listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } else { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } // Add to Custom List listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Mark As Watched if (!selectedMovie.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (selectedMovie.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } // Add to Library // Don't allow if it will be removed again on next sync // movie could be part of a DVD collection if (!selectedMovie.IsCollected() && !TraktSettings.KeepTraktLibraryClean) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedMovie.IsCollected()) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } // Related Movies listItem = new GUIListItem(Translation.RelatedMovies); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Movie listItem = new GUIListItem(Translation.RateMovie); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; if (TraktHelper.IsTrailersAvailableAndEnabled) { // Trailers listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (!selectedMovie.IsCollected() && TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for movie with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (!selectedMovie.IsCollected() && TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for movie with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.MarkAsWatched): TraktHelper.AddMovieToWatchHistory(selectedMovie); selectedItem.IsPlayed = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.MarkAsUnWatched): TraktHelper.RemoveMovieFromWatchHistory(selectedMovie); selectedItem.IsPlayed = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddMovieToWatchList(selectedMovie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveMovieFromWatchList(selectedMovie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveMovieInUserList(selectedMovie, false); break; case ((int)ContextMenuItem.Trailers): PreviousUser = CurrentUser; GUICommon.ShowMovieTrailersMenu(selectedMovie); break; case ((int)ContextMenuItem.AddToLibrary): TraktHelper.AddMovieToCollection(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveMovieFromCollection(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.Related): TraktHelper.ShowRelatedMovies(selectedMovie); break; case ((int)ContextMenuItem.Rate): GUICommon.RateMovie(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowMovieShouts(selectedMovie); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedMovie.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedMovie.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }