Ejemplo n.º 1
0
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktUserList selectedList = (TraktUserList)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

            // only allow add/delete/update if viewing your own lists
            if (CurrentUser == TraktSettings.Username)
            {
                listItem = new GUIListItem(Translation.CreateList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Create;

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

                listItem = new GUIListItem(Translation.DeleteList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Delete;
            }
            else
            {
                // copy a friends list
                listItem = new GUIListItem(Translation.CopyList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Copy;
            }

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

            TraktList currentList = new TraktList
            {
                Name        = selectedList.Name,
                Description = selectedList.Description,
                Privacy     = selectedList.Privacy,
                Slug        = selectedList.Slug,
                ShowNumbers = selectedList.ShowNumbers,
                AllowShouts = selectedList.AllowShouts
            };

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.Create):
                TraktList list = new TraktList();
                if (TraktLists.GetListDetailsFromUser(ref list))
                {
                    if (Lists.ToList().Exists(l => l.Name == list.Name))
                    {
                        // list with that name already exists
                        GUIUtils.ShowNotifyDialog(Translation.Lists, Translation.ListNameAlreadyExists);
                        return;
                    }
                    TraktLogger.Info("Creating new '{0}' list '{1}'", list.Privacy, list.Name);
                    CreateList(list);
                }
                break;

            case ((int)ContextMenuItem.Delete):
                DeleteList(selectedList);
                break;

            case ((int)ContextMenuItem.Edit):
                if (TraktLists.GetListDetailsFromUser(ref currentList))
                {
                    TraktLogger.Info("Editing list '{0}'", currentList.Slug);
                    EditList(currentList);
                }
                break;

            case ((int)ContextMenuItem.Copy):
                if (TraktLists.GetListDetailsFromUser(ref currentList))
                {
                    CopyList(selectedList, currentList);
                }
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 2
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedShow = selectedItem.TVTag as TraktShow;

            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 Watch List
            if (!selectedShow.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveShowInUserList(selectedShow.Title, selectedShow.Year.ToString(), selectedShow.Tvdb, false);
                break;

            case ((int)ContextMenuItem.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 <TraktShow>();
                        showsToExcept.Add(selectedShow);
                        _RecommendedShows = RecommendedShows.Except(showsToExcept);
                    }
                    else
                    {
                        // reload, none left
                        ClearProperties();
                        GUIControl.ClearControl(GetID, Facade.GetID);
                        _RecommendedShows = null;
                    }
                    LoadRecommendedShows();
                }
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, 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();
        }
Ejemplo n.º 3
0
        internal static void CreateShowsContextMenu(ref IDialogbox dlg, TraktShow show, bool dashboard)
        {
            GUIListItem listItem = null;

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

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

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

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

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

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

            // Filters
            if (TraktSettings.FilterTrendingOnDashboard || !dashboard)
            {
                listItem = new GUIListItem(Translation.Filters + "...");
                dlg.Add(listItem);
                listItem.ItemId = (int)MediaContextMenuItem.Filters;
            }

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

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

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

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

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

            // Change Layout
            if (!dashboard)
            {
                listItem = new GUIListItem(Translation.ChangeLayout);
                dlg.Add(listItem);
                listItem.ItemId = (int)MediaContextMenuItem.ChangeLayout;
            }

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

            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for show with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)MediaContextMenuItem.SearchTorrent;
            }
        }
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktMovie selectedMovie = (TraktMovie)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

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

            // Mark As Watched
            // This should remove item from recommendations if executed
            if (!selectedMovie.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
            }

            // Add/Remove Watch List
            if (!selectedMovie.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

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

            // 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.InCollection && !TraktSettings.KeepTraktLibraryClean)
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }

            if (selectedMovie.InCollection)
            {
                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.Shouts + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

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

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

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

            if (!selectedMovie.InCollection && 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.DismissRecommendation):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                DismissRecommendation(selectedMovie);
                if (_RecommendedMovies.Count() > 1)
                {
                    var moviesToExcept = new List <TraktMovie>();
                    moviesToExcept.Add(selectedMovie);
                    _RecommendedMovies = RecommendedMovies.Except(moviesToExcept);
                }
                else
                {
                    // reload, none left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _RecommendedMovies = null;
                }
                LoadRecommendedMovies();
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                MarkMovieAsWatched(selectedMovie);
                if (_RecommendedMovies.Count() > 1)
                {
                    var moviesToExcept = new List <TraktMovie>();
                    moviesToExcept.Add(selectedMovie);
                    _RecommendedMovies = RecommendedMovies.Except(moviesToExcept);
                }
                else
                {
                    // reload, none left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _RecommendedMovies = null;
                }
                LoadRecommendedMovies();
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                AddMovieToWatchList(selectedMovie);
                selectedMovie.InWatchList = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveMovieFromWatchList(selectedMovie);
                selectedMovie.InWatchList = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveMovieInUserList(selectedMovie.Title, selectedMovie.Year, selectedMovie.IMDBID, false);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                AddMovieToLibrary(selectedMovie);
                selectedMovie.InCollection = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                RemoveMovieFromLibrary(selectedMovie);
                selectedMovie.InCollection = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.Related):
                RelatedMovie relatedMovie = new RelatedMovie();
                relatedMovie.IMDbId           = selectedMovie.IMDBID;
                relatedMovie.Title            = selectedMovie.Title;
                GUIRelatedMovies.relatedMovie = relatedMovie;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedMovies);
                break;

            case ((int)ContextMenuItem.Rate):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                if (GUICommon.RateMovie(selectedMovie))
                {
                    // also mark as watched
                    MarkMovieAsWatched(selectedMovie);
                    // remove from recommendations
                    if (_RecommendedMovies.Count() > 1)
                    {
                        var moviesToExcept = new List <TraktMovie>();
                        moviesToExcept.Add(selectedMovie);
                        _RecommendedMovies = RecommendedMovies.Except(moviesToExcept);
                    }
                    else
                    {
                        // reload, none left
                        ClearProperties();
                        GUIControl.ClearControl(GetID, Facade.GetID);
                        _RecommendedMovies = null;
                    }
                    LoadRecommendedMovies();
                }
                break;

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.movie;
                GUIShouts.MovieInfo = new MovieShout {
                    IMDbId = selectedMovie.IMDBID, TMDbId = selectedMovie.TMDBID, Title = selectedMovie.Title, Year = selectedMovie.Year
                };
                GUIShouts.Fanart = selectedMovie.Images.FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowMovieTrailersMenu(selectedMovie);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout);
                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();
        }
Ejemplo n.º 5
0
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktShow selectedShow = (TraktShow)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            case ((int)ContextMenuItem.AddToWatchList):
                AddShowToWatchList(selectedShow);
                selectedShow.InWatchList = true;
                OnShowSelected(selectedItem, Facade);
                selectedShow.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveShowFromWatchList(selectedShow);
                selectedShow.InWatchList = false;
                OnShowSelected(selectedItem, Facade);
                selectedShow.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveShowInUserList(selectedShow.Title, selectedShow.Year.ToString(), selectedShow.Tvdb, false);
                break;

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

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.show;
                GUIShouts.ShowInfo  = new ShowShout {
                    IMDbId = selectedShow.Imdb, TVDbId = selectedShow.Tvdb, Title = selectedShow.Title
                };
                GUIShouts.Fanart = selectedShow.Images.FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

            case ((int)ContextMenuItem.Related):
                RelatedShow relShow = new RelatedShow
                {
                    Title  = selectedShow.Title,
                    TVDbId = selectedShow.Tvdb
                };
                relatedShow = relShow;
                LoadRelatedShows();
                GUIUtils.SetProperty("#Trakt.Related.Show", relatedShow.Title);
                RelationChanged = true;
                break;

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

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

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 6
0
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktShout selectedShout = (TraktShout)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

            if (ShoutType == ShoutTypeEnum.episode)
            {
                listItem = new GUIListItem(Translation.NextEpisode);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.NextEpisode;

                if (int.Parse(EpisodeInfo.EpisodeIdx) > 1)
                {
                    listItem = new GUIListItem(Translation.PreviousEpisode);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.PrevEpisode;
                }
            }

            listItem = new GUIListItem(TraktSettings.HideSpoilersOnShouts ? Translation.ShowSpoilers : Translation.HideSpoilers);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Spoilers;

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.Spoilers):
                TraktSettings.HideSpoilersOnShouts = !TraktSettings.HideSpoilersOnShouts;
                if (hideSpoilersButton != null)
                {
                    hideSpoilersButton.Selected = TraktSettings.HideSpoilersOnShouts;
                }
                PublishShoutSkinProperties(selectedShout);
                break;

            case ((int)ContextMenuItem.NextEpisode):
                GetNextEpisodeShouts();
                break;

            case ((int)ContextMenuItem.PrevEpisode):
                GetPrevEpisodeShouts();
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 7
0
        internal static void CreateTrendingMoviesContextMenu(ref IDialogbox dlg, TraktMovie movie, bool dashboard)
        {
            GUIListItem listItem = null;

            // Mark As Watched
            if (!movie.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.MarkAsWatched;
            }

            // Mark As UnWatched
            if (movie.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsUnWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.MarkAsUnWatched;
            }

            // Add/Remove Watch List
            if (!movie.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.RemoveFromWatchList;
            }

            // Add to Custom list
            listItem = new GUIListItem(Translation.AddToList + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)TrendingContextMenuItem.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 (!movie.InCollection && !TraktSettings.KeepTraktLibraryClean)
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.AddToLibrary;
            }

            if (movie.InCollection)
            {
                listItem = new GUIListItem(Translation.RemoveFromLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.RemoveFromLibrary;
            }

            // Filters
            if (!dashboard)
            {
                listItem = new GUIListItem(Translation.Filters + "...");
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.Filters;
            }

            // Related Movies
            listItem = new GUIListItem(Translation.RelatedMovies + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)TrendingContextMenuItem.Related;

            // Rate Movie
            listItem = new GUIListItem(Translation.RateMovie);
            dlg.Add(listItem);
            listItem.ItemId = (int)TrendingContextMenuItem.Rate;

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

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

            // Change Layout
            if (GUIWindowManager.ActiveWindow == (int)TraktGUIWindows.TrendingMovies)
            {
                listItem = new GUIListItem(Translation.ChangeLayout);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.ChangeLayout;
            }

            if (!movie.InCollection && TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                // Search for movie with mpNZB
                listItem = new GUIListItem(Translation.SearchWithMpNZB);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.SearchWithMpNZB;
            }

            if (!movie.InCollection && TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for movie with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.SearchTorrent;
            }
        }
Ejemplo n.º 8
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktUserListItem userListItem = (TraktUserListItem)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

            if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.episode)
            {
                // Mark As Watched
                if (!userListItem.Watched)
                {
                    listItem = new GUIListItem(Translation.MarkAsWatched);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
                }

                // Mark As UnWatched
                if (userListItem.Watched)
                {
                    listItem = new GUIListItem(Translation.MarkAsUnWatched);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched;
                }
            }

            if (SelectedType != TraktItemType.season)
            {
                // Add/Remove Watch List
                if (!userListItem.InWatchList)
                {
                    listItem = new GUIListItem(Translation.AddToWatchList);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
                }
                else
                {
                    listItem = new GUIListItem(Translation.RemoveFromWatchList);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
                }
            }

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

            // Remove from Custom list (Only if current user is the active user)
            if (TraktSettings.Username == CurrentUser)
            {
                listItem = new GUIListItem(Translation.RemoveFromList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromList;
            }

            if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.episode)
            {
                // Add to Library
                // Don't allow if it will be removed again on next sync
                // movie could be part of a DVD collection
                if (!userListItem.InCollection && !TraktSettings.KeepTraktLibraryClean)
                {
                    listItem = new GUIListItem(Translation.AddToLibrary);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
                }

                if (userListItem.InCollection)
                {
                    listItem = new GUIListItem(Translation.RemoveFromLibrary);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary;
                }
            }

            // Related Movies/Shows
            listItem = new GUIListItem(SelectedType == TraktItemType.movie ? Translation.RelatedMovies : Translation.RelatedShows + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Related;

            if (SelectedType != TraktItemType.season)
            {
                // Rate
                listItem = new GUIListItem(Translation.Rate + "...");
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.Rate;

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

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

            // Search with mpNZB
            if (TraktHelper.IsMpNZBAvailableAndEnabled)
            {
                if ((userListItem.Movie != null && !userListItem.Movie.InCollection) || userListItem.Episode != null)
                {
                    listItem = new GUIListItem(Translation.SearchWithMpNZB);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB;
                }
            }

            // Search with MyTorrents
            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                if ((userListItem.Movie != null && !userListItem.Movie.InCollection) || userListItem.Episode != null)
                {
                    listItem = new GUIListItem(Translation.SearchTorrent);
                    dlg.Add(listItem);
                    listItem.ItemId = (int)ContextMenuItem.SearchTorrent;
                }
            }

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

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.MarkAsWatched):
                MarkItemAsWatched(userListItem);
                if (userListItem.Plays == 0)
                {
                    userListItem.Plays = 1;
                }
                userListItem.Watched  = true;
                selectedItem.IsPlayed = true;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                MarkItemAsUnWatched(userListItem);
                userListItem.Watched  = false;
                selectedItem.IsPlayed = false;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                AddItemToWatchList(userListItem);
                userListItem.InWatchList = true;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveItemFromWatchList(userListItem);
                userListItem.InWatchList = false;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddToList):
                if (SelectedType == TraktItemType.movie)
                {
                    TraktHelper.AddRemoveMovieInUserList(userListItem.Title, userListItem.Year, userListItem.ImdbId, false);
                }
                else if (SelectedType == TraktItemType.show)
                {
                    TraktHelper.AddRemoveShowInUserList(userListItem.Title, userListItem.Year, userListItem.Show.Tvdb, false);
                }
                else if (SelectedType == TraktItemType.season)
                {
                    TraktHelper.AddRemoveSeasonInUserList(userListItem.Title, userListItem.Year, userListItem.SeasonNumber, userListItem.Show.Tvdb, false);
                }
                else if (SelectedType == TraktItemType.episode)
                {
                    TraktHelper.AddRemoveEpisodeInUserList(userListItem.Title, userListItem.Year, userListItem.SeasonNumber, userListItem.EpisodeNumber, userListItem.Show.Tvdb, false);
                }
                break;

            case ((int)ContextMenuItem.RemoveFromList):
                if (!GUIUtils.ShowYesNoDialog(Translation.DeleteListItem, Translation.ConfirmDeleteListItem))
                {
                    break;
                }

                // Only do remove from current list
                // We could do same as Add (ie remove from multile lists) but typically you only remove from the current list
                if (SelectedType == TraktItemType.movie)
                {
                    TraktListItem item = new TraktListItem {
                        Type = "movie", ImdbId = userListItem.ImdbId, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year)
                    };
                    TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true);
                }
                else if (SelectedType == TraktItemType.show)
                {
                    TraktListItem item = new TraktListItem {
                        Type = "show", TvdbId = userListItem.Show.Tvdb, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year)
                    };
                    TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true);
                }
                else if (SelectedType == TraktItemType.season)
                {
                    TraktListItem item = new TraktListItem {
                        Type = "season", TvdbId = userListItem.Show.Tvdb, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year), Season = Convert.ToInt32(userListItem.SeasonNumber)
                    };
                    TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true);
                }
                else if (SelectedType == TraktItemType.episode)
                {
                    TraktListItem item = new TraktListItem {
                        Type = "episode", TvdbId = userListItem.Show.Tvdb, Title = userListItem.Title, Year = Convert.ToInt32(userListItem.Year), Season = Convert.ToInt32(userListItem.SeasonNumber), Episode = Convert.ToInt32(userListItem.EpisodeNumber)
                    };
                    TraktHelper.AddRemoveItemInList(CurrentList.Slug, item, true);
                }

                // Remove from view
                if (Facade.Count > 1)
                {
                    PreviousSelectedIndex = Facade.SelectedListItemIndex;
                    CurrentList.Items.Remove(userListItem);
                    SendListItemsToFacade(CurrentList);
                }
                else
                {
                    CurrentList.Items.Remove(userListItem);

                    // no more items left
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    ClearProperties();
                    GUIWindowManager.Process();

                    // nothing left, exit
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                AddItemToLibrary(userListItem);
                userListItem.InCollection = true;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                RemoveItemFromLibrary(userListItem);
                userListItem.InCollection = false;
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                break;

            case ((int)ContextMenuItem.Related):
                if (SelectedType == TraktItemType.movie)
                {
                    RelatedMovie relatedMovie = new RelatedMovie();
                    relatedMovie.IMDbId           = userListItem.Movie.IMDBID;
                    relatedMovie.Title            = userListItem.Movie.Title;
                    GUIRelatedMovies.relatedMovie = relatedMovie;
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedMovies);
                }
                else
                {
                    //series, season & episode
                    RelatedShow relatedShow = new RelatedShow();
                    relatedShow.Title           = userListItem.Show.Title;
                    relatedShow.TVDbId          = userListItem.Show.Tvdb;
                    GUIRelatedShows.relatedShow = relatedShow;
                    GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedShows);
                }
                break;

            case ((int)ContextMenuItem.Rate):
                RateItem(userListItem);
                OnItemSelected(selectedItem, Facade);
                if (SelectedType == TraktItemType.movie)
                {
                    userListItem.Movie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    userListItem.Show.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                break;

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType = (GUIShouts.ShoutTypeEnum)Enum.Parse(typeof(GUIShouts.ShoutTypeEnum), SelectedType.ToString(), true);
                if (SelectedType == TraktItemType.movie)
                {
                    GUIShouts.MovieInfo = new MovieShout {
                        IMDbId = userListItem.ImdbId, TMDbId = userListItem.Movie.TMDBID, Title = userListItem.Title, Year = userListItem.Year
                    }
                }
                ;
                else if (SelectedType == TraktItemType.show)
                {
                    GUIShouts.ShowInfo = new ShowShout {
                        IMDbId = userListItem.ImdbId, TVDbId = userListItem.Show.Tvdb, Title = userListItem.Title
                    }
                }
                ;
                else
                {
                    GUIShouts.EpisodeInfo = new EpisodeShout {
                        IMDbId = userListItem.ImdbId, TVDbId = userListItem.Show.Tvdb, Title = userListItem.Title, SeasonIdx = userListItem.SeasonNumber, EpisodeIdx = userListItem.EpisodeNumber
                    }
                };
                GUIShouts.Fanart = SelectedType == TraktItemType.movie ? (userListItem.Images as TraktMovie.MovieImages).FanartImageFilename : (userListItem.Images as TraktShow.ShowImages).FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

            case ((int)ContextMenuItem.Trailers):
                if (SelectedType == TraktItemType.movie)
                {
                    GUICommon.ShowMovieTrailersMenu(userListItem.Movie);
                }
                else
                {
                    GUICommon.ShowTVShowTrailersMenu(userListItem.Show, userListItem.Episode);
                }
                break;

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = String.Empty;
                if (userListItem.Movie != null)
                {
                    loadingParam = string.Format("search:{0}", userListItem.Movie.Title);
                }
                else if (userListItem.Episode != null)
                {
                    loadingParam = string.Format("search:{0} S{1}E{2}", userListItem.Show.Title, userListItem.Episode.Season.ToString("D2"), userListItem.Episode.Number.ToString("D2"));
                }
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = String.Empty;
                if (userListItem.Movie != null)
                {
                    loadPar = userListItem.Movie.Title;
                }
                else if (userListItem.Episode != null)
                {
                    loadPar = string.Format("{0} S{1}E{2}", userListItem.Show.Title, userListItem.Episode.Season.ToString("D2"), userListItem.Episode.Number.ToString("D2"));
                }
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktShowSeason selectedSeason = (TraktShowSeason)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

            // Mark season as watched
            listItem = new GUIListItem(Translation.MarkAsWatched);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;

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

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

            // Sort By
            listItem = new GUIListItem(TraktSettings.SortSeasonsAscending ? Translation.SortSeasonsDescending : Translation.SortSeasonsAscending);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Sort;

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

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.MarkAsWatched):
                GUICommon.MarkSeasonAsSeen(Show, selectedSeason.Season);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                GUICommon.AddSeasonToLibrary(Show, selectedSeason.Season);
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveSeasonInUserList(Show.Title, Show.Year.ToString(), selectedSeason.Season.ToString(), Show.Tvdb, false);
                break;

            case ((int)ContextMenuItem.Sort):
                TraktSettings.SortSeasonsAscending = !TraktSettings.SortSeasonsAscending;
                LoadShowSeasons();
                break;

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 10
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.FacadeActors.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

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

            dlg.Reset();
            dlg.SetHeading(Translation.Actors);

            GUIListItem listItem = null;

            // Trakt: Search for Actor
            if (Helper.IsTraktAvailableAndEnabled)
            {
                listItem = new GUIListItem(Translation.Biography);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.biography;
            }

            // MovingPictures: Search for Actor in Movies
            if (Helper.IsMovingPicturesAvailableAndEnabled)
            {
                listItem = new GUIListItem(Translation.SearchActorInMovies);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.searchmovie;
            }

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

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.layout):
                ShowLayoutsMenu();
                break;

            case ((int)ContextMenuItem.searchmovie):
                DBActor actor     = (selectedItem as GUIActorListItem).Item as DBActor;
                string  searchObj = string.Format("searchcast:{0}", actor.Name);
                GUIWindowManager.ActivateWindow(96742, searchObj);
                break;

            // trakt actor search
            case ((int)ContextMenuItem.biography):
                actor = (selectedItem as GUIActorListItem).Item as DBActor;
                GUIWindowManager.ActivateWindow(874005, actor.Name);
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 11
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var item            = (KeyValuePair <TraktShow, TraktWatchListEpisode.Episode>)selectedItem.TVTag;
            var selectedSeries  = item.Key;
            var selectedEpisode = item.Value;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

            if (CurrentUser == TraktSettings.Username)
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

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

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

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

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

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

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

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemovingWatchListItem = true;
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                RemoveEpisodeFromWatchList(item);
                if (this.Facade.Count >= 1)
                {
                    // remove from list
                    _WatchListEpisodes = null;
                    userWatchList.Remove(CurrentUser);
                    LoadWatchListEpisodes();
                }
                else
                {
                    // no more shows left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _WatchListEpisodes = null;
                    userWatchList.Remove(CurrentUser);
                    // notify and exit
                    GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoShowWatchList);
                    GUIWindowManager.ShowPreviousWindow();
                    return;
                }
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveEpisodeInUserList(selectedSeries.Title, selectedSeries.Year.ToString(), selectedEpisode.Season.ToString(), selectedEpisode.Number.ToString(), selectedSeries.Tvdb, false);
                break;

            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowTVShowTrailersMenu(selectedSeries, selectedEpisode);
                break;

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType   = GUIShouts.ShoutTypeEnum.episode;
                GUIShouts.EpisodeInfo = new EpisodeShout
                {
                    TVDbId     = selectedSeries.Tvdb,
                    IMDbId     = selectedSeries.Imdb,
                    Title      = selectedSeries.Title,
                    SeasonIdx  = selectedEpisode.Season.ToString(),
                    EpisodeIdx = selectedEpisode.Number.ToString()
                };
                GUIShouts.Fanart = selectedSeries.Images.FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

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

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0} S{1}E{2}", selectedSeries.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = string.Format("{0} S{1}E{2}", selectedSeries.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedMovie = selectedItem.TVTag as TraktMovieSummary;

            if (selectedMovie == 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;

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

            // 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.HideShowWatched):
                HideWatched = !HideWatched;
                if (hideWatchedButton != null)
                {
                    hideWatchedButton.Selected = HideWatched;
                }
                dictRelatedMovies.Remove(relatedMovie.Slug);
                LoadRelatedMovies();
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                TraktHelper.AddMovieToWatchHistory(selectedMovie);
                if (!HideWatched)
                {
                    selectedItem.IsPlayed = true;
                    OnMovieSelected(selectedItem, Facade);
                    (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                }
                else
                {
                    dictRelatedMovies.Remove(relatedMovie.Slug);
                    LoadRelatedMovies();
                }
                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):
                var relMovie = new RelatedMovie
                {
                    Title   = selectedMovie.Title,
                    Year    = selectedMovie.Year,
                    TraktId = selectedMovie.Ids.Trakt,
                    TmdbId  = selectedMovie.Ids.Tmdb,
                    ImdbId  = selectedMovie.Ids.Imdb
                };
                relatedMovie = relMovie;
                GUIUtils.SetProperty("#Trakt.Related.Movie", relMovie.Title);
                LoadRelatedMovies();
                RelationChanged = true;
                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();
        }
Ejemplo n.º 13
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedEpisode = selectedItem.TVTag as TraktEpisode;

            if (selectedEpisode == 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.Trailers + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Trailers;

            if (selectedEpisode.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsUnWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched;
            }
            else
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
            }

            if (selectedEpisode.InCollection)
            {
                listItem = new GUIListItem(Translation.RemoveFromLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary;
            }
            else
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }

            if (selectedEpisode.InWatchList)
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.AddEpisodeToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }

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

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

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

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

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

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

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowTVShowTrailersMenu(Show, selectedEpisode);
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                MarkEpisodeAsWatched(selectedEpisode);
                selectedEpisode.Watched          = true;
                Facade.SelectedListItem.IsPlayed = true;
                if (selectedEpisode.Plays == 0)
                {
                    selectedEpisode.Plays = 1;
                }
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                MarkEpisodeAsUnWatched(selectedEpisode);
                selectedEpisode.Watched          = false;
                Facade.SelectedListItem.IsPlayed = false;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                AddEpisodeToLibrary(selectedEpisode);
                selectedEpisode.InCollection = true;
                OnEpisodeSelected(selectedItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                RemoveEpisodeFromLibrary(selectedEpisode);
                selectedEpisode.InCollection = false;
                OnEpisodeSelected(selectedItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                AddEpisodeToWatchList(selectedEpisode);
                selectedEpisode.InWatchList = true;
                OnEpisodeSelected(selectedItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveEpisodeFromWatchList(selectedEpisode);
                selectedEpisode.InWatchList = false;
                OnEpisodeSelected(selectedItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.Rate):
                RateEpisode(selectedEpisode);
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                selectedEpisode.Images.NotifyPropertyChanged("EpisodeImageFilename");
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveEpisodeInUserList(Show.Title, Show.Year.ToString(), selectedEpisode.Season.ToString(), selectedEpisode.Number.ToString(), Show.Tvdb, false);
                break;

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType   = GUIShouts.ShoutTypeEnum.episode;
                GUIShouts.EpisodeInfo = new EpisodeShout
                {
                    TVDbId     = Show.Tvdb,
                    IMDbId     = Show.Imdb,
                    Title      = Show.Title,
                    SeasonIdx  = selectedEpisode.Season.ToString(),
                    EpisodeIdx = selectedEpisode.Number.ToString()
                };
                GUIShouts.Fanart = Show.Images.FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

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

            case ((int)ContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0} S{1}E{2}", Show.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)ContextMenuItem.SearchTorrent):
                string loadPar = string.Format("{0} S{1}E{2}", Show.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2"));
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 14
0
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktMovie selectedMovie = (TraktMovie)selectedItem.TVTag;

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

            if (dlg == null)
            {
                return;
            }

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

            GUIListItem listItem = null;

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

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

            // Mark As UnWatched
            if (selectedMovie.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsUnWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched;
            }

            // Add/Remove Watch List
            if (!selectedMovie.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

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

            // 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.InCollection && !TraktSettings.KeepTraktLibraryClean)
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }

            if (selectedMovie.InCollection)
            {
                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.Shouts + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

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

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

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

            if (!selectedMovie.InCollection && 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.HideShowWatched):
                HideWatched = !HideWatched;
                if (hideWatchedButton != null)
                {
                    hideWatchedButton.Selected = HideWatched;
                }
                dictRelatedMovies.Remove(relatedMovie.Slug);
                LoadRelatedMovies();
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                MarkMovieAsWatched(selectedMovie);
                if (!HideWatched)
                {
                    if (selectedMovie.Plays == 0)
                    {
                        selectedMovie.Plays = 1;
                    }
                    selectedMovie.Watched = true;
                    selectedItem.IsPlayed = true;
                    OnMovieSelected(selectedItem, Facade);
                    selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                }
                else
                {
                    dictRelatedMovies.Remove(relatedMovie.Slug);
                    LoadRelatedMovies();
                }
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                MarkMovieAsUnWatched(selectedMovie);
                selectedMovie.Watched = false;
                selectedItem.IsPlayed = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                AddMovieToWatchList(selectedMovie);
                selectedMovie.InWatchList = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                RemoveMovieFromWatchList(selectedMovie);
                selectedMovie.InWatchList = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                GUIWatchListMovies.ClearCache(TraktSettings.Username);
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveMovieInUserList(selectedMovie.Title, selectedMovie.Year, selectedMovie.IMDBID, false);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                AddMovieToLibrary(selectedMovie);
                selectedMovie.InCollection = true;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                RemoveMovieFromLibrary(selectedMovie);
                selectedMovie.InCollection = false;
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.Related):
                RelatedMovie relMovie = new RelatedMovie
                {
                    Title  = selectedMovie.Title,
                    IMDbId = selectedMovie.IMDBID,
                    Year   = Convert.ToInt32(selectedMovie.Year)
                };
                relatedMovie = relMovie;
                GUIUtils.SetProperty("#Trakt.Related.Movie", relMovie.Title);
                LoadRelatedMovies();
                RelationChanged = true;
                break;

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateMovie(selectedMovie);
                OnMovieSelected(selectedItem, Facade);
                selectedMovie.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)ContextMenuItem.Shouts):
                GUIShouts.ShoutType = GUIShouts.ShoutTypeEnum.movie;
                GUIShouts.MovieInfo = new MovieShout {
                    IMDbId = selectedMovie.IMDBID, TMDbId = selectedMovie.TMDBID, Title = selectedMovie.Title, Year = selectedMovie.Year
                };
                GUIShouts.Fanart = selectedMovie.Images.FanartImageFilename;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.Shouts);
                break;

            case ((int)ContextMenuItem.Trailers):
                GUICommon.ShowMovieTrailersMenu(selectedMovie);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout);
                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();
        }
Ejemplo n.º 15
0
        public bool ResumeOrPlay(VM_AnimeEpisode_User episode)
        {
            try
            {
                // get the list if FileLocal records for this AnimeEpisode
                List <VM_VideoDetailed> fileLocalList = episode.FilesForEpisode;

                if (fileLocalList.Count == 0)
                {
                    return(false);
                }
                VM_VideoDetailed fileToPlay = null;
                if (fileLocalList.Count == 1)
                {
                    fileToPlay = fileLocalList[0];
                }
                else
                {
                    // ask the user which file they want to play
                    IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    dlg.Reset();
                    dlg.SetHeading("Select File");
                    GUIListItem pItem = null;

                    foreach (VM_VideoDetailed fl in fileLocalList)
                    {
                        pItem = new GUIListItem(fl.FileSelectionDisplay);
                        dlg.Add(pItem);
                    }

                    dlg.DoModal(GUIWindowManager.ActiveWindow);

                    if (dlg.SelectedId > 0)
                    {
                        fileToPlay = fileLocalList[dlg.SelectedId - 1];
                    }
                }

                if (fileToPlay == null)
                {
                    return(false);
                }
                previous    = current;
                previousUri = currentUri;
                current     = fileToPlay;
                BaseConfig.MyAnimeLog.Write("Filetoplay: {0}", fileToPlay.FileName);


                if (!fileToPlay.IsLocalOrStreaming() == null)
                {
                    Utils.DialogMsg("Error", "File could not be found!");
                    return(false);
                }
                BaseConfig.MyAnimeLog.Write("Getting time stopped for : {0}", fileToPlay.FileName);
                _timeMovieStopped = (int)(fileToPlay.VideoLocal_ResumePosition / 1000);
                BaseConfig.MyAnimeLog.Write("Time stopped for : {0} - {1}", fileToPlay.FileName, _timeMovieStopped);

                prevEpisode = curEpisode;
                curEpisode  = episode;



                #region Ask user to Resume
                if (_timeMovieStopped > 0)
                {
                    //MPTVSeriesLog.Write("Asking user to resume episode from: " + Utils.SecondsToHMSString(timeMovieStopped));
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);

                    if (null != dlgYesNo)
                    {
                        dlgYesNo.SetHeading(GUILocalizeStrings.Get(900)); //resume movie?
                        dlgYesNo.SetLine(1, episode.EpisodeName);
                        dlgYesNo.SetLine(2, GUILocalizeStrings.Get(936) + " " + MediaPortal.Util.Utils.SecondsToHMSString(_timeMovieStopped));
                        dlgYesNo.SetDefaultToYes(true);
                        dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                        if (!dlgYesNo.IsConfirmed) // reset resume data in DB
                        {
                            _timeMovieStopped = 0;
                            //MPTVSeriesLog.Write("User selected to start episode from beginning", MPTVSeriesLog.LogLevel.Debug);
                        }
                    }
                }
                #endregion



                Play(_timeMovieStopped, curEpisode.DefaultAudioLanguage, curEpisode.DefaultSubtitleLanguage);
                return(true);
            }
            catch (Exception e)
            {
                BaseConfig.MyAnimeLog.Write("ResumeOrPlay: {0}", e.ToString());
                return(false);
            }
        }
        protected override void OnShowContextMenu()
        {
            var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedMovie = selectedItem.TVTag as TraktMovieSummary;

            if (selectedMovie == 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;

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

            // Mark As Watched
            // This should remove item from recommendations if executed
            if (!selectedMovie.IsWatched())
            {
                listItem = new GUIListItem(Translation.MarkAsWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsWatched;
            }

            // 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;

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

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

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

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

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

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.DismissRecommendation):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                DismissRecommendation(selectedMovie);
                if (_RecommendedMovies.Count() > 1)
                {
                    var moviesToExcept = new List <TraktMovieSummary>();
                    moviesToExcept.Add(selectedMovie);
                    _RecommendedMovies = RecommendedMovies.Except(moviesToExcept);
                }
                else
                {
                    // reload, none left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _RecommendedMovies = null;
                }
                LoadRecommendedMovies();
                break;

            case ((int)ContextMenuItem.MarkAsWatched):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                TraktHelper.AddMovieToWatchHistory(selectedMovie);
                if (_RecommendedMovies.Count() > 1)
                {
                    var moviesToExcept = new List <TraktMovieSummary>();
                    moviesToExcept.Add(selectedMovie);
                    _RecommendedMovies = RecommendedMovies.Except(moviesToExcept);
                }
                else
                {
                    // reload, none left
                    ClearProperties();
                    GUIControl.ClearControl(GetID, Facade.GetID);
                    _RecommendedMovies = null;
                }
                LoadRecommendedMovies();
                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):
                PreviousSelectedIndex = this.Facade.SelectedListItemIndex;
                if (GUICommon.RateMovie(selectedMovie))
                {
                    // also mark as watched
                    TraktHelper.AddMovieToWatchHistory(selectedMovie);
                    // remove from recommendations
                    if (_RecommendedMovies.Count() > 1)
                    {
                        var moviesToExcept = new List <TraktMovieSummary>();
                        moviesToExcept.Add(selectedMovie);
                        _RecommendedMovies = RecommendedMovies.Except(moviesToExcept);
                    }
                    else
                    {
                        // reload, none left
                        ClearProperties();
                        GUIControl.ClearControl(GetID, Facade.GetID);
                        _RecommendedMovies = null;
                    }
                    LoadRecommendedMovies();
                }
                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();
        }
Ejemplo n.º 17
0
        internal void MyContextMenu()
        {
            try
            {
                GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlg == null)
                {
                    return;
                }

                dlg.Reset();
                dlg.SetHeading(924);

                //Add Details Menu Item
                //Play Menu Item
                GUIListItem pItem = new GUIListItem(Translation.Play);
                dlg.Add(pItem);
                pItem.ItemId = 1;

                pItem = new GUIListItem(Translation.MovieDetails);
                dlg.Add(pItem);
                pItem.ItemId = 2;

                //Add Watched/Unwatched Filter Menu Item
                if (CurrentFacade.UnWatched)
                {
                    pItem = new GUIListItem(Translation.ShowUnwatchedMovies);
                    dlg.Add(pItem);
                    pItem.ItemId = 3;
                }
                else
                {
                    pItem = new GUIListItem(Translation.ShowAllMovies);
                    dlg.Add(pItem);
                    pItem.ItemId = 3;
                }

                //Add Latests/Watched/Rated Menu Item
                pItem = new GUIListItem("[^] " + CurrentFacade.Title);
                dlg.Add(pItem);
                pItem.ItemId = 4;

                pItem        = new GUIListItem();
                pItem.Label  = Translation.Update;
                pItem.ItemId = 5;
                dlg.Add(pItem);

                //Show Dialog
                dlg.DoModal(Utils.ActiveWindow);

                if (dlg.SelectedLabel == -1)
                {
                    return;
                }

                // CurrentFacade.Facade = Utils.GetLatestsFacade(CurrentFacade.ControlID);
                switch (dlg.SelectedId)
                {
                case 1:
                {
                    PlayMovingPicture(GUIWindowManager.GetWindow(Utils.ActiveWindow));
                    break;
                }

                case 2:
                {
                    ShowInfo();
                    break;
                }

                case 3:
                {
                    CurrentFacade.UnWatched = !CurrentFacade.UnWatched;
                    MovingPictureUpdateLatest();
                    break;
                }

                case 4:
                {
                    IDialogbox ldlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (ldlg == null)
                    {
                        return;
                    }

                    ldlg.Reset();
                    ldlg.SetHeading(924);

                    //Add Types Menu Items
                    pItem = new GUIListItem((CurrentFacade.Type == LatestsFacadeType.Latests ? "[x] " : string.Empty) + Translation.LabelLatestAdded);
                    ldlg.Add(pItem);
                    pItem.ItemId = 1;

                    pItem = new GUIListItem((CurrentFacade.Type == LatestsFacadeType.Watched ? "[x] " : string.Empty) + Translation.LabelLatestWatched);
                    ldlg.Add(pItem);
                    pItem.ItemId = 2;

                    pItem = new GUIListItem((CurrentFacade.Type == LatestsFacadeType.Rated ? "[x] " : string.Empty) + Translation.LabelHighestRated);
                    ldlg.Add(pItem);
                    pItem.ItemId = 3;

                    //Show Dialog
                    ldlg.DoModal(Utils.ActiveWindow);

                    if (ldlg.SelectedLabel == -1)
                    {
                        return;
                    }

                    switch (ldlg.SelectedId - 1)
                    {
                    case 0:
                        CurrentFacade.Type = LatestsFacadeType.Latests;
                        break;

                    case 1:
                        CurrentFacade.Type = LatestsFacadeType.Watched;
                        break;

                    case 2:
                        CurrentFacade.Type = LatestsFacadeType.Rated;
                        break;
                    }
                    MovingPictureUpdateLatest();
                    break;
                }

                case 5:
                {
                    MovingPictureUpdateLatest();
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                logger.Error("MyContextMenu: " + ex.ToString());
            }
        }
Ejemplo n.º 18
0
        private void ShowSongContext(PandoraSong song)
        {
            if (song.IsAdvertisement)
            {
                return;
            }

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

            dialog.Reset();
            dialog.SetHeading("Song Options - " + song.Title);

            GUIListItem thumbsUpItem = new GUIListItem("I like this song.");

            dialog.Add(thumbsUpItem);

            GUIListItem thumbsDownItem = new GUIListItem("I don't like this song.");

            dialog.Add(thumbsDownItem);

            GUIListItem tempBanItem = new GUIListItem("I am tired of this song.");

            dialog.Add(tempBanItem);
            dialog.DoModal(GUIWindowManager.ActiveWindow);

            GUIListItem whySelectedItem = new GUIListItem("Why was this song selected?");
            //dialog.Add(whySelectedItem);

            GUIListItem moveSongItem = new GUIListItem("Move Song to Another Station...");

            dialog.Add(moveSongItem);

            if (dialog.SelectedId == thumbsUpItem.ItemId)
            {
                RateSong(song, PandoraRating.Love);
            }

            else if (dialog.SelectedId == thumbsDownItem.ItemId)
            {
                RateSong(song, PandoraRating.Hate);
            }

            else if (dialog.SelectedId == whySelectedItem.ItemId)
            {
                // todo: show the reason song was selected
            }

            else if (dialog.SelectedId == moveSongItem.ItemId)
            {
                PandoraStation newStation = ShowStationChooser();
                if (newStation != null)
                {
                    // todo: move song to new station
                }
            }

            else if (dialog.SelectedId == tempBanItem.ItemId)
            {
                TemporarilyBanSong(song);
            }
        }
Ejemplo n.º 19
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedMovie = selectedItem.TVTag as TraktMovie;

            if (selectedMovie == 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;

            if (!selectedMovie.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList;
            }

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

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

            // Mark As UnWatched
            if (selectedMovie.Watched)
            {
                listItem = new GUIListItem(Translation.MarkAsUnWatched);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched;
            }

            // Add to Library
            // Don't allow if it will be removed again on next sync
            // movie could be part of a DVD collection
            if (!selectedMovie.InCollection && !TraktSettings.KeepTraktLibraryClean)
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }

            if (selectedMovie.InCollection)
            {
                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.Shouts + "...");
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.Shouts;

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

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

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

            if (!selectedMovie.InCollection && 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.MarkMovieAsWatched(selectedMovie);
                if (selectedMovie.Plays == 0)
                {
                    selectedMovie.Plays = 1;
                }
                selectedMovie.Watched = true;
                selectedItem.IsPlayed = true;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.MarkAsUnWatched):
                TraktHelper.MarkMovieAsUnWatched(selectedMovie);
                selectedMovie.Watched = false;
                selectedItem.IsPlayed = false;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.AddToWatchList):
                TraktHelper.AddMovieToWatchList(selectedMovie, true);
                selectedMovie.InWatchList = true;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveMovieFromWatchList(selectedMovie, true);
                selectedMovie.InWatchList = false;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.AddToList):
                TraktHelper.AddRemoveMovieInUserList(selectedMovie.Title, selectedMovie.Year, selectedMovie.IMDBID, false);
                break;

            case ((int)ContextMenuItem.Trailers):
                PreviousUser = CurrentUser;
                GUICommon.ShowMovieTrailersMenu(selectedMovie);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddMovieToLibrary(selectedMovie);
                selectedMovie.InCollection = true;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveMovieFromLibrary(selectedMovie);
                selectedMovie.InCollection = false;
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.Related):
                RelatedMovie relatedMovie = new RelatedMovie();
                relatedMovie.IMDbId           = selectedMovie.IMDBID;
                relatedMovie.Title            = selectedMovie.Title;
                GUIRelatedMovies.relatedMovie = relatedMovie;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.RelatedMovies);
                break;

            case ((int)ContextMenuItem.Rate):
                GUICommon.RateMovie(selectedMovie);
                OnMovieSelected(selectedItem, Facade);
                (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster");
                break;

            case ((int)ContextMenuItem.Shouts):
                TraktHelper.ShowMovieShouts(selectedMovie);
                break;

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

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 20
0
        protected override void OnShowContextMenu()
        {
            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

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

            var episodeItem = Facade.SelectedListItem.TVTag as TraktEpisodeSummary;

            if (episodeItem == null)
            {
                return;
            }

            // Create Views Menu Item
            GUIListItem listItem = new GUIListItem(Translation.ChangeView);

            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.View;

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

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

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

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

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

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

            // Add/Remove Show Watch List
            if (!episodeItem.Show.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddShowToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddShowToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveShowFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveShowFromWatchList;
            }

            // Add/Remove Episode Watch List
            if (!episodeItem.Episode.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddEpisodeToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddEpisodeToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveEpisodeFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveEpisodeFromWatchList;
            }

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

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

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

            // Add/Remove Libary
            if (!episodeItem.Episode.InCollection)
            {
                listItem = new GUIListItem(Translation.AddToLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.AddToLibrary;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromLibrary);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary;
            }

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

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

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

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

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

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

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

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

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

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

            case ((int)ContextMenuItem.MarkAsWatched):
                TraktHelper.MarkEpisodeAsWatched(episodeItem.Show, episodeItem.Episode);
                episodeItem.Episode.Watched      = true;
                Facade.SelectedListItem.IsPlayed = true;
                if (episodeItem.Episode.Plays == 0)
                {
                    episodeItem.Episode.Plays = 1;
                }
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

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

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

            case ((int)ContextMenuItem.AddEpisodeToWatchList):
                TraktHelper.AddEpisodeToWatchList(episodeItem.Show, episodeItem.Episode);
                episodeItem.Episode.InWatchList = true;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                GUIWatchListShows.ClearCache(TraktSettings.Username);
                break;

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

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

            case ((int)ContextMenuItem.AddEpisodeToList):
                TraktHelper.AddRemoveEpisodeInUserList(episodeItem.Show.Title, episodeItem.Show.Year.ToString(), episodeItem.Episode.Season.ToString(), episodeItem.Episode.Number.ToString(), episodeItem.Show.Tvdb, false);
                break;

            case ((int)ContextMenuItem.AddShowToList):
                TraktHelper.AddRemoveShowInUserList(episodeItem.Show.Title, episodeItem.Show.Year.ToString(), episodeItem.Show.Tvdb, false);
                break;

            case ((int)ContextMenuItem.AddToLibrary):
                TraktHelper.AddEpisodeToLibrary(episodeItem.Show, episodeItem.Episode);
                episodeItem.Episode.InCollection = true;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

            case ((int)ContextMenuItem.RemoveFromLibrary):
                TraktHelper.RemoveEpisodeFromLibrary(episodeItem.Show, episodeItem.Episode);
                episodeItem.Episode.InCollection = false;
                OnEpisodeSelected(Facade.SelectedListItem, Facade);
                (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen");
                break;

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Ejemplo n.º 21
0
        internal static void CreateTrendingShowsContextMenu(ref IDialogbox dlg, TraktShow show, bool dashboard)
        {
            GUIListItem listItem = null;

            // Add/Remove Watch List
            if (!show.InWatchList)
            {
                listItem = new GUIListItem(Translation.AddToWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.AddToWatchList;
            }
            else
            {
                listItem = new GUIListItem(Translation.RemoveFromWatchList);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.RemoveFromWatchList;
            }

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

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

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

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

            if (TraktHelper.IsOnlineVideosAvailableAndEnabled)
            {
                listItem = new GUIListItem(Translation.Trailers);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.Trailers;
            }

            // Filters
            if (!dashboard)
            {
                listItem = new GUIListItem(Translation.Filters + "...");
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.Filters;
            }

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

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

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

            // Change Layout
            if (GUIWindowManager.ActiveWindow == (int)TraktGUIWindows.TrendingShows)
            {
                listItem = new GUIListItem(Translation.ChangeLayout);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.ChangeLayout;
            }

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

            if (TraktHelper.IsMyTorrentsAvailableAndEnabled)
            {
                // Search for show with MyTorrents
                listItem = new GUIListItem(Translation.SearchTorrent);
                dlg.Add(listItem);
                listItem.ItemId = (int)TrendingContextMenuItem.SearchTorrent;
            }
        }
Ejemplo n.º 22
0
        protected override void OnShowContextMenu()
        {
            try
            {
                GUIListItem currentitem = this.m_Facade.SelectedListItem;
                if (currentitem == null || !(currentitem.TVTag is FanartContainer))
                {
                    return;
                }
                FanartContainer selectedFanart = currentitem.TVTag as FanartContainer;

                IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlg == null)
                {
                    return;
                }
                dlg.Reset();
                dlg.SetHeading("Fanart");


                GUIListItem pItem;


                if (!selectedFanart.IsImageEnabled)
                {
                    pItem = new GUIListItem("Enable");
                    dlg.Add(pItem);
                }
                else
                {
                    pItem = new GUIListItem("Disable");
                    dlg.Add(pItem);
                }

                if (selectedFanart.IsImageEnabled)
                {
                    if (selectedFanart.IsImageDefault)
                    {
                        pItem = new GUIListItem("Remove as Default");
                        dlg.Add(pItem);
                    }
                    else
                    {
                        pItem = new GUIListItem("Set as Default");
                        dlg.Add(pItem);
                    }
                }


                // lets show it
                dlg.DoModal(GUIWindowManager.ActiveWindow);

                if (dlg.SelectedId == 1)                 // enabled/disable
                {
                    bool endis = !selectedFanart.IsImageEnabled;
                    JMMServerHelper.EnableDisableFanart(endis, selectedFanart, AnimeID);

                    ShowFanart();
                    return;
                }

                if (dlg.SelectedId == 2)
                {
                    bool isdef = !selectedFanart.IsImageDefault;
                    JMMServerHelper.SetDefaultFanart(isdef, selectedFanart, AnimeID);

                    ShowFanart();
                    return;
                }
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("Exception in Fanart Chooser Context Menu: " + ex.Message + ex.StackTrace);
                return;
            }
        }