Ejemplo n.º 1
0
        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;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 void MarkEpisodeAsWatched(VM_AnimeEpisode_User episode)
 {
     episode.ToggleWatchedStatus(true, false);
     MainWindow.animeSeriesIDToBeRated = episode.AnimeSeriesID;
 }