Beispiel #1
0
        protected override void OnShowContextMenu()
        {
            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

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

            var selectedItem = Facade.SelectedListItem as GUIEpisodeListItem;

            if (selectedItem == null)
            {
                return;
            }

            var calendarItem = selectedItem.TVTag as TraktShowCalendar;

            if (calendarItem == null)
            {
                return;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            default:
                break;
            }

            base.OnShowContextMenu();
        }