private void OnCommentSelected(GUIListItem item, GUIControl parent) { var commentItem = item.TVTag as TraktCommentItem; if (commentItem == null) { return; } PublishCommentSkinProperties(commentItem); string fanartFileName = string.Empty; switch (commentItem.Type) { case "movie": fanartFileName = TmdbCache.GetMovieBackdropFilename((item as GUICustomListItem).Images.MovieImages); break; case "show": case "season": case "episode": fanartFileName = TmdbCache.GetShowBackdropFilename((item as GUICustomListItem).Images.ShowImages); break; case "list": break; } if (!string.IsNullOrEmpty(fanartFileName)) { GUIImageHandler.LoadFanart(backdrop, fanartFileName); } }
private void OnMovieSelected(GUIListItem item, GUIControl parent) { PreviousSelectedIndex = Facade.SelectedListItemIndex; var movie = item.TVTag as TraktMovieBoxOffice; PublishMovieSkinProperties(movie); GUIImageHandler.LoadFanart(backdrop, TmdbCache.GetMovieBackdropFilename((item as GUIMovieListItem).Images.MovieImages)); }
private void OnCastSelected(GUIListItem item, GUIControl control) { PreviousSelectedIndex = Facade.SelectedListItemIndex; var creditItem = item.TVTag as TraktPersonMovieCast; if (creditItem == null) return; PublishCastSkinProperties(creditItem); GUIImageHandler.LoadFanart(backdrop, TmdbCache.GetMovieBackdropFilename((item as GUIMovieListItem).Images.MovieImages)); }
private void OnMovieSelected(GUIListItem item, GUIControl parent) { // publish extended properties, selected index excludes date headers. GUICommon.SetProperty("#Trakt.Calendar.Selected.Date", (item as GUIMovieListItem).Date); GUICommon.SetProperty("#selectedindex", (item as GUIMovieListItem).SelectedIndex); var calendarItem = item.TVTag as TraktMovieCalendar; PublishCalendarSkinProperties(calendarItem); GUIImageHandler.LoadFanart(backdrop, TmdbCache.GetMovieBackdropFilename((item as GUIMovieListItem).Images.MovieImages)); }
private void OnMovieSelected(GUIListItem item, GUIControl parent) { PreviousSelectedIndex = Facade.SelectedListItemIndex; var watchlistItem = item.TVTag as TraktMovieWatchList; PublishWatchlistSkinProperties(watchlistItem); string fanart = TmdbCache.GetMovieBackdropFilename((item as GUIMovieListItem).Images.MovieImages); if (!string.IsNullOrEmpty(fanart)) { GUIImageHandler.LoadFanart(backdrop, fanart); } }
private void OnMovieSelected(GUIListItem item, GUIControl control) { GUIUtils.SetProperty("#Trakt.Facade.IsPageItem", false.ToString()); PreviousSelectedIndex = Facade.SelectedListItemIndex; var PopularItem = item.TVTag as TraktMovieSummary; if (PopularItem == null) { return; } PublishMovieSkinProperties(PopularItem); GUIImageHandler.LoadFanart(backdrop, TmdbCache.GetMovieBackdropFilename((item as GUIMovieListItem).Images.MovieImages)); }
private void OnMovieSelected(GUIListItem item, GUIControl parent) { var selectedMovie = item.TVTag as TraktMovieSummary; if (selectedMovie == null) { return; } PreviousSelectedIndex = Facade.SelectedListItemIndex; GUICommon.SetProperty("#Trakt.Movie.AddedDate", (item as GUIMovieListItem).Date); GUICommon.SetMovieProperties(selectedMovie); GUIImageHandler.LoadFanart(backdrop, TmdbCache.GetMovieBackdropFilename((item as GUIMovieListItem).Images.MovieImages)); }
protected override void OnShowContextMenu() { var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); var selectedItem = Facade.SelectedListItem as GUIMovieListItem; if (selectedItem == null) { return; } var calendarItem = selectedItem.TVTag as TraktMovieCalendar; if (calendarItem == null) { return; } // Create Views Menu Item var listItem = new GUIListItem(Translation.ChangeView); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.View; // Start Date listItem = new GUIListItem(Translation.StartDate + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.StartDate; // Max Days listItem = new GUIListItem(Translation.MaxDays + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MaxDays; // Hide Movie listItem = new GUIListItem(Translation.HideMovie); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.HideMovie; // Related Movies listItem = new GUIListItem(Translation.RelatedMovies); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate listItem = new GUIListItem(Translation.Rate + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Mark As Watched if (!calendarItem.Movie.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } else { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } // Add/Remove Movie Watchlist if (!calendarItem.Movie.IsWatchlisted()) { listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddMovieToWatchlist; } else { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveMovieFromWatchlist; } // Add Movie to Custom List listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddMovieToList; // Shouts listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Add/Remove Libary if (!calendarItem.Movie.IsCollected()) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } else { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } // Cast and Crew listItem = new GUIListItem(Translation.Cast); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Cast; listItem = new GUIListItem(Translation.Crew); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Crew; if (TraktHelper.IsTrailersAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.View): ShowViewMenu(); break; case ((int)ContextMenuItem.StartDate): ShowStartDateMenu(); break; case ((int)ContextMenuItem.MaxDays): ShowMaxDaysMenu(); break; case ((int)ContextMenuItem.HideMovie): TraktHelper.AddHiddenMovie(calendarItem.Movie, "calendar"); FilterHiddenMovies = true; LoadCalendar(); break; case ((int)ContextMenuItem.Related): TraktHelper.ShowRelatedMovies(calendarItem.Movie); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowMovieShouts(calendarItem.Movie); break; case ((int)ContextMenuItem.Rate): GUICommon.RateMovie(calendarItem.Movie); OnMovieSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.MarkAsWatched): TraktHelper.AddMovieToWatchHistory(calendarItem.Movie); Facade.SelectedListItem.IsPlayed = true; OnMovieSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.MarkAsUnWatched): TraktHelper.RemoveMovieFromWatchHistory(calendarItem.Movie); Facade.SelectedListItem.IsPlayed = false; OnMovieSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddMovieToWatchlist): TraktHelper.AddMovieToWatchList(calendarItem.Movie, true); OnMovieSelected(Facade.SelectedListItem, Facade); GUIWatchListMovies.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.RemoveMovieFromWatchlist): TraktHelper.RemoveMovieFromWatchList(calendarItem.Movie, true); OnMovieSelected(Facade.SelectedListItem, Facade); GUIWatchListMovies.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.AddMovieToList): TraktHelper.AddRemoveMovieInUserList(calendarItem.Movie, false); break; case ((int)ContextMenuItem.AddToLibrary): TraktHelper.AddMovieToCollection(calendarItem.Movie); OnMovieSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveMovieFromCollection(calendarItem.Movie); OnMovieSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.Cast): GUICreditsMovie.Movie = calendarItem.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)ContextMenuItem.Crew): GUICreditsMovie.Movie = calendarItem.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)ContextMenuItem.Trailers): if (calendarItem != null) { GUICommon.ShowMovieTrailersMenu(calendarItem.Movie); } break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem; if (selectedItem == null) { return; } var selectedPopularMovie = selectedItem.TVTag as TraktMovieSummary; if (selectedPopularMovie == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUICommon.CreateMoviesContextMenu(ref dlg, selectedPopularMovie, false); // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)MediaContextMenuItem.MarkAsWatched): TraktHelper.AddMovieToWatchHistory(selectedPopularMovie); selectedItem.IsPlayed = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.PopularMoviesHideWatched) { LoadPopularMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.MarkAsUnWatched): TraktHelper.RemoveMovieFromWatchHistory(selectedPopularMovie); selectedItem.IsPlayed = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.AddToWatchList): TraktHelper.AddMovieToWatchList(selectedPopularMovie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.PopularMoviesHideWatchlisted) { LoadPopularMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveMovieFromWatchList(selectedPopularMovie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.AddToList): TraktHelper.AddRemoveMovieInUserList(selectedPopularMovie, false); break; case ((int)MediaContextMenuItem.AddToLibrary): TraktHelper.AddMovieToCollection(selectedPopularMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.PopularMoviesHideCollected) { LoadPopularMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveMovieFromCollection(selectedPopularMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.Related): TraktHelper.ShowRelatedMovies(selectedPopularMovie); break; case ((int)MediaContextMenuItem.Rate): GUICommon.RateMovie(selectedPopularMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.PopularMoviesHideRated) { LoadPopularMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.Filters): if (ShowMovieFiltersMenu()) { PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1; UpdateButtonState(); LoadPopularMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.Shouts): TraktHelper.ShowMovieShouts(selectedPopularMovie); break; case ((int)MediaContextMenuItem.Cast): GUICreditsMovie.Movie = selectedPopularMovie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)MediaContextMenuItem.Crew): GUICreditsMovie.Movie = selectedPopularMovie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)MediaContextMenuItem.Trailers): GUICommon.ShowMovieTrailersMenu(selectedPopularMovie); break; case ((int)MediaContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)MediaContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedPopularMovie.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)MediaContextMenuItem.SearchTorrent): string loadParm = selectedPopularMovie.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadParm); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { if (GUIBackgroundTask.Instance.IsBusy) { return; } var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem; if (selectedItem == null) { return; } var selectedMovie = selectedItem.Movie; if (selectedMovie == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Mark As Watched if (!selectedMovie.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (selectedMovie.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } // Add/Remove Watchlist if (!selectedMovie.IsWatchlisted()) { listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } else { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } // Add to Custom list listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Add to Library // Don't allow if it will be removed again on next sync // movie could be part of a DVD collection if (!selectedMovie.IsCollected() && !TraktSettings.KeepTraktLibraryClean) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedMovie.IsCollected()) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } // Related Movies listItem = new GUIListItem(Translation.RelatedMovies); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Movie listItem = new GUIListItem(Translation.RateMovie); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Cast and Crew listItem = new GUIListItem(Translation.Cast); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Cast; listItem = new GUIListItem(Translation.Crew); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Crew; // Trailers if (TraktHelper.IsTrailersAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (!selectedMovie.IsCollected() && TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for movie with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (!selectedMovie.IsCollected() && TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for movie with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.MarkAsWatched): TraktHelper.AddMovieToWatchHistory(selectedMovie); selectedItem.IsPlayed = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.MarkAsUnWatched): TraktHelper.RemoveMovieFromWatchHistory(selectedMovie); selectedItem.IsPlayed = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddMovieToWatchList(selectedMovie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveMovieFromWatchList(selectedMovie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveMovieInUserList(selectedMovie, false); break; case ((int)ContextMenuItem.AddToLibrary): TraktHelper.AddMovieToCollection(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveMovieFromCollection(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.Related): TraktHelper.ShowRelatedMovies(selectedMovie); break; case ((int)ContextMenuItem.Rate): GUICommon.RateMovie(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowMovieShouts(selectedMovie); break; case ((int)ContextMenuItem.Cast): GUICreditsMovie.Movie = selectedMovie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)ContextMenuItem.Crew): GUICreditsMovie.Movie = selectedMovie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowMovieTrailersMenu(selectedMovie); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedMovie.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedMovie.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
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 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 OnItemSelected(GUIListItem item, GUIControl parent) { if (item == null) { return; } var listItem = item.TVTag as TraktListItem; if (listItem == null) { return; } PreviousSelectedIndex = Facade.SelectedListItemIndex; switch (listItem.Type) { case "movie": SelectedType = TraktItemType.movie; PublishMovieSkinProperties(listItem); string fanart = TmdbCache.GetMovieBackdropFilename((item as GUICustomListItem).Images.MovieImages); if (!string.IsNullOrEmpty(fanart)) { GUIImageHandler.LoadFanart(backdrop, fanart); } break; case "show": SelectedType = TraktItemType.show; PublishShowSkinProperties(listItem); fanart = TmdbCache.GetShowBackdropFilename((item as GUICustomListItem).Images.ShowImages); if (!string.IsNullOrEmpty(fanart)) { GUIImageHandler.LoadFanart(backdrop, fanart); } break; case "season": SelectedType = TraktItemType.season; PublishSeasonSkinProperties(listItem); fanart = TmdbCache.GetShowBackdropFilename((item as GUICustomListItem).Images.ShowImages); if (!string.IsNullOrEmpty(fanart)) { GUIImageHandler.LoadFanart(backdrop, fanart); } break; case "episode": SelectedType = TraktItemType.episode; PublishEpisodeSkinProperties(listItem); fanart = TmdbCache.GetShowBackdropFilename((item as GUICustomListItem).Images.ShowImages); if (!string.IsNullOrEmpty(fanart)) { GUIImageHandler.LoadFanart(backdrop, fanart); } break; case "person": SelectedType = TraktItemType.person; PublishPersonSkinProperties(listItem); break; } GUIUtils.SetProperty("#Trakt.List.ItemType", SelectedType.ToString()); GUIUtils.SetProperty("#Trakt.List.Rank", listItem.Rank.ToString()); }
/// <summary> /// Download all images attached to the GUI List Control /// TODO: Make part of a GUI Base Window /// </summary> /// <param name="itemsWithThumbs">List of images to get</param> internal static void GetImages(List <GUITmdbImage> itemsWithThumbs) { StopDownload = false; // split the downloads in 5+ groups and do multithreaded downloading int groupSize = (int)Math.Max(1, Math.Floor((double)itemsWithThumbs.Count / 5)); int groups = (int)Math.Ceiling((double)itemsWithThumbs.Count() / groupSize); for (int i = 0; i < groups; i++) { var groupList = new List <GUITmdbImage>(); for (int j = groupSize * i; j < groupSize * i + (groupSize * (i + 1) > itemsWithThumbs.Count ? itemsWithThumbs.Count - groupSize * i : groupSize); j++) { groupList.Add(itemsWithThumbs[j]); } // sort images so that images that already exist are displayed first //groupList.Sort((m1, m2) => //{ // int x = Convert.ToInt32(File.Exists(m1.MovieImages.Poster.LocalImageFilename(ArtworkType.MoviePoster))) + Convert.ToInt32(File.Exists(m1.MovieImages.Fanart.LocalImageFilename(ArtworkType.MovieFanart))); // int y = Convert.ToInt32(File.Exists(m2.MovieImages.Poster.LocalImageFilename(ArtworkType.MoviePoster))) + Convert.ToInt32(File.Exists(m2.MovieImages.Fanart.LocalImageFilename(ArtworkType.MovieFanart))); // return y.CompareTo(x); //}); new Thread(delegate(object o) { var items = (List <GUITmdbImage>)o; foreach (var item in items) { // check if we have the image in our cache var movieImages = TmdbCache.GetMovieImages(item.MovieImages.Id); if (movieImages == null) { continue; } item.MovieImages = movieImages; #region Poster // stop download if we have exited window if (StopDownload) { break; } string remoteThumb = TmdbCache.GetMoviePosterUrl(movieImages); string localThumb = TmdbCache.GetMoviePosterFilename(movieImages); if (!string.IsNullOrEmpty(remoteThumb) && !string.IsNullOrEmpty(localThumb)) { if (GUIImageHandler.DownloadImage(remoteThumb, localThumb)) { // notify that image has been downloaded item.NotifyPropertyChanged("Poster"); } } #endregion #region Fanart // stop download if we have exited window if (StopDownload) { break; } if (!TraktSettings.DownloadFanart) { continue; } string remoteFanart = TmdbCache.GetMovieBackdropUrl(movieImages);; string localFanart = TmdbCache.GetMovieBackdropFilename(movieImages); if (!string.IsNullOrEmpty(remoteFanart) && !string.IsNullOrEmpty(localFanart)) { if (GUIImageHandler.DownloadImage(remoteFanart, localFanart)) { // notify that image has been downloaded item.NotifyPropertyChanged("Fanart"); } } #endregion } }) { IsBackground = true, Name = "ImageDownloader" + i.ToString() }.Start(groupList); } }
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(); }
/// <summary> /// Download all images attached to the GUI List Control /// TODO: Make part of a GUI Base Window /// </summary> /// <param name="itemsWithThumbs">List of images to get</param> internal static void GetImages(List <GUITmdbImage> itemsWithThumbs) { StopDownload = false; // split the downloads in 5+ groups and do multithreaded downloading int groupSize = (int)Math.Max(1, Math.Floor((double)itemsWithThumbs.Count / 5)); int groups = (int)Math.Ceiling((double)itemsWithThumbs.Count() / groupSize); for (int i = 0; i < groups; i++) { var groupList = new List <GUITmdbImage>(); for (int j = groupSize * i; j < groupSize * i + (groupSize * (i + 1) > itemsWithThumbs.Count ? itemsWithThumbs.Count - groupSize * i : groupSize); j++) { groupList.Add(itemsWithThumbs[j]); } new Thread(delegate(object o) { var items = (List <GUITmdbImage>)o; foreach (var item in items) { string remoteThumb = string.Empty; string localThumb = string.Empty; #region Seasons / Episodes if (item.SeasonImages != null) { // check if we have the image in our cache var seasonImages = TmdbCache.GetSeasonImages(item.SeasonImages.Id, item.SeasonImages.Season); if (seasonImages == null) { continue; } item.SeasonImages = seasonImages; #region Show Season Poster // stop download if we have exited window if (StopDownload) { break; } remoteThumb = TmdbCache.GetSeasonPosterUrl(seasonImages); localThumb = TmdbCache.GetSeasonPosterFilename(seasonImages); if (!string.IsNullOrEmpty(remoteThumb) && !string.IsNullOrEmpty(localThumb)) { if (GUIImageHandler.DownloadImage(remoteThumb, localThumb)) { if (StopDownload) { break; } // notify that image has been downloaded item.NotifyPropertyChanged("SeasonPoster"); } } #endregion } #endregion #region Shows / Seasons / Episodes if (item.ShowImages != null) { #region Show Poster var showImages = TmdbCache.GetShowImages(item.ShowImages.Id); if (showImages == null) { continue; } item.ShowImages = showImages; // don't download the show poster if we have a season poster if (item.SeasonImages == null || item.SeasonImages.Posters == null || item.SeasonImages.Posters.Count == 0) { // stop download if we have exited window if (StopDownload) { break; } remoteThumb = TmdbCache.GetShowPosterUrl(showImages); localThumb = TmdbCache.GetShowPosterFilename(showImages); if (!string.IsNullOrEmpty(remoteThumb) && !string.IsNullOrEmpty(localThumb)) { if (GUIImageHandler.DownloadImage(remoteThumb, localThumb)) { if (StopDownload) { break; } // notify that image has been downloaded item.NotifyPropertyChanged("ShowPoster"); } } } #endregion #region Fanart // stop download if we have exited window if (StopDownload) { break; } if (!TraktSettings.DownloadFanart) { continue; } string remoteFanart = TmdbCache.GetShowBackdropUrl(showImages);; string localFanart = TmdbCache.GetShowBackdropFilename(showImages); if (!string.IsNullOrEmpty(remoteFanart) && !string.IsNullOrEmpty(localFanart)) { if (GUIImageHandler.DownloadImage(remoteFanart, localFanart)) { if (StopDownload) { break; } // notify that image has been downloaded item.NotifyPropertyChanged("Fanart"); } } #endregion } #endregion #region Movies if (item.MovieImages != null) { // check if we have the image in our cache var movieImages = TmdbCache.GetMovieImages(item.MovieImages.Id); if (movieImages == null) { continue; } item.MovieImages = movieImages; #region Movie Poster // stop download if we have exited window if (StopDownload) { break; } remoteThumb = TmdbCache.GetMoviePosterUrl(movieImages); localThumb = TmdbCache.GetMoviePosterFilename(movieImages); if (!string.IsNullOrEmpty(remoteThumb) && !string.IsNullOrEmpty(localThumb)) { if (GUIImageHandler.DownloadImage(remoteThumb, localThumb)) { if (StopDownload) { break; } // notify that image has been downloaded item.NotifyPropertyChanged("MoviePoster"); } } #endregion #region Fanart // stop download if we have exited window if (StopDownload) { break; } if (!TraktSettings.DownloadFanart) { continue; } string remoteFanart = TmdbCache.GetMovieBackdropUrl(movieImages);; string localFanart = TmdbCache.GetMovieBackdropFilename(movieImages); if (!string.IsNullOrEmpty(remoteFanart) && !string.IsNullOrEmpty(localFanart)) { if (GUIImageHandler.DownloadImage(remoteFanart, localFanart)) { if (StopDownload) { break; } // notify that image has been downloaded item.NotifyPropertyChanged("Fanart"); } } #endregion } #endregion #region People if (item.PeopleImages != null) { // check if we have the image in our cache var peopleImages = TmdbCache.GetPersonImages(item.PeopleImages.Id); if (peopleImages == null) { continue; } item.PeopleImages = peopleImages; #region Headshot // stop download if we have exited window if (StopDownload) { break; } remoteThumb = TmdbCache.GetPersonHeadshotUrl(peopleImages); localThumb = TmdbCache.GetPersonHeadshotFilename(peopleImages); if (!string.IsNullOrEmpty(remoteThumb) && !string.IsNullOrEmpty(localThumb)) { if (GUIImageHandler.DownloadImage(remoteThumb, localThumb)) { if (StopDownload) { break; } // notify that image has been downloaded item.NotifyPropertyChanged("HeadShot"); } } #endregion } #endregion } }) { IsBackground = true, Name = "ImageDownloader" + i.ToString() }.Start(groupList); } }