コード例 #1
0
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem;

            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;

            // 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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedAnticipatedItem = selectedItem.TVTag as TraktMovieAnticipated;

            if (selectedAnticipatedItem == 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, selectedAnticipatedItem.Movie, false);

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

            switch (dlg.SelectedId)
            {
            case ((int)MediaContextMenuItem.MarkAsWatched):
                TraktHelper.AddMovieToWatchHistory(selectedAnticipatedItem.Movie);
                selectedItem.IsPlayed = true;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                LoadAnticipatedMovies(CurrentPage);
                break;

            case ((int)MediaContextMenuItem.MarkAsUnWatched):
                TraktHelper.RemoveMovieFromWatchHistory(selectedAnticipatedItem.Movie);
                selectedItem.IsPlayed = false;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)MediaContextMenuItem.AddToWatchList):
                TraktHelper.AddMovieToWatchList(selectedAnticipatedItem.Movie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.AnticipatedMoviesHideWatchlisted)
                {
                    LoadAnticipatedMovies(CurrentPage);
                }
                break;

            case ((int)MediaContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveMovieFromWatchList(selectedAnticipatedItem.Movie, true);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)MediaContextMenuItem.AddToList):
                TraktHelper.AddRemoveMovieInUserList(selectedAnticipatedItem.Movie, false);
                break;

            case ((int)MediaContextMenuItem.AddToLibrary):
                TraktHelper.AddMovieToCollection(selectedAnticipatedItem.Movie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                LoadAnticipatedMovies(CurrentPage);
                break;

            case ((int)MediaContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromCollection(selectedAnticipatedItem.Movie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)MediaContextMenuItem.Related):
                TraktHelper.ShowRelatedMovies(selectedAnticipatedItem.Movie);
                break;

            case ((int)MediaContextMenuItem.Rate):
                GUICommon.RateMovie(selectedAnticipatedItem.Movie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                LoadAnticipatedMovies(CurrentPage);
                break;

            case ((int)MediaContextMenuItem.Filters):
                if (GUICommon.ShowMovieFiltersMenu())
                {
                    PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
                    UpdateButtonState();
                    LoadAnticipatedMovies(CurrentPage);
                }
                break;

            case ((int)MediaContextMenuItem.Shouts):
                TraktHelper.ShowMovieShouts(selectedAnticipatedItem.Movie);
                break;

            case ((int)MediaContextMenuItem.Cast):
                GUICreditsMovie.Movie  = selectedAnticipatedItem.Movie;
                GUICreditsMovie.Type   = GUICreditsMovie.CreditType.Cast;
                GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie);
                break;

            case ((int)MediaContextMenuItem.Crew):
                GUICreditsMovie.Movie  = selectedAnticipatedItem.Movie;
                GUICreditsMovie.Type   = GUICreditsMovie.CreditType.Crew;
                GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie);
                break;

            case ((int)MediaContextMenuItem.Trailers):
                GUICommon.ShowMovieTrailersMenu(selectedAnticipatedItem.Movie);
                break;

            case ((int)MediaContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

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

            case ((int)MediaContextMenuItem.SearchTorrent):
                string loadPar = selectedAnticipatedItem.Movie.Title;
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
コード例 #4
0
        /// <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((s1, s2) =>
                //{
                //    int x = Convert.ToInt32(File.Exists(s1.ShowImages.Poster.LocalImageFilename(ArtworkType.ShowPoster))) + Convert.ToInt32(File.Exists(s1.ShowImages.Fanart.LocalImageFilename(ArtworkType.ShowFanart)));
                //    int y = Convert.ToInt32(File.Exists(s2.ShowImages.Poster.LocalImageFilename(ArtworkType.ShowPoster))) + Convert.ToInt32(File.Exists(s2.ShowImages.Fanart.LocalImageFilename(ArtworkType.ShowFanart)));
                //    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 showImages = TmdbCache.GetShowImages(item.ShowImages.Id);
                        if (showImages == null)
                        {
                            continue;
                        }

                        item.ShowImages = showImages;

                        #region Poster
                        // stop download if we have exited window
                        if (StopDownload)
                        {
                            break;
                        }

                        string remoteThumb = TmdbCache.GetShowPosterUrl(showImages);
                        string 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("Poster");
                            }
                        }
                        #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
                    }
                })
                {
                    IsBackground = true,
                    Name         = "ImageDownloader" + i.ToString()
                }.Start(groupList);
            }
        }
コード例 #5
0
        /// <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);
            }
        }
コード例 #6
0
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem as GUIShowListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedShow = selectedItem.TVTag as TraktShowSummary;

            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;

            listItem = new GUIListItem(Translation.DismissRecommendation);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.DismissRecommendation;

            // Show Season Information
            listItem = new GUIListItem(Translation.ShowSeasonInfo);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo;

            // Add/Remove Watchlist
            if (!selectedShow.IsWatchlisted())
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

            listItem = new GUIListItem(Translation.AddToList);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToList;

            if (TraktHelper.IsTrailersAvailableAndEnabled)
            {
                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.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;

            if (TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for show with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for show with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
            }

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.DismissRecommendation):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                DismissRecommendation(selectedShow);
                if (_RecommendedShows.Count() > 1)
                {
                    var showsToExcept = new List <TraktShowSummary>();
                    showsToExcept.Add(selectedShow);
                    _RecommendedShows = RecommendedShows.Except(showsToExcept);
                }
                else
                {
                    // reload, none left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _RecommendedShows = null;
                }
                LoadRecommendedShows();
                break;

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

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddShowToWatchList(selectedShow);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveShowFromWatchList(selectedShow);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveShowInUserList(selectedShow, false);
                break;

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

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

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

            case ((int)ContextMenuItem.Rate):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                if (GUICommon.RateShow(selectedShow))
                {
                    // remove from recommendations
                    if (_RecommendedShows.Count() > 1)
                    {
                        var showsToExcept = new List <TraktShowSummary>();
                        showsToExcept.Add(selectedShow);
                        _RecommendedShows = RecommendedShows.Except(showsToExcept);
                    }
                    else
                    {
                        // reload, none left
                        ClearProperties();
                        GUIControl.ClearControl(GetID, Facade.GetID);
                        _RecommendedShows = null;
                    }
                    LoadRecommendedShows();
                }
                break;

            case ((int)ContextMenuItem.Cast):
                GUICreditsShow.Show   = selectedShow;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Cast;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.Crew):
                GUICreditsShow.Show   = selectedShow;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Crew;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
コード例 #7
0
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            var selectedItem = this.Facade.SelectedListItem as GUIShowListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedShow = selectedItem.TVTag as TraktShowSummary;

            if (selectedShow == null)
            {
                return;
            }

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

            // Show Season Information
            listItem = new GUIListItem(Translation.ShowSeasonInfo);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo;

            // Hide/Show Watched items
            listItem = new GUIListItem(HideWatched ? Translation.ShowWatched : Translation.HideWatched);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.HideShowWatched;

            // Mark Show As Watched
            listItem = new GUIListItem(Translation.MarkAsWatched);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;

            // Add Show to Library
            listItem = new GUIListItem(Translation.AddToLibrary);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToLibrary;

            // Add/Remove Watchlist
            if (!selectedShow.IsWatchlisted())
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

            // Add to Custom List
            listItem = new GUIListItem(Translation.AddToList);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddToList;

            // Cast and Crew
            listItem = new GUIListItem(Translation.Cast);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Cast;

            listItem = new GUIListItem(Translation.Crew);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Crew;

            // Related Shows
            listItem = new GUIListItem(Translation.RelatedShows);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            // Rate Show
            listItem = new GUIListItem(Translation.RateShow);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Rate;

            // Shouts
            listItem = new GUIListItem(Translation.Comments);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            // Change Layout
            listItem = new GUIListItem(Translation.ChangeLayout);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ChangeLayout;

            // Trailers
            if (TraktHelper.IsTrailersAvailableAndEnabled)
            {
                listItem = new GUIListItem(Translation.Trailers);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Trailers;
            }

            if (TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for show with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
            }

            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for show with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
            }

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON());
                break;

            case ((int)ContextMenuItem.HideShowWatched):
                HideWatched = !HideWatched;
                if (hideWatchedButton != null)
                {
                    hideWatchedButton.Selected = HideWatched;
                }
                dictRelatedShows.Remove(relatedShow.Slug);
                LoadRelatedShows();
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                GUICommon.MarkShowAsWatched(selectedShow);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                GUICommon.AddShowToCollection(selectedShow);
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddShowToWatchList(selectedShow);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveShowFromWatchList(selectedShow);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveShowInUserList(selectedShow, false);
                break;

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

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

            case ((int)ContextMenuItem.Related):
                var relShow = new RelatedShow
                {
                    TraktId = selectedShow.Ids.Trakt,
                    TmdbId  = selectedShow.Ids.Tmdb,
                    TvdbId  = selectedShow.Ids.Tvdb,
                    Title   = selectedShow.Title,
                    Year    = selectedShow.Year
                };
                relatedShow = relShow;
                LoadRelatedShows();
                GUIUtils.SetProperty("#Trakt.Related.Show", relatedShow.Title);
                RelationChanged = true;
                break;

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateShow(selectedShow);
                OnShowSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.Cast):
                GUICreditsShow.Show   = selectedShow;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Cast;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.Crew):
                GUICreditsShow.Show   = selectedShow;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Crew;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
コード例 #8
0
        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();
        }
コード例 #9
0
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem as GUIShowListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedShow = selectedItem.Show;

            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, selectedShow, false);

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

            switch (dlg.SelectedId)
            {
            case ((int)MediaContextMenuItem.AddToWatchList):
                TraktHelper.AddShowToWatchList(selectedShow);
                OnItemSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.CreditShowsHideWatchlisted)
                {
                    LoadCredits();
                }
                break;

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

            case ((int)MediaContextMenuItem.MarkAsWatched):
                GUICommon.MarkShowAsWatched(selectedShow);
                if (TraktSettings.CreditShowsHideWatched)
                {
                    LoadCredits();
                }
                break;

            case ((int)MediaContextMenuItem.AddToLibrary):
                GUICommon.AddShowToCollection(selectedShow);
                if (TraktSettings.CreditShowsHideCollected)
                {
                    LoadCredits();
                }
                break;

            case ((int)MediaContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveShowFromWatchList(selectedShow);
                OnItemSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)MediaContextMenuItem.AddToList):
                TraktHelper.AddRemoveShowInUserList(selectedShow, false);
                break;

            case ((int)MediaContextMenuItem.Filters):
                if (ShowTVShowFiltersMenu())
                {
                    PreviousSelectedIndex = 0;
                    UpdateButtonState();
                    LoadCredits();
                }
                break;

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

            case ((int)MediaContextMenuItem.Cast):
                GUICreditsShow.Show   = selectedShow;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Cast;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)MediaContextMenuItem.Crew):
                GUICreditsShow.Show   = selectedShow;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Crew;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

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

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

            case ((int)MediaContextMenuItem.Rate):
                GUICommon.RateShow(selectedShow);
                OnItemSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster");
                if (TraktSettings.CreditShowsHideRated)
                {
                    LoadCredits();
                }
                break;

            case ((int)MediaContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
コード例 #10
0
        /// <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, bool downloadFanart = true)
        {
            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)
                    {
                        if (item.PeopleImages != null)
                        {
                            // stop download if we have exited window
                            if (StopDownload)
                            {
                                break;
                            }

                            var peopleImages = TmdbCache.GetPersonImages(item.PeopleImages.Id);
                            if (peopleImages == null)
                            {
                                return;
                            }

                            item.PeopleImages = peopleImages;

                            string remoteThumb = TmdbCache.GetPersonHeadshotUrl(peopleImages);
                            string localThumb  = TmdbCache.GetPersonHeadshotFilename(peopleImages);

                            if (!string.IsNullOrEmpty(remoteThumb) && !string.IsNullOrEmpty(localThumb))
                            {
                                if (GUIImageHandler.DownloadImage(remoteThumb, localThumb))
                                {
                                    // notify that image has been downloaded
                                    item.NotifyPropertyChanged("HeadShot");
                                }
                            }

                            // not all methods have Fanart for people
                            // only get it, if we need it
                            //if (downloadFanart && item.PeopleImages.Fanart != null)
                            //{
                            //    remoteThumb = TraktSettings.DownloadFullSizeFanart ? item.PeopleImages.Fanart.FullSize : item.PeopleImages.Fanart.MediumSize;
                            //    localThumb = item.PeopleImages.Fanart.LocalImageFilename(ArtworkType.PersonFanart);

                            //    if (!string.IsNullOrEmpty(remoteThumb) && !string.IsNullOrEmpty(localThumb))
                            //    {
                            //        if (GUIImageHandler.DownloadImage(remoteThumb, localThumb))
                            //        {
                            //            // notify that image has been downloaded
                            //            item.NotifyPropertyChanged("Fanart");
                            //        }
                            //    }
                            //}
                        }
                    }
                })
                {
                    IsBackground = true,
                    Name         = "ImageDownloader" + i.ToString()
                }.Start(groupList);
            }
        }
コード例 #11
0
        /// <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((s1, s2) =>
                //{
                //    int x = Convert.ToInt32(File.Exists(s1.EpisodeImages.ScreenShot.LocalImageFilename(ArtworkType.EpisodeImage))) + (s1.ShowImages == null ? 0 : Convert.ToInt32(File.Exists(s1.ShowImages.Fanart.LocalImageFilename(ArtworkType.ShowFanart))));
                //    int y = Convert.ToInt32(File.Exists(s2.EpisodeImages.ScreenShot.LocalImageFilename(ArtworkType.EpisodeImage))) + (s2.ShowImages == null ? 0 : Convert.ToInt32(File.Exists(s2.ShowImages.Fanart.LocalImageFilename(ArtworkType.ShowFanart))));
                //    return y.CompareTo(x);
                //});

                new Thread(delegate(object o)
                {
                    var items = (List <GUITmdbImage>)o;
                    foreach (var item in items)
                    {
                        #region Episode Image
                        // stop download if we have exited window
                        if (StopDownload)
                        {
                            break;
                        }

                        bool downloadShowBackdrop = false;

                        string remoteThumb = string.Empty;
                        string localThumb  = string.Empty;

                        TmdbEpisodeImages episodeImages = null;
                        TmdbShowImages showImages       = null;

                        // Don't try to get episode images that air after today, they most likely do not exist and contain spoilers
                        if (item.EpisodeImages.AirDate != null && item.EpisodeImages.AirDate.ToDateTime() <= Convert.ToDateTime(DateTime.Now.ToShortDateString()))
                        {
                            episodeImages = TmdbCache.GetEpisodeImages(item.EpisodeImages.Id, item.EpisodeImages.Season, item.EpisodeImages.Episode);
                            if (episodeImages != null)
                            {
                                item.EpisodeImages = episodeImages;
                            }
                        }

                        showImages = TmdbCache.GetShowImages(item.EpisodeImages.Id);
                        if (showImages != null)
                        {
                            item.ShowImages = showImages;
                        }

                        // if the episode image exists get it, otherwise get the show fanart
                        if (episodeImages != null && episodeImages.Stills != null && episodeImages.Stills.Count > 0)
                        {
                            remoteThumb = TmdbCache.GetEpisodeThumbUrl(episodeImages);
                            localThumb  = TmdbCache.GetEpisodeThumbFilename(episodeImages);
                        }
                        else
                        {
                            downloadShowBackdrop = true;

                            // use fanart for episode image, get one with a logo
                            remoteThumb = TmdbCache.GetShowBackdropUrl(item.ShowImages, true);
                            localThumb  = TmdbCache.GetShowBackdropFilename(item.ShowImages, true);
                        }

                        if (!string.IsNullOrEmpty(remoteThumb) && !string.IsNullOrEmpty(localThumb))
                        {
                            if (GUIImageHandler.DownloadImage(remoteThumb, localThumb))
                            {
                                if (StopDownload)
                                {
                                    break;
                                }

                                // notify that image has been downloaded
                                item.NotifyPropertyChanged(downloadShowBackdrop ? "ShowScreenStillAsBackdrop" : "ShowScreenStill");
                            }
                        }
                        #endregion

                        #region Fanart
                        // stop download if we have exited window
                        if (StopDownload)
                        {
                            break;
                        }
                        if (!TraktSettings.DownloadFanart)
                        {
                            continue;
                        }

                        remoteThumb = TmdbCache.GetShowBackdropUrl(item.ShowImages);
                        localThumb  = TmdbCache.GetShowBackdropFilename(item.ShowImages);

                        if (!string.IsNullOrEmpty(remoteThumb) && !string.IsNullOrEmpty(localThumb))
                        {
                            if (GUIImageHandler.DownloadImage(remoteThumb, localThumb))
                            {
                                if (StopDownload)
                                {
                                    break;
                                }

                                // notify that image has been downloaded
                                item.NotifyPropertyChanged("Fanart");
                            }
                        }
                        #endregion
                    }
                })
                {
                    IsBackground = true,
                    Name         = "ImageDownloader" + i.ToString()
                }.Start(groupList);
            }
        }
コード例 #12
0
        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 GUIEpisodeListItem;

            if (selectedItem == null)
            {
                return;
            }

            var calendarItem = selectedItem.TVTag as TraktShowCalendar;

            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;

            // Show Season Information
            listItem = new GUIListItem(Translation.ShowSeasonInfo);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo;

            // Hide Show
            listItem = new GUIListItem(Translation.HideShow);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.HideShow;

            // Hide Season
            //listItem = new GUIListItem(Translation.HideSeason);
            //dlg.Add(listItem);
            //listItem.ItemId = (int)ContextMenuItem.HideSeason;

            // Related Shows
            listItem = new GUIListItem(Translation.RelatedShows);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            // Rate
            listItem = new GUIListItem(Translation.Rate + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Rate;

            // Mark As Watched
            if (!calendarItem.Episode.IsWatched(calendarItem.Show))
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
            }

            // Mark As UnWatched
            if (calendarItem.Episode.IsWatched(calendarItem.Show))
            {
                listItem = new GUIListItem(Translation.MarkAsUnWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched;
            }

            // Add/Remove Show Watchlist
            if (!calendarItem.Show.IsWatchlisted())
            {
                listItem = new GUIListItem(Translation.AddShowToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddShowToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveShowFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveShowFromWatchList;
            }

            // Add/Remove Episode Watchlist
            if (!calendarItem.Episode.IsWatchlisted())
            {
                listItem = new GUIListItem(Translation.AddEpisodeToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddEpisodeToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveEpisodeFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveEpisodeFromWatchList;
            }

            // Add Show to Custom List
            listItem = new GUIListItem(Translation.AddShowToList + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddShowToList;

            // Add Episode to Custom List
            listItem = new GUIListItem(Translation.AddEpisodeToList + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.AddEpisodeToList;

            // Shouts
            listItem = new GUIListItem(Translation.Comments);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

            // Add/Remove Libary
            if (!calendarItem.Episode.IsCollected(calendarItem.Show))
            {
                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;
            }

            // Watchlist Filter
            if (CurrentCalendar == CalendarType.UserShows)
            {
                if (TraktSettings.CalendarHideTVShowsInWatchList)
                {
                    listItem = new GUIListItem(Translation.ShowTVShowsInWatchlist);
                }
                else
                {
                    listItem = new GUIListItem(Translation.HideTVShowsInWatchlist);
                }

                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.WatchlistFilter;
            }

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.View):
                ShowViewMenu();
                break;

            case ((int)ContextMenuItem.StartDate):
                ShowStartDateMenu();
                break;

            case ((int)ContextMenuItem.MaxDays):
                ShowMaxDaysMenu();
                break;

            case ((int)ContextMenuItem.HideShow):
                TraktHelper.AddHiddenShow(calendarItem.Show, "calendar");
                FilterHiddenShows = true;
                LoadCalendar();
                break;

            case ((int)ContextMenuItem.HideSeason):
                break;

            case ((int)ContextMenuItem.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, calendarItem.Show.ToJSON());
                break;

            case ((int)ContextMenuItem.Related):
                TraktHelper.ShowRelatedShows(calendarItem.Show);
                break;

            case ((int)ContextMenuItem.Shouts):
                TraktHelper.ShowEpisodeShouts(calendarItem.Show, calendarItem.Episode);
                break;

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateEpisode(calendarItem.Show, calendarItem.Episode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                TraktHelper.AddEpisodeToWatchHistory(calendarItem.Episode);
                TraktCache.AddEpisodeToWatchHistory(calendarItem.Show, calendarItem.Episode);
                Facade.SelectedListItem.IsPlayed = true;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                TraktHelper.RemoveEpisodeFromWatchHistory(calendarItem.Episode);
                TraktCache.RemoveEpisodeFromWatchHistory(calendarItem.Show, calendarItem.Episode);
                Facade.SelectedListItem.IsPlayed = false;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.AddShowToWatchList):
                TraktHelper.AddShowToWatchList(calendarItem.Show);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddEpisodeToWatchList):
                TraktHelper.AddEpisodeToWatchList(calendarItem.Episode);
                TraktCache.AddEpisodeToWatchlist(calendarItem.Show, calendarItem.Episode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveShowFromWatchList):
                TraktHelper.RemoveShowFromWatchList(calendarItem.Show);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveEpisodeFromWatchList):
                TraktHelper.RemoveEpisodeFromWatchList(calendarItem.Episode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddEpisodeToList):
                TraktHelper.AddRemoveEpisodeInUserList(calendarItem.Episode, false);
                break;

            case ((int)ContextMenuItem.AddShowToList):
                TraktHelper.AddRemoveShowInUserList(calendarItem.Show, false);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddEpisodeToCollection(calendarItem.Episode);
                TraktCache.AddEpisodeToCollection(calendarItem.Show, calendarItem.Episode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveEpisodeFromCollection(calendarItem.Episode);
                TraktCache.RemoveEpisodeFromCollection(calendarItem.Show, calendarItem.Episode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.Cast):
                GUICreditsShow.Show   = calendarItem.Show;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Cast;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.Crew):
                GUICreditsShow.Show   = calendarItem.Show;
                GUICreditsShow.Type   = GUICreditsShow.CreditType.Crew;
                GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages);
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow);
                break;

            case ((int)ContextMenuItem.Trailers):
                if (calendarItem != null)
                {
                    GUICommon.ShowTVShowTrailersMenu(calendarItem.Show, calendarItem.Episode);
                }
                break;

            case ((int)ContextMenuItem.WatchlistFilter):
                TraktSettings.CalendarHideTVShowsInWatchList = !TraktSettings.CalendarHideTVShowsInWatchList;
                SetHideWatchlisted();
                LoadCalendar();
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
コード例 #13
0
        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 GUIMovieListItem).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 GUIShowListItem).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 GUIMovieListItem).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 GUIShowListItem).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();
        }
コード例 #14
0
        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());
        }