protected override void OnShowContextMenu()
        {
            GUIListItem currentitem = m_Facade.SelectedListItem;

            if (currentitem == null)
            {
                return;
            }

            if (currentitem.TVTag.GetType() == typeof(VM_AnimeEpisode_User))
            {
                VM_AnimeEpisode_User ep = currentitem.TVTag as VM_AnimeEpisode_User;
                if (ep != null)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }

                    dlg.Reset();
                    dlg.SetHeading(ep.EpisodeNumberAndName);
                    dlg.Add("Mark as Watched");
                    dlg.Add("Play Previous Episode");
                    dlg.Add("Go To Episode List");
                    dlg.Add("View Series Info");

                    dlg.DoModal(GUIWindowManager.ActiveWindow);

                    switch (dlg.SelectedLabelText)
                    {
                    case "Mark as Watched":
                        ep.ToggleWatchedStatus(true);
                        LoadData();
                        break;

                    case "Play Previous Episode":
                        if (ep.AnimeSeries == null)
                        {
                            return;
                        }
                        VM_AnimeEpisode_User epPrev = (VM_AnimeEpisode_User)VM_ShokoServer.Instance.ShokoServices.GetPreviousEpisodeForUnwatched(ep.AnimeSeries.AnimeSeriesID,
                                                                                                                                                 VM_ShokoServer.Instance.CurrentUser.JMMUserID);

                        if (epPrev == null)
                        {
                            Utils.DialogMsg("Error", "Previous episode not found");
                            return;
                        }
                        MainWindow.vidHandler.ResumeOrPlay(epPrev);
                        break;

                    case "Go To Episode List":
                        if (ep.AnimeSeries == null)
                        {
                            return;
                        }

                        MainWindow.Breadcrumbs = new List <History>
                        {
                            new History {
                                Selected = GroupFilterHelper.AllGroupsFilter
                            }
                        };

                        // find the group for this series
                        VM_AnimeGroup_User grp = ShokoServerHelper.GetGroup(ep.AnimeSeries.AnimeGroupID);
                        if (grp == null)
                        {
                            BaseConfig.MyAnimeLog.Write("Group not found");
                            return;
                        }
                        MainWindow.ContinueWatching_CurrentSeries = ep.AnimeSeries;

                        MainWindow.Breadcrumbs.Add(new History {
                            Listing = GroupFilterHelper.AllGroupsFilter, Selected = grp
                        });
                        MainWindow.Breadcrumbs.Add(new History {
                            Listing = grp, Selected = MainWindow.ContinueWatching_CurrentSeries
                        });
                        bool foundEpType = false;
                        if (MainWindow.ContinueWatching_CurrentSeries.EpisodeTypesToDisplay.Count == 1)
                        {
                            MainWindow.Breadcrumbs.Add(new History {
                                Listing = MainWindow.ContinueWatching_CurrentSeries, Selected = null
                            });
                        }
                        else
                        {
                            foreach (VM_AnimeEpisodeType anEpType in MainWindow.ContinueWatching_CurrentSeries.EpisodeTypesToDisplay)
                            {
                                if (anEpType.EpisodeType == EpisodeType.Episode)
                                {
                                    MainWindow.Breadcrumbs.Add(new History {
                                        Listing = MainWindow.ContinueWatching_CurrentSeries, Selected = anEpType
                                    });
                                    MainWindow.Breadcrumbs.Add(new History {
                                        Listing = anEpType, Selected = null
                                    });
                                    foundEpType = true;
                                    break;
                                }
                            }

                            if (!foundEpType)
                            {
                                return;
                            }
                        }
                        GUIWindowManager.CloseCurrentWindow();
                        GUIWindowManager.ActivateWindow(Constants.WindowIDs.MAIN, false);
                        return;

                    case "View Series Info":

                        if (ep.AnimeSeries == null)
                        {
                            return;
                        }
                        MainWindow.GlobalSeriesID = ep.AnimeSeries.AnimeSeriesID;
                        GUIWindowManager.ActivateWindow(Constants.WindowIDs.ANIMEINFO, false);

                        break;
                    }
                }
            }
        }
示例#2
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            MainMenu menu = new MainMenu();

            menu.Add(btnAddTag, () =>
            {
                string tag = Utils.PromptSelectTag("");
                if (!MainWindow.RandomWindow_SeriesTags.Contains(tag, StringComparer.InvariantCultureIgnoreCase))
                {
                    MainWindow.RandomWindow_SeriesTags.Add(tag);
                    SetDisplayDetails();
                }
            });
            menu.Add(btnEpisodeAddTag, () =>
            {
                string tag = Utils.PromptSelectTag("");
                if (!MainWindow.RandomWindow_EpisodeTags.Contains(tag, StringComparer.InvariantCultureIgnoreCase))
                {
                    MainWindow.RandomWindow_EpisodeTags.Add(tag);
                    SetDisplayDetails();
                }
            });
            menu.Add(btnClearTags, () =>
            {
                MainWindow.RandomWindow_SeriesTags.Clear();
                SetDisplayDetails();
            });
            menu.Add(btnEpisodeClearTags, () =>
            {
                MainWindow.RandomWindow_EpisodeTags.Clear();
                SetDisplayDetails();
            });
            menu.Add(btnAllAnyTags, () =>
            {
                MainWindow.RandomWindow_SeriesAllTags = !MainWindow.RandomWindow_SeriesAllTags;
                SetDisplayDetails();
            });
            menu.Add(btnEpisodeAllAnyTags, () =>
            {
                MainWindow.RandomWindow_EpisodeAllTags = !MainWindow.RandomWindow_EpisodeAllTags;
                SetDisplayDetails();
            });
            menu.Add(btnRandom, () =>
            {
                if (togWatched != null)
                {
                    MainWindow.RandomWindow_SeriesWatched = togWatched.Selected;
                }
                if (togUnwatched != null)
                {
                    MainWindow.RandomWindow_SeriesUnwatched = togUnwatched.Selected;
                }
                if (togPartiallyWatched != null)
                {
                    MainWindow.RandomWindow_SeriesPartiallyWatched = togPartiallyWatched.Selected;
                }
                if (togCompleteOnly != null)
                {
                    MainWindow.RandomWindow_SeriesOnlyComplete = togCompleteOnly.Selected;
                }

                if (togEpisodeUnwatched != null)
                {
                    MainWindow.RandomWindow_EpisodeUnwatched = togEpisodeUnwatched.Selected;
                }
                if (togEpisodeWatched != null)
                {
                    MainWindow.RandomWindow_EpisodeWatched = togEpisodeWatched.Selected;
                }

                MainWindow.RandomWindow_CurrentEpisode = null;
                MainWindow.RandomWindow_CurrentSeries  = null;
                btnRandom.IsFocused = true;
                LoadData();
            });
            menu.Add(btnSwitchSeries, () =>
            {
                btnSwitchSeries.IsFocused          = false;
                btnRandom.IsFocused                = true;
                MainWindow.RandomWindow_RandomType = RandomObjectType.Series;
                LoadData();
            });
            menu.Add(btnSwitchEpisode, () =>
            {
                btnSwitchEpisode.IsFocused         = false;
                btnRandom.IsFocused                = true;
                MainWindow.RandomWindow_RandomType = RandomObjectType.Episode;
                LoadData();
            });
            menu.AddFunc(btnPlayEpisode, () =>
            {
                if (MainWindow.RandomWindow_CurrentEpisode == null)
                {
                    return(false);
                }
                MainWindow.vidHandler.ResumeOrPlay(MainWindow.RandomWindow_CurrentEpisode);
                return(true);
            });
            menu.AddFunc(btnEpisodeList, () =>
            {
                if (MainWindow.RandomWindow_CurrentSeries == null)
                {
                    return(false);
                }
                MainWindow.Breadcrumbs = new List <History>
                {
                    new History {
                        Selected = GroupFilterHelper.AllGroupsFilter
                    }
                };

                // find the group for this series
                VM_AnimeGroup_User grp = ShokoServerHelper.GetGroup(MainWindow.RandomWindow_CurrentSeries.AnimeGroupID);
                if (grp == null)
                {
                    BaseConfig.MyAnimeLog.Write("Group not found");
                    return(false);
                }
                MainWindow.Breadcrumbs.Add(new History {
                    Listing = GroupFilterHelper.AllGroupsFilter, Selected = grp
                });
                MainWindow.Breadcrumbs.Add(new History {
                    Listing = grp, Selected = MainWindow.RandomWindow_CurrentSeries
                });
                bool foundEpType = false;
                if (MainWindow.RandomWindow_CurrentSeries.EpisodeTypesToDisplay.Count == 1)
                {
                    MainWindow.Breadcrumbs.Add(new History {
                        Listing = MainWindow.RandomWindow_CurrentSeries, Selected = null
                    });
                }
                else
                {
                    foreach (VM_AnimeEpisodeType anEpType in MainWindow.RandomWindow_CurrentSeries.EpisodeTypesToDisplay)
                    {
                        if (anEpType.EpisodeType == enEpisodeType.Episode)
                        {
                            MainWindow.Breadcrumbs.Add(new History {
                                Listing = MainWindow.RandomWindow_CurrentSeries, Selected = anEpType
                            });
                            MainWindow.Breadcrumbs.Add(new History {
                                Listing = anEpType, Selected = null
                            });
                            foundEpType = true;
                            break;
                        }
                    }

                    if (!foundEpType)
                    {
                        return(false);
                    }
                }
                GUIWindowManager.CloseCurrentWindow();
                GUIWindowManager.ActivateWindow(Constants.WindowIDs.MAIN, false);
                return(true);
            });
            if (menu.Check(control))
            {
                return;
            }
            base.OnClicked(controlId, control, actionType);
        }