public void ToggleWatchedStatus(bool watched, bool promptForRating) { bool currentStatus = IsWatched == 1; if (currentStatus == watched) { return; } JMMServerBinary.Contract_ToggleWatchedStatusOnEpisode_Response response = JMMServerVM.Instance.clientBinaryHTTP.ToggleWatchedStatusOnEpisode(AnimeEpisodeID, watched, JMMServerVM.Instance.CurrentUser.JMMUserID); if (!string.IsNullOrEmpty(response.ErrorMessage)) { BaseConfig.MyAnimeLog.Write("Error in ToggleWatchedStatus: " + response.ErrorMessage); return; } if (promptForRating && BaseConfig.Settings.DisplayRatingDialogOnCompletion) { JMMServerBinary.Contract_AnimeSeries contract = JMMServerVM.Instance.clientBinaryHTTP.GetSeries(response.AnimeEpisode.AnimeSeriesID, JMMServerVM.Instance.CurrentUser.JMMUserID); if (contract != null) { AnimeSeriesVM ser = new AnimeSeriesVM(contract); Utils.PromptToRateSeriesOnCompletion(ser); } } }
public void PopulateSeries(JMMServerBinary.Contract_AnimeSeries seriesContract) { if (seriesContract != null) { AnimeSeries = new AnimeSeriesVM(seriesContract); } EvaluateProperties(); }
public static void SetWatchedStatusOnSeries(bool watchedStatus, int maxEpisodeNumber, int animeSeriesID) { AnimeSeriesVM series = GetSeries(animeSeriesID); if (series == null) { return; } foreach (AnimeEpisodeTypeVM epType in series.EpisodeTypes) { SetWatchedStatusOnSeries(watchedStatus, maxEpisodeNumber, animeSeriesID, epType.EpisodeType); } }
public static String GetSeriesImageAsFileName(AnimeSeriesVM ser, GUIFacadeControl.Layout viewMode) { string imgFileName = ""; switch (viewMode) { case GUIFacadeControl.Layout.LargeIcons: imgFileName = GetWideBannerAsFileName(ser.AniDB_Anime); break; case GUIFacadeControl.Layout.List: case GUIFacadeControl.Layout.AlbumView: case GUIFacadeControl.Layout.Filmstrip: case GUIFacadeControl.Layout.CoverFlow: imgFileName = GetPosterAsFileName(ser.AniDB_Anime); break; } //BaseConfig.MyAnimeLog.Write("GetSeriesBannerAsFileName::viewMode: {0} : {1} : {2}", viewMode, imgFileName, ser); return imgFileName; }
public void ToggleWatchedStatus(bool watched, bool promptForRating) { bool currentStatus = IsWatched == 1; if (currentStatus == watched) return; JMMServerBinary.Contract_ToggleWatchedStatusOnEpisode_Response response = JMMServerVM.Instance.clientBinaryHTTP.ToggleWatchedStatusOnEpisode(AnimeEpisodeID, watched, JMMServerVM.Instance.CurrentUser.JMMUserID); if (!string.IsNullOrEmpty(response.ErrorMessage)) { BaseConfig.MyAnimeLog.Write("Error in ToggleWatchedStatus: " + response.ErrorMessage); return; } if (promptForRating && BaseConfig.Settings.DisplayRatingDialogOnCompletion) { JMMServerBinary.Contract_AnimeSeries contract = JMMServerVM.Instance.clientBinaryHTTP.GetSeries(response.AnimeEpisode.AnimeSeriesID, JMMServerVM.Instance.CurrentUser.JMMUserID); if (contract != null) { AnimeSeriesVM ser = new AnimeSeriesVM(contract); Utils.PromptToRateSeriesOnCompletion(ser); } } }
void getDataWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { colEpisodes = e.Result as List<AnimeEpisodeVM>; if (colEpisodes == null || colEpisodes.Count == 0) { if (dummyAnyRecords != null) dummyAnyRecords.Visible = false; setGUIProperty("Watching.Status", "No episodes have recently been watched"); return; } if (dummyAnyRecords != null) dummyAnyRecords.Visible = true; foreach (AnimeEpisodeVM ep in colEpisodes) { GUIListItem item = new GUIListItem(""); AniDB_AnimeVM anime = ep.AnimeSeries.AniDB_Anime; string imagePath = GUIGraphicsContext.Skin + @"\Media\MyAnime3\anime3_question_poster.png"; if (anime.DefaultPosterPath.Trim().Length > 0) { if (File.Exists(anime.DefaultPosterPath)) imagePath = anime.DefaultPosterPath; } item.IconImage = item.IconImageBig = imagePath; item.TVTag = ep; item.OnItemSelected += new GUIListItem.ItemSelectedHandler(onFacadeItemSelected); m_Facade.Add(item); } if (m_Facade.Count > 0) { m_Facade.SelectedListItemIndex = 0; AnimeEpisodeVM ep = m_Facade.SelectedListItem.TVTag as AnimeEpisodeVM; if (ep != null) { SetEpisode(ep); } } if (MainWindow.animeSeriesIDToBeRated.HasValue && BaseConfig.Settings.DisplayRatingDialogOnCompletion) { JMMServerBinary.Contract_AnimeSeries contract = JMMServerVM.Instance.clientBinaryHTTP.GetSeries(MainWindow.animeSeriesIDToBeRated.Value, JMMServerVM.Instance.CurrentUser.JMMUserID); if (contract != null) { AnimeSeriesVM ser = new AnimeSeriesVM(contract); Utils.PromptToRateSeriesOnCompletion(ser); } MainWindow.animeSeriesIDToBeRated = null; } }
private bool ShowSeasonSelectionMenuTvDB(AnimeSeriesVM ser, int animeID, int tvdbid, string previousMenu) { try { List<int> seasons = JMMServerVM.Instance.clientBinaryHTTP.GetSeasonNumbersForSeries(tvdbid); if (seasons.Count == 0) { GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (null != dlgOK) { dlgOK.SetHeading("Season Results"); dlgOK.SetLine(1, string.Empty); dlgOK.SetLine(2, "No seasons found"); dlgOK.DoModal(GUIWindowManager.ActiveWindow); } return true; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = "Select Season"; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); foreach (int season in seasons) dlg.Add("Season " + season.ToString()); dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); if (selection == 0) return true; //previous menu if (selection > 0 && selection <= seasons.Count) { int selectedSeason = seasons[selection - 1]; string res = JMMServerVM.Instance.clientBinaryHTTP.RemoveLinkAniDBTvDBForAnime(animeID); LinkAniDBToTVDB(ser, animeID, enEpisodeType.Episode, 1, tvdbid, selectedSeason, 1); } return false; } } catch (Exception ex) { BaseConfig.MyAnimeLog.Write("Error in ShowSeasonSelectionMenu:: {0}", ex); } return true; }
private void ShowParentLevelForGroup(AnimeGroupVM grp) { while (grp != null) { List<AnimeGroupVM> subGroups = grp.SubGroups; List<AnimeSeriesVM> seriesList = grp.ChildSeries; if ((seriesList.Count + subGroups.Count) > 1) { curAnimeGroupViewed = grp; curAnimeGroup = grp; listLevel = Listlevel.Series; return; } else { // go up one level if (grp.AnimeGroupParentID.HasValue) grp = grp.ParentGroup; else { // only one series or subgroup so go all the way back to the group list listLevel = Listlevel.Group; curAnimeEpisodeType = null; curAnimeSeries = null; return; } } } }
private bool ShowContextMenuTrakt(AnimeSeriesVM ser, string previousMenu) { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) return true; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; string traktID = ""; int season = -1; string displayName = ""; if (ser.AniDB_Anime.AniDB_AnimeCrossRefs != null && ser.AniDB_Anime.AniDB_AnimeCrossRefs.CrossRef_AniDB_Trakt != null && ser.AniDB_Anime.AniDB_AnimeCrossRefs.TraktShow != null) { displayName = ser.AniDB_Anime.AniDB_AnimeCrossRefs.TraktShow.Title; traktID = ser.AniDB_Anime.AniDB_AnimeCrossRefs.CrossRef_AniDB_Trakt.TraktID; season = ser.AniDB_Anime.AniDB_AnimeCrossRefs.CrossRef_AniDB_Trakt.TraktSeasonNumber; } else return false; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = displayName; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); dlg.Add("Remove Trakt Association"); dlg.Add("Switch Season (Current is " + season.ToString() + ")"); dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); switch (selection) { case 0: //show previous return true; case 1: JMMServerVM.Instance.clientBinaryHTTP.RemoveLinkAniDBTrakt(ser.AniDB_Anime.AnimeID); break; case 2: if (!ShowSeasonSelectionMenuTrakt(ser, ser.AniDB_Anime.AnimeID, traktID, currentMenu)) return false; break; default: //close menu return false; } } }
private bool SetSeriesListItem(ref GUIListItem item, AnimeSeriesVM ser) { string sIconList = GUIGraphicsContext.Skin + @"\Media\MyAnime3\anime3_ListIcon.png"; string sUnWatchedFilename = GUIGraphicsContext.Skin + @"\Media\MyAnime3\anime3_UnWatched_left.png"; if (seriesViewMode != GUIFacadeControl.Layout.List) { // Graphical Mode item = new GUIListItem(); //item.IconImage = item.IconImageBig = ImageAllocator.GetSeriesBanner(ser, seriesViewMode); } else { item = new GUIListItem(ser.SeriesName); View.eLabelStyleGroups style = settings.LabelStyleGroups; switch (style) { case View.eLabelStyleGroups.WatchedUnwatched: string unwatched = ser.UnwatchedEpisodeCount.ToString(); string watched = ser.WatchedEpisodeCount.ToString(); string space = " "; item.Label3 = space + watched.ToString().PadLeft(3, '0'); item.IconImage = sIconList; item.Label2 = unwatched.ToString().PadLeft(3, '0'); break; case View.eLabelStyleGroups.Unwatched: if (ser.UnwatchedEpisodeCount > 0) { item.IconImage = sUnWatchedFilename; item.Label3 = ser.UnwatchedEpisodeCount.ToString() + " New"; item.Label2 = " "; } else { item.Label2 = " "; item.Label3 = " "; } break; case View.eLabelStyleGroups.TotalEpisodes: int totalEps = ser.UnwatchedEpisodeCount + ser.WatchedEpisodeCount; item.IconImage = sUnWatchedFilename; item.Label3 = totalEps.ToString() + " Episodes"; item.Label2 = " "; break; } } item.DVDLabel = ser.SeriesName; item.TVTag = ser; item.IsPlayed = (ser.UnwatchedEpisodeCount == 0); return true; }
private void Series_OnItemSelected(GUIListItem item) { // need to do this here as well because we display series and sub-groups in the same list if (displayGrpTimer != null) displayGrpTimer.Stop(); if (m_bQuickSelect) return; if (dummyIsAvailable != null) dummyIsAvailable.Visible = true; clearGUIProperty("SeriesGroup.Year"); clearGUIProperty("SeriesGroup.Genre"); clearGUIProperty("SeriesGroup.Episodes"); clearGUIProperty("SeriesGroup.EpisodesAvailable"); clearGUIProperty("SeriesGroup.Rating"); clearGUIProperty(guiProperty.SeriesTitle); clearGUIProperty(guiProperty.Subtitle); clearGUIProperty(guiProperty.Description); clearGUIProperty("SeriesGroup.EpisodeCountNormal"); clearGUIProperty("SeriesGroup.EpisodeCountSpecial"); clearGUIProperty("SeriesGroup.EpisodeCountNormalAvailable"); clearGUIProperty("SeriesGroup.EpisodeCountSpecialAvailable"); clearGUIProperty("SeriesGroup.EpisodeCountUnwatched"); clearGUIProperty("SeriesGroup.EpisodeCountWatched"); clearGUIProperty("SeriesGroup.RatingVoteCount"); clearGUIProperty("SeriesGroup.RawRating"); clearGUIProperty("SeriesGroup.MyRating"); clearGUIProperty(guiProperty.RomanjiTitle); clearGUIProperty(guiProperty.EnglishTitle); clearGUIProperty(guiProperty.KanjiTitle); clearGUIProperty(guiProperty.RotatorTitle); if (item == null || item.TVTag == null || !(item.TVTag is AnimeSeriesVM)) return; AnimeSeriesVM ser = item.TVTag as AnimeSeriesVM; if (ser == null) return; BaseConfig.MyAnimeLog.Write(ser.ToString()); curAnimeSeries = ser; setGUIProperty(guiProperty.SeriesTitle, ser.SeriesName); setGUIProperty(guiProperty.Subtitle, ""); setGUIProperty(guiProperty.Description, ser.Description); // set info properties // most of these properties actually come from the anidb_anime record // we need to find all the series for this group AniDB_AnimeVM anAnime = ser.AniDB_Anime; if (dummyUserHasVotedSeries != null) dummyUserHasVotedSeries.Visible = false; // Only AniDB users have votes if (JMMServerVM.Instance.CurrentUser.IsAniDBUserBool) { string myRating = anAnime.UserVoteFormatted; if (string.IsNullOrEmpty(myRating)) clearGUIProperty("SeriesGroup.MyRating"); else { setGUIProperty("SeriesGroup.MyRating", myRating); if (dummyUserHasVotedSeries != null) dummyUserHasVotedSeries.Visible = true; } } BaseConfig.MyAnimeLog.Write(anAnime.ToString()); setGUIProperty("SeriesGroup.Year", anAnime.Year); setGUIProperty("SeriesGroup.Genre", anAnime.CategoriesFormatted); setGUIProperty("SeriesGroup.GenreShort", anAnime.CategoriesFormattedShort); string eps = anAnime.EpisodeCountNormal.ToString() + " (" + anAnime.EpisodeCountSpecial.ToString() + " Specials)"; setGUIProperty("SeriesGroup.Episodes", eps); setGUIProperty("SeriesGroup.EpisodeCountNormal", anAnime.EpisodeCountNormal.ToString()); setGUIProperty("SeriesGroup.EpisodeCountSpecial", anAnime.EpisodeCountSpecial.ToString()); string rating = ""; rating = Utils.FormatAniDBRating((double)anAnime.AniDBRating) + " (" + anAnime.AniDBTotalVotes.ToString() + " votes)"; setGUIProperty("SeriesGroup.RawRating", Utils.FormatAniDBRating((double)anAnime.AniDBRating)); setGUIProperty("SeriesGroup.RatingVoteCount", anAnime.AniDBTotalVotes.ToString()); setGUIProperty("SeriesGroup.Rating", rating); // set watched/unavailable flag if (dummyIsWatched != null) dummyIsWatched.Visible = (ser.UnwatchedEpisodeCount == 0); setGUIProperty("SeriesGroup.EpisodeCountUnwatched", ser.UnwatchedEpisodeCount.ToString()); setGUIProperty("SeriesGroup.EpisodeCountWatched", ser.WatchedEpisodeCount.ToString()); // Delayed Image Loading of Series Banners listPoster.Filename = ImageAllocator.GetSeriesImageAsFileName(ser, GUIFacadeControl.Layout.List); LoadFanart(ser); }
private bool SearchTraktMenu(AnimeSeriesVM ser, string previousMenu) { //string searchCriteria = ""; int aniDBID = ser.AniDB_Anime.AnimeID; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = "Search Trakt"; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); dlg.Add("Search using: " + ser.AniDB_Anime.FormattedTitle); dlg.Add("Manual Search"); CrossRef_AniDB_TraktResultVM webCacheResult = null; JMMServerBinary.Contract_CrossRef_AniDB_TraktResult xref = JMMServerVM.Instance.clientBinaryHTTP.GetTraktCrossRefWebCache(aniDBID); if (xref != null) { webCacheResult = new CrossRef_AniDB_TraktResultVM(xref); dlg.Add("Community Says: " + webCacheResult.ShowName); } dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); switch (selection) { case 0: //show previous return true; case 1: if (!SearchTrakt(ser, ser.AniDB_Anime.FormattedTitle, currentMenu)) return false; break; case 2: { if (Utils.DialogText(ref searchText, GetID)) { if (!SearchTrakt(ser, searchText, currentMenu)) return false; } } break; case 3: LinkAniDBToTrakt(ser, ser.AniDB_Anime.AnimeID, webCacheResult.TraktID, webCacheResult.TraktSeasonNumber); return false; default: //close menu return false; } } }
private bool SearchTrakt(AnimeSeriesVM ser, string searchCriteria, string previousMenu) { if (searchCriteria.Length == 0) return true; int aniDBID = ser.AniDB_Anime.AnimeID; List<TraktTVShowResponseVM> TraktSeriesSearchResults = new List<TraktTVShowResponseVM>(); List<JMMServerBinary.Contract_TraktTVShowResponse> traktResults = JMMServerVM.Instance.clientBinaryHTTP.SearchTrakt(searchCriteria); foreach (JMMServerBinary.Contract_TraktTVShowResponse traktResult in traktResults) TraktSeriesSearchResults.Add(new TraktTVShowResponseVM(traktResult)); BaseConfig.MyAnimeLog.Write("Found {0} trakt results for {1}", TraktSeriesSearchResults.Count, searchCriteria); if (TraktSeriesSearchResults.Count > 0) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; //keep showing the dialog until the user closes it int selectedLabel = 0; while (true) { dlg.Reset(); dlg.SetHeading("Trakt Search Results"); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); foreach (TraktTVShowResponseVM res in TraktSeriesSearchResults) { string disp = string.Format("{0} ({1})", res.title, res.year); dlg.Add(disp); } dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); if (selection == 0) return true; // previous menu if (selection > 0 && selection <= TraktSeriesSearchResults.Count) { TraktTVShowResponseVM res = TraktSeriesSearchResults[selection - 1]; LinkAniDBToTrakt(ser, aniDBID, res.TraktID, 1); return false; } return true; } } else { GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (null != dlgOK) { dlgOK.SetHeading("Search Results"); dlgOK.SetLine(1, string.Empty); dlgOK.SetLine(2, "No results found"); dlgOK.DoModal(GUIWindowManager.ActiveWindow); } return true; } }
private bool SearchTheTvDBMenu(AnimeSeriesVM ser, string previousMenu) { //string searchCriteria = ""; int aniDBID = ser.AniDB_Anime.AnimeID; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = "Search The TvDB"; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); dlg.Add("Search using: " + ser.AniDB_Anime.FormattedTitle); dlg.Add("Manual Search"); List<CrossRef_AniDB_TvDBVMV2> CrossRef_AniDB_TvDBResult = new List<CrossRef_AniDB_TvDBVMV2>(); List<JMMServerBinary.Contract_Azure_CrossRef_AniDB_TvDB> xrefs = JMMServerVM.Instance.clientBinaryHTTP.GetTVDBCrossRefWebCache(aniDBID); if (xrefs != null && xrefs.Count > 0) { string xrefSummary = string.Empty; foreach (JMMServerBinary.Contract_Azure_CrossRef_AniDB_TvDB xref in xrefs) { CrossRef_AniDB_TvDBVMV2 xrefAzure = new CrossRef_AniDB_TvDBVMV2(xref); CrossRef_AniDB_TvDBResult.Add(xrefAzure); xrefSummary += Environment.NewLine; xrefSummary += string.Format("AniDB {0}:{1} -- TvDB {2}: {3}:{4}", xref.AniDBStartEpisodeType, xref.AniDBStartEpisodeNumber, xref.TvDBTitle, xref.TvDBSeasonNumber, xref.TvDBStartEpisodeNumber); } dlg.Add("Community Says: " + xrefSummary); } dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); switch (selection) { case 0: //show previous return true; case 1: if (!SearchTheTvDB(ser, ser.AniDB_Anime.FormattedTitle, currentMenu)) return false; break; case 2: { if (Utils.DialogText(ref searchText, GetID)) { if (!SearchTheTvDB(ser, searchText, currentMenu)) return false; } } break; case 3: string res = JMMServerVM.Instance.clientBinaryHTTP.RemoveLinkAniDBTvDBForAnime(aniDBID); if (res.Length > 0) { Utils.DialogMsg("Error", res); return false; } foreach (CrossRef_AniDB_TvDBVMV2 xref in CrossRef_AniDB_TvDBResult) { LinkAniDBToTVDB(ser, xref.AnimeID, (enEpisodeType)xref.AniDBStartEpisodeType, xref.AniDBStartEpisodeNumber, xref.TvDBID, xref.TvDBSeasonNumber, xref.TvDBStartEpisodeNumber); } return false; default: //close menu return false; } } }
private bool SearchTheMovieDB(AnimeSeriesVM ser, string searchCriteria, string previousMenu) { if (searchCriteria.Length == 0) return true; int aniDBID = ser.AniDB_Anime.AnimeID; List<MovieDBMovieSearchResultVM> MovieDBSeriesSearchResults = new List<MovieDBMovieSearchResultVM>(); List<JMMServerBinary.Contract_MovieDBMovieSearchResult> movieResults = JMMServerVM.Instance.clientBinaryHTTP.SearchTheMovieDB(searchCriteria.Trim()); foreach (JMMServerBinary.Contract_MovieDBMovieSearchResult movieResult in movieResults) MovieDBSeriesSearchResults.Add(new MovieDBMovieSearchResultVM(movieResult)); BaseConfig.MyAnimeLog.Write("Found {0} moviedb results for {1}", MovieDBSeriesSearchResults.Count, searchCriteria); if (MovieDBSeriesSearchResults.Count > 0) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; //keep showing the dialog until the user closes it int selectedLabel = 0; while (true) { dlg.Reset(); dlg.SetHeading("Search Results"); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); foreach (MovieDBMovieSearchResultVM res in MovieDBSeriesSearchResults) dlg.Add(res.MovieName); dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); if (selection == 0) return true; //previous menu if (selection > 0 && selection <= MovieDBSeriesSearchResults.Count) { MovieDBMovieSearchResultVM res = MovieDBSeriesSearchResults[selection - 1]; LinkAniDBToMovieDB(ser, aniDBID, res.MovieID); return false; } return true; } } else { GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (null != dlgOK) { dlgOK.SetHeading("Search Results"); dlgOK.SetLine(1, string.Empty); dlgOK.SetLine(2, "No results found"); dlgOK.DoModal(GUIWindowManager.ActiveWindow); } return true; } }
private bool SearchMALMenu(AnimeSeriesVM ser, string previousMenu) { int aniDBID = ser.AniDB_Anime.AnimeID; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = "Search MAL"; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); dlg.Add("Search using: " + ser.AniDB_Anime.FormattedTitle); dlg.Add("Manual Search"); dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); switch (selection) { case 0: //show previous return true; case 1: if (!SearchMAL(ser, ser.AniDB_Anime.FormattedTitle, currentMenu)) return false; break; case 2: { string searchText = ser.AniDB_Anime.FormattedTitle; if (Utils.DialogText(ref searchText, GetID)) { if (!SearchMAL(ser, searchText, currentMenu)) return false; } } break; default: //close menu return false; } } }
private void LinkAniDBToTVDB(AnimeSeriesVM ser, int animeID, enEpisodeType anidbEpType, int anidbEpNumber, int tvDBID, int tvSeason, int tvEpNumber) { string res = JMMServerVM.Instance.clientBinaryHTTP.LinkAniDBTvDB(animeID, (int)anidbEpType, anidbEpNumber, tvDBID, tvSeason, tvEpNumber, null); if (res.Length > 0) Utils.DialogMsg("Error", res); ser = JMMServerHelper.GetSeries(ser.AnimeSeriesID.Value); }
private void ShowChildrenLevelForGroup() { List<AnimeGroupVM> subGroups = curAnimeGroupViewed.SubGroups; List<AnimeSeriesVM> seriesList = curAnimeGroupViewed.ChildSeries; int subLevelCount = seriesList.Count + subGroups.Count; if (subLevelCount > 1) { listLevel = Listlevel.Series; LoadFacade(); return; } else if (subLevelCount == 1) { // keep drilling down until we find a series // or more than one sub level while (subLevelCount == 1 && subGroups.Count > 0) { curAnimeGroupViewed = subGroups[0]; curAnimeGroup = subGroups[0]; subGroups = curAnimeGroup.SubGroups; seriesList = curAnimeGroup.ChildSeries; subLevelCount = seriesList.Count + subGroups.Count; } if (subGroups.Count == 0) { // means we got all the way down to a series if (seriesList.Count > 1) { listLevel = Listlevel.Series; } else if (seriesList.Count == 1) { curAnimeSeries = seriesList[0]; ShowChildrenLevelForSeries(); } } else { // else we have more than one sub level to display listLevel = Listlevel.Series; } } }
private bool ShowContextMenuTVDB(AnimeSeriesVM ser, string previousMenu) { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) return true; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; int tvdbid = -1; int season = -1; string displayName = ""; if (ser.CrossRef_AniDB_TvDBV2.Count > 0 && ser.TvDBSeriesV2.Count > 0 && ser.AniDB_Anime.AniDB_AnimeCrossRefs != null && ser.AniDB_Anime.AniDB_AnimeCrossRefs.TvDBCrossRefExists) { displayName = ser.AniDB_Anime.AniDB_AnimeCrossRefs.TvDBSeries[0].SeriesName; tvdbid = ser.CrossRef_AniDB_TvDBV2[0].TvDBID; season = ser.CrossRef_AniDB_TvDBV2[0].TvDBSeasonNumber; } else return false; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = displayName; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); dlg.Add("Remove TVDB Association"); dlg.Add("Switch Season (Current is " + season.ToString() + ")"); dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); switch (selection) { case 0: //show previous return true; case 1: JMMServerVM.Instance.clientBinaryHTTP.RemoveLinkAniDBTvDBForAnime(ser.AniDB_Anime.AnimeID); break; case 2: if (ser.CrossRef_AniDB_TvDBV2.Count < 2 ) { if (!ShowSeasonSelectionMenuTvDB(ser, ser.AniDB_Anime.AnimeID, tvdbid, currentMenu)) return false; } else { Utils.DialogMsg("Error", "Cannot edit seasons when series has more than one TvDB link, use JMM Desktop instead"); } break; default: //close menu return false; } } }
private bool ShowContextMenuDatabases(AnimeSeriesVM ser, string previousMenu) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; int mnuPrevious = -1; int mnuTvDB = -1; int mnuMovieDB = -1; int mnuTvDBSub = -1; int mnuMovieDBSub = -1; int mnuTrakt = -1; int mnuTraktSub = -1; int mnuMAL = -1; int mnuMALSub = -1; int curMenu = -1; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = ser.SeriesName + " Databases"; bool hasTvDBLink = ser.CrossRef_AniDB_TvDBV2.Count > 0 && ser.AniDB_Anime.AniDB_AnimeCrossRefs != null && ser.AniDB_Anime.AniDB_AnimeCrossRefs.TvDBCrossRefExists; bool hasMovieDBLink = ser.CrossRef_AniDB_MovieDB != null && ser.AniDB_Anime.AniDB_AnimeCrossRefs != null && ser.AniDB_Anime.AniDB_AnimeCrossRefs.MovieDB_Movie != null; bool hasTraktLink = ser.AniDB_Anime.AniDB_AnimeCrossRefs != null && ser.AniDB_Anime.AniDB_AnimeCrossRefs.TraktShow != null; bool hasMALLink = ser.CrossRef_AniDB_MAL != null && ser.CrossRef_AniDB_MAL.Count > 0; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); string tvdbText = "Search The TvDB"; string moviedbText = "Search The MovieDB"; string traktText = "Search Trakt.tv"; string malText = "Search MAL"; if (ser != null) { if (hasTvDBLink) tvdbText += " (Current: " + ser.AniDB_Anime.AniDB_AnimeCrossRefs.TvDBSeries[0].SeriesName + ")"; if (hasMovieDBLink) moviedbText += " (Current: " + ser.AniDB_Anime.AniDB_AnimeCrossRefs.MovieDB_Movie.MovieName + ")"; if (hasTraktLink) traktText += " (Current: " + ser.AniDB_Anime.AniDB_AnimeCrossRefs.TraktShow.Title + ")"; if (hasMALLink) { if (ser.CrossRef_AniDB_MAL.Count == 1) malText += " (Current: " + ser.CrossRef_AniDB_MAL[0].MALTitle + ")"; else malText += " (Current: Multiple Links)"; } } if (previousMenu != string.Empty) { dlg.Add("<<< " + previousMenu); curMenu++; mnuPrevious = curMenu; } if (ser != null && !hasMovieDBLink) { dlg.Add(tvdbText); curMenu++; mnuTvDB = curMenu; dlg.Add(traktText); curMenu++; mnuTrakt = curMenu; dlg.Add(malText); curMenu++; mnuMAL = curMenu; } if (ser != null && !hasTvDBLink && !hasTraktLink) { dlg.Add(moviedbText); curMenu++; mnuMovieDB = curMenu; } if (ser != null && hasTvDBLink) { dlg.Add("The Tv DB >>>"); curMenu++; mnuTvDBSub = curMenu; } if (ser != null && hasTraktLink) { dlg.Add("Trakt.tv >>>"); curMenu++; mnuTraktSub = curMenu; } if (ser != null && hasMALLink) { dlg.Add("MAL >>>"); curMenu++; mnuMALSub = curMenu; } if (ser != null && hasMovieDBLink) { dlg.Add("The Movie DB >>>"); curMenu++; mnuMovieDBSub = curMenu; } dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; if (selectedLabel == mnuPrevious) return true; if (selectedLabel == mnuTvDB) { if (!SearchTheTvDBMenu(ser, currentMenu)) return false; } if (selectedLabel == mnuTrakt) { if (!SearchTraktMenu(ser, currentMenu)) return false; } if (selectedLabel == mnuMAL) { if (!SearchMALMenu(ser, currentMenu)) return false; } if (selectedLabel == mnuMovieDB) { if (!SearchTheMovieDBMenu(ser, currentMenu)) return false; } if (selectedLabel == mnuTvDBSub) { if (!ShowContextMenuTVDB(ser, currentMenu)) return false; } if (selectedLabel == mnuTraktSub) { if (!ShowContextMenuTrakt(ser, currentMenu)) return false; } if (selectedLabel == mnuMALSub) { if (!ShowContextMenuMAL(ser, currentMenu)) return false; } if (selectedLabel == mnuMovieDBSub) { if (!ShowContextMenuMovieDB(ser, currentMenu)) return false; } return false; } }
private void ShowParentLevelForSeries(AnimeSeriesVM ser) { AnimeGroupVM grp = JMMServerHelper.GetGroup(ser.AnimeGroupID); ShowParentLevelForGroup(grp); }
private bool ShowContextMenuEpisode(string previousMenu) { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) return true; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; AnimeEpisodeVM episode = currentitem.TVTag as AnimeEpisodeVM; if (episode == null) return true; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = episode.EpisodeNumberAndName; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); bool isWatched = (episode.IsWatched == 1); if (isWatched) dlg.Add("Mark as Unwatched"); else dlg.Add("Mark as Watched"); dlg.Add("Mark ALL as Watched"); dlg.Add("Mark ALL as Unwatched"); dlg.Add("Mark ALL PREVIOUS as Watched"); dlg.Add("Mark ALL PREVIOUS as Unwatched"); dlg.Add("Associate File With This Episode"); dlg.Add("Remove File From This Episode"); dlg.Add("Download this epsiode"); dlg.Add("Post-processing >>>"); dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); switch (selection) { case 0: //show previous return true; case 1: { // Mark as Watched/Unwatched BaseConfig.MyAnimeLog.Write("Toggle watched status: {0} - {1}", isWatched, episode); episode.ToggleWatchedStatus(!isWatched); LoadFacade(); return false; } case 2: // Mark ALL as Watched { JMMServerVM.Instance.clientBinaryHTTP.SetWatchedStatusOnSeries(curAnimeSeries.AnimeSeriesID.Value, true, int.MaxValue, (int)curAnimeEpisodeType.EpisodeType, JMMServerVM.Instance.CurrentUser.JMMUserID); if (BaseConfig.Settings.DisplayRatingDialogOnCompletion) { JMMServerBinary.Contract_AnimeSeries contract = JMMServerVM.Instance.clientBinaryHTTP.GetSeries(curAnimeSeries.AnimeSeriesID.Value, JMMServerVM.Instance.CurrentUser.JMMUserID); if (contract != null) { AnimeSeriesVM ser = new AnimeSeriesVM(contract); Utils.PromptToRateSeriesOnCompletion(ser); } } LoadFacade(); return false; } case 3: // Mark ALL as Unwatched { JMMServerVM.Instance.clientBinaryHTTP.SetWatchedStatusOnSeries(curAnimeSeries.AnimeSeriesID.Value, false, int.MaxValue, (int)curAnimeEpisodeType.EpisodeType, JMMServerVM.Instance.CurrentUser.JMMUserID); LoadFacade(); return false; } case 4: // Mark ALL PREVIOUS as Watched { JMMServerVM.Instance.clientBinaryHTTP.SetWatchedStatusOnSeries(curAnimeSeries.AnimeSeriesID.Value, true, episode.EpisodeNumber, (int)curAnimeEpisodeType.EpisodeType, JMMServerVM.Instance.CurrentUser.JMMUserID); JMMServerBinary.Contract_AnimeSeries contract = JMMServerVM.Instance.clientBinaryHTTP.GetSeries(curAnimeSeries.AnimeSeriesID.Value, JMMServerVM.Instance.CurrentUser.JMMUserID); if (contract != null) { AnimeSeriesVM ser = new AnimeSeriesVM(contract); Utils.PromptToRateSeriesOnCompletion(ser); } LoadFacade(); return false; } case 5: // Mark ALL PREVIOUS as Unwatched { JMMServerVM.Instance.clientBinaryHTTP.SetWatchedStatusOnSeries(curAnimeSeries.AnimeSeriesID.Value, false, episode.EpisodeNumber, (int)curAnimeEpisodeType.EpisodeType, JMMServerVM.Instance.CurrentUser.JMMUserID); LoadFacade(); return false; } case 6: // associate file with this episode { List<VideoLocalVM> unlinkedVideos = JMMServerHelper.GetUnlinkedVideos(); if (unlinkedVideos.Count == 0) { GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (null != dlgOK) { dlgOK.SetHeading("Error"); dlgOK.SetLine(1, string.Empty); dlgOK.SetLine(2, "No unlinked files to select"); dlgOK.DoModal(GUIWindowManager.ActiveWindow); } break; } // ask the user which file they want to associate IDialogbox dlg2 = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlg2.Reset(); dlg2.SetHeading("Select File"); foreach (VideoLocalVM fl in unlinkedVideos) dlg2.Add(Path.GetFileName(fl.FullPath) + " - " + Path.GetDirectoryName(fl.FullPath)); dlg2.DoModal(GUIWindowManager.ActiveWindow); if (dlg2.SelectedId > 0) { VideoLocalVM selectedFile = unlinkedVideos[dlg2.SelectedId - 1]; JMMServerHelper.LinkedFileToEpisode(selectedFile.VideoLocalID, episode.AnimeEpisodeID); LoadFacade(); return false; } break; } case 7: // remove associated file { List<VideoDetailedVM> vidList = episode.FilesForEpisode; if (vidList.Count == 0) { GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (null != dlgOK) { dlgOK.SetHeading("Error"); dlgOK.SetLine(1, string.Empty); dlgOK.SetLine(2, "This episode has no associated files"); dlgOK.DoModal(GUIWindowManager.ActiveWindow); } break; } // ask the user which file they want to un-associate IDialogbox dlg2 = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlg2.Reset(); dlg2.SetHeading("Select File"); foreach (VideoDetailedVM fl in vidList) dlg2.Add(Path.GetFileName(fl.FileName)); dlg2.DoModal(GUIWindowManager.ActiveWindow); if (dlg2.SelectedId > 0) { VideoDetailedVM selectedFile = vidList[dlg2.SelectedId - 1]; string res = JMMServerVM.Instance.clientBinaryHTTP.RemoveAssociationOnFile(selectedFile.VideoLocalID, episode.AniDB_EpisodeID); if (!string.IsNullOrEmpty(res)) Utils.DialogMsg("Error", res); LoadFacade(); return false; } break; } case 8: DownloadHelper.SearchEpisode(curAnimeEpisode); return false; case 9: if (!ShowContextMenuPostProcessing(currentMenu)) return false; break; default: //close menu return false; } } }
protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType) { if (actionType == MediaPortal.GUI.Library.Action.ActionType.ACTION_MOUSE_DOUBLECLICK) { OnShowContextMenu(); return; } if (actionType == MediaPortal.GUI.Library.Action.ActionType.ACTION_PLAY) { if (MediaPortal.Player.g_Player.Playing == false) BaseConfig.MyAnimeLog.Write("Pressed the play button"); } if (this.btnDisplayOptions != null && control == this.btnDisplayOptions) { hook.IsEnabled = false; ShowDisplayOptionsMenu(""); btnDisplayOptions.Focus = false; Thread.Sleep(100); //make sure key-up's from the context menu aren't cought by the hook hook.IsEnabled = true; this.btnDisplayOptions.IsFocused = false; return; } if (this.btnWindowUtilities != null && control == this.btnWindowUtilities) { SetGlobalIDs(); GUIWindowManager.ActivateWindow(Constants.WindowIDs.ADMIN); this.btnWindowUtilities.IsFocused = false; return; } if (this.btnWindowCalendar != null && control == this.btnWindowCalendar) { SetGlobalIDs(); GUIWindowManager.ActivateWindow(Constants.WindowIDs.CALENDAR); //GUIWindowManager.ActivateWindow(Constants.WindowIDs.BROWSER); this.btnWindowCalendar.IsFocused = false; return; } if (this.btnWindowDownloads != null && control == this.btnWindowDownloads) { SetGlobalIDs(); GUIWindowManager.ActivateWindow(Constants.WindowIDs.DOWNLOADS); this.btnWindowDownloads.IsFocused = false; return; } if (this.btnWindowContinueWatching != null && control == this.btnWindowContinueWatching) { SetGlobalIDs(); GUIWindowManager.ActivateWindow(Constants.WindowIDs.WATCHING); this.btnWindowContinueWatching.IsFocused = false; return; } if (this.btnWindowRecommendations != null && control == this.btnWindowRecommendations) { SetGlobalIDs(); GUIWindowManager.ActivateWindow(Constants.WindowIDs.RECOMMENDATIONS); this.btnWindowRecommendations.IsFocused = false; return; } if (this.btnWindowRandom != null && control == this.btnWindowRandom) { RandomWindow_LevelObject = GroupFilterHelper.AllGroupsFilter; RandomWindow_RandomLevel = RandomSeriesEpisodeLevel.GroupFilter; RandomWindow_RandomType = RandomObjectType.Series; GUIWindowManager.ActivateWindow(Constants.WindowIDs.RANDOM); this.btnWindowRandom.IsFocused = false; return; } if (this.btnChangeLayout != null && control == this.btnChangeLayout) { ShowLayoutMenu(""); this.btnChangeLayout.IsFocused = false; return; } if (this.btnSwitchUser != null && control == this.btnSwitchUser) { if (JMMServerVM.Instance.PromptUserLogin()) { listLevel = Listlevel.GroupFilter; curAnimeEpisode = null; curAnimeGroup = null; curAnimeSeries = null; curGroupFilter = null; // user has logged in, so save to settings so we will log in as the same user next time settings.CurrentJMMUserID = JMMServerVM.Instance.CurrentUser.JMMUserID.ToString(); settings.Save(); LoadFacade(); } this.btnSwitchUser.IsFocused = false; return; } if (this.btnSettings != null && control == this.btnSettings) { hook.IsEnabled = false; ShowOptionsDisplayMenu(""); btnDisplayOptions.Focus = false; Thread.Sleep(100); //make sure key-up's from the context menu aren't cought by the hook hook.IsEnabled = true; this.btnSettings.IsFocused = false; return; } try { if (actionType != MediaPortal.GUI.Library.Action.ActionType.ACTION_SELECT_ITEM) return; // some other events raised onClicked too for some reason? if (control == this.m_Facade) { UpdateSearchPanel(false); if (this.m_Facade.SelectedListItem == null || this.m_Facade.SelectedListItem.TVTag == null) return; switch (listLevel) { case Listlevel.GroupFilter: curGroupFilter = this.m_Facade.SelectedListItem.TVTag as GroupFilterVM; if (curGroupFilter == null) return; if (curGroupFilter.GroupFilterID.Value == Constants.StaticGF.Predefined) { listLevel = Listlevel.GroupFilterSub; curGroupFilterSub2 = null; curGroupFilterSub = null; } else { listLevel = Listlevel.Group; curGroupFilterSub2 = null; curGroupFilterSub = null; } LoadFacade(); this.m_Facade.Focus = true; break; case Listlevel.GroupFilterSub: curGroupFilterSub = this.m_Facade.SelectedListItem.TVTag as GroupFilterVM; if (curGroupFilterSub == null) return; curGroupFilterSub2 = null; listLevel = Listlevel.GroupFilterSub2; LoadFacade(); this.m_Facade.Focus = true; break; case Listlevel.GroupFilterSub2: curGroupFilterSub2 = this.m_Facade.SelectedListItem.TVTag as GroupFilterVM; if (curGroupFilterSub2 == null) return; listLevel = Listlevel.Group; LoadFacade(); this.m_Facade.Focus = true; break; case Listlevel.Group: curAnimeGroup = this.m_Facade.SelectedListItem.TVTag as AnimeGroupVM; if (curAnimeGroup == null) return; curAnimeGroupViewed = curAnimeGroup; // e.g. if there is only one series for the group, show the episode types // if there is only for episode type for the series show the episodes ShowChildrenLevelForGroup(); LoadFacade(); this.m_Facade.Focus = true; break; case Listlevel.Series: if (this.m_Facade.SelectedListItem.TVTag == null) return; // sub groups if (this.m_Facade.SelectedListItem.TVTag.GetType() == typeof(AnimeGroupVM)) { curAnimeGroup = this.m_Facade.SelectedListItem.TVTag as AnimeGroupVM; if (curAnimeGroup == null) return; curAnimeGroupViewed = curAnimeGroup; ShowChildrenLevelForGroup(); } else if (this.m_Facade.SelectedListItem.TVTag.GetType() == typeof(AnimeSeriesVM)) { curAnimeSeries = this.m_Facade.SelectedListItem.TVTag as AnimeSeriesVM; if (curAnimeSeries == null) return; ShowChildrenLevelForSeries(); } LoadFacade(); this.m_Facade.Focus = true; break; case Listlevel.EpisodeTypes: curAnimeEpisodeType = this.m_Facade.SelectedListItem.TVTag as AnimeEpisodeTypeVM; if (curAnimeEpisodeType == null) return; listLevel = Listlevel.Episode; SetFanartForEpisodes(); LoadFacade(); this.m_Facade.Focus = true; break; case Listlevel.Episode: this.curAnimeEpisode = this.m_Facade.SelectedListItem.TVTag as AnimeEpisodeVM; if (curAnimeEpisode == null) return; BaseConfig.MyAnimeLog.Write("Selected to play: {0}", curAnimeEpisode.EpisodeNumberAndName); vidHandler.ResumeOrPlay(curAnimeEpisode); break; } } } catch (Exception ex) { BaseConfig.MyAnimeLog.Write("Error in OnClicked: {0} - {1}", ex.Message, ex.ToString()); } base.OnClicked(controlId, control, actionType); }
private bool ShowContextMenuGroup(string previousMenu) { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) return true; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; AnimeGroupVM grp = currentitem.TVTag as AnimeGroupVM; if (grp == null) return true; int mnuPrev = -1; int mnuFave = -1; int mnuWatched = -1; int mnuUnwatched = -1; int mnuEdit = -1; int mnuQuickSort = -1; int mnuRemoveQuickSort = -1; int mnuDatabases = -1; int mnuImages = -1; int mnuSeries = -1; int mnuRandomSeries = -1; int mnuRandomEpisode = -1; int mnuPostProcessing = -1; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = grp.GroupName; while (true) { int curMenu = -1; dlg.Reset(); dlg.SetHeading(currentMenu); string faveText = "Add to Favorites"; if (grp.IsFave == 1) faveText = "Remove from Favorites"; if (previousMenu != string.Empty) { dlg.Add("<<< " + previousMenu); curMenu++; mnuPrev = curMenu; } dlg.Add(faveText); curMenu++; mnuFave = curMenu; dlg.Add("Mark ALL as Watched"); curMenu++; mnuWatched = curMenu; dlg.Add("Mark ALL as Unwatched"); curMenu++; mnuUnwatched = curMenu; dlg.Add("Edit Group >>>"); curMenu++; mnuEdit = curMenu; dlg.Add("Quick Sort >>>"); curMenu++; mnuQuickSort = curMenu; if (GroupFilterQuickSorts.ContainsKey(curGroupFilter.GroupFilterID.Value)) { dlg.Add("Remove Quick Sort"); curMenu++; mnuRemoveQuickSort = curMenu; } if (grp.AllSeries.Count == 1) { dlg.Add("Databases >>>"); curMenu++; mnuDatabases = curMenu; dlg.Add("Images >>>"); curMenu++; mnuImages = curMenu; dlg.Add("Series Information"); curMenu++; mnuSeries = curMenu; } dlg.Add("Random Series"); curMenu++; mnuRandomSeries = curMenu; dlg.Add("Random Episode"); curMenu++; mnuRandomEpisode = curMenu; dlg.Add("Post-processing >>>"); curMenu++; mnuPostProcessing = curMenu; dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; if (selectedLabel == mnuPrev) return true; if (selectedLabel == mnuFave) { grp.IsFave = grp.IsFave == 1 ? 0 : 1; grp.Save(); EvaluateVisibility(); return false; } if (selectedLabel == mnuWatched) { foreach (AnimeSeriesVM ser in grp.AllSeries) JMMServerHelper.SetWatchedStatusOnSeries(true, int.MaxValue, ser.AnimeSeriesID.Value); LoadFacade(); return false; } if (selectedLabel == mnuUnwatched) { foreach (AnimeSeriesVM ser in grp.AllSeries) JMMServerHelper.SetWatchedStatusOnSeries(false, int.MaxValue, ser.AnimeSeriesID.Value); LoadFacade(); return false; } if (selectedLabel == mnuEdit) { if (!ShowContextMenuGroupEdit(currentMenu)) return false; } if (selectedLabel == mnuQuickSort) { string sortType = ""; GroupFilterSortDirection sortDirection = GroupFilterSortDirection.Asc; if (GroupFilterQuickSorts.ContainsKey(curGroupFilter.GroupFilterID.Value)) sortDirection = GroupFilterQuickSorts[curGroupFilter.GroupFilterID.Value].SortDirection; if (!Utils.DialogSelectGFQuickSort(ref sortType, ref sortDirection, curGroupFilter.GroupFilterName)) { if (!GroupFilterQuickSorts.ContainsKey(curGroupFilter.GroupFilterID.Value)) GroupFilterQuickSorts[curGroupFilter.GroupFilterID.Value] = new QuickSort(); GroupFilterQuickSorts[curGroupFilter.GroupFilterID.Value].SortType = sortType; GroupFilterQuickSorts[curGroupFilter.GroupFilterID.Value].SortDirection = sortDirection; LoadFacade(); return false; } } if (selectedLabel == mnuRemoveQuickSort) { GroupFilterQuickSorts.Remove(curGroupFilter.GroupFilterID.Value); LoadFacade(); return false; } if (selectedLabel == mnuDatabases) { if (!ShowContextMenuDatabases(grp.AllSeries[0], "Group Menu")) return false; } if (selectedLabel == mnuImages) { if (!ShowContextMenuImages(currentMenu)) return false; } if (selectedLabel == mnuSeries) { ShowAnimeInfoWindow(); return false; } if (selectedLabel == mnuRandomSeries) { RandomWindow_CurrentEpisode = null; RandomWindow_CurrentSeries = null; RandomWindow_LevelObject = grp; RandomWindow_RandomLevel = RandomSeriesEpisodeLevel.Group; RandomWindow_RandomType = RandomObjectType.Series; GUIWindowManager.ActivateWindow(Constants.WindowIDs.RANDOM); return false; } if (selectedLabel == mnuRandomEpisode) { RandomWindow_CurrentEpisode = null; RandomWindow_CurrentSeries = null; RandomWindow_LevelObject = grp; RandomWindow_RandomLevel = RandomSeriesEpisodeLevel.Group; RandomWindow_RandomType = RandomObjectType.Episode; GUIWindowManager.ActivateWindow(Constants.WindowIDs.RANDOM); return false; } if (selectedLabel == mnuPostProcessing) { ShowContextMenuPostProcessing(currentMenu); return false; } } }
public void PopulateSeries(JMMServerBinary.Contract_AnimeSeries seriesContract) { if (seriesContract != null) AnimeSeries = new AnimeSeriesVM(seriesContract); EvaluateProperties(); }
private bool ShowContextMenuGroupFilter(string previousMenu) { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) return true; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; GroupFilterVM gf = currentitem.TVTag as GroupFilterVM; if (gf == null) return true; int mnuPrev = -1; int mnuRandomSeries = -1; int mnuRandomEpisode = -1; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = gf.GroupFilterName; while (true) { int curMenu = -1; dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) { dlg.Add("<<< " + previousMenu); curMenu++; mnuPrev = curMenu; } dlg.Add("Random Series"); curMenu++; mnuRandomSeries = curMenu; dlg.Add("Random Episode"); curMenu++; mnuRandomEpisode = curMenu; dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; if (selectedLabel == mnuPrev) return true; if (selectedLabel == mnuRandomSeries) { RandomWindow_CurrentEpisode = null; RandomWindow_CurrentSeries = null; RandomWindow_LevelObject = gf; RandomWindow_RandomLevel = RandomSeriesEpisodeLevel.GroupFilter; RandomWindow_RandomType = RandomObjectType.Series; GUIWindowManager.ActivateWindow(Constants.WindowIDs.RANDOM); return false; } if (selectedLabel == mnuRandomEpisode) { RandomWindow_CurrentEpisode = null; RandomWindow_CurrentSeries = null; RandomWindow_LevelObject = gf; RandomWindow_RandomLevel = RandomSeriesEpisodeLevel.GroupFilter; RandomWindow_RandomType = RandomObjectType.Episode; GUIWindowManager.ActivateWindow(Constants.WindowIDs.RANDOM); return false; } } }
public static String GetSeriesImage(AnimeSeriesVM ser, GUIFacadeControl.Layout viewMode) { string imgFileName = ""; Size sz = PosterSize; switch (viewMode) { case GUIFacadeControl.Layout.LargeIcons: imgFileName = GetWideBannerAsFileName(ser.AniDB_Anime); sz = BannerSize; break; case GUIFacadeControl.Layout.List: case GUIFacadeControl.Layout.AlbumView: case GUIFacadeControl.Layout.Filmstrip: case GUIFacadeControl.Layout.CoverFlow: imgFileName = GetPosterAsFileName(ser.AniDB_Anime); sz = PosterSize; break; } //BaseConfig.MyAnimeLog.Write("GetSeriesBannerAsFileName::viewMode: {0} : {1} : {2}", viewMode, imgFileName, ser); if (imgFileName.Length == 0) { string ident = "series_" + ser.SeriesName; string sTextureName = buildMemoryImage(drawSimpleBanner(sz, ser.SeriesName), ident, sz, true); if (sTextureName.Length > 0 && !s_SeriesImageList.Contains(sTextureName)) s_SeriesImageList.Add(sTextureName); return sTextureName; } else { string sTextureName = ""; if (imgFileName.Length > 0 && System.IO.File.Exists(imgFileName)) { sTextureName = buildMemoryImageFromFile(imgFileName, sz); } return sTextureName; } }
private bool ShowContextMenuMAL(AnimeSeriesVM ser, string previousMenu) { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) return true; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; //int moviedbid = -1; string displayName = ""; if (ser.CrossRef_AniDB_MAL != null && ser.CrossRef_AniDB_MAL.Count > 0) { if (ser.CrossRef_AniDB_MAL.Count == 1) displayName = ser.CrossRef_AniDB_MAL[0].MALTitle; else displayName = "Multiple Links!"; } else return false; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = displayName; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); dlg.Add("Remove MAL Association"); dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); switch (selection) { case 0: //show previous return true; case 1: foreach (CrossRef_AniDB_MALVM xref in ser.CrossRef_AniDB_MAL) { JMMServerVM.Instance.clientBinaryHTTP.RemoveLinkAniDBMAL(xref.AnimeID, xref.StartEpisodeType, xref.StartEpisodeNumber); } return false; default: //close menu return false; } } }
private void LoadInfo() { if (MainWindow.GlobalSeriesID > 0) { serMain = JMMServerHelper.GetSeries(MainWindow.GlobalSeriesID); if (serMain != null) MainAnime = serMain.AniDB_Anime; } }
public override void OnAction(MediaPortal.GUI.Library.Action action) { //BaseConfig.MyAnimeLog.Write("Received action: {0}/{1}", action.wID, (char)(action.m_key.KeyChar)); switch (action.wID) { case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_DOWN: case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_UP: //Reset autoclose timer on search if (searchTimer.Enabled) { searchTimer.Stop(); searchTimer.Start(); } base.OnAction(action); break; case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_LEFT: case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_RIGHT: base.OnAction(action); break; case MediaPortal.GUI.Library.Action.ActionType.ACTION_KEY_PRESSED: //when the list is selected, search the input if (GUIWindowManager.ActiveWindowEx == this.GetID) { if ((m_Facade.CurrentLayout == GUIFacadeControl.Layout.List && m_Facade.ListLayout.IsFocused) || (m_Facade.CurrentLayout == GUIFacadeControl.Layout.LargeIcons && m_Facade.ThumbnailLayout.IsFocused) || (m_Facade.CurrentLayout == GUIFacadeControl.Layout.Filmstrip && m_Facade.FilmstripLayout.IsFocused) || (m_Facade.CurrentLayout == GUIFacadeControl.Layout.CoverFlow && m_Facade.CoverFlowLayout.IsFocused)) OnSearchChar((char)(action.m_key.KeyChar)); } break; case MediaPortal.GUI.Library.Action.ActionType.ACTION_PARENT_DIR: case MediaPortal.GUI.Library.Action.ActionType.ACTION_HOME: UpdateSearchPanel(false); ImageAllocator.FlushAll(); GUIWindowManager.ShowPreviousWindow(); break; case MediaPortal.GUI.Library.Action.ActionType.ACTION_PLAY: BaseConfig.MyAnimeLog.Write("Received PLAY action"); try { if (listLevel == Listlevel.Group) { if (curAnimeGroup == null) return; JMMServerBinary.Contract_AnimeEpisode contract = JMMServerVM.Instance.clientBinaryHTTP.GetNextUnwatchedEpisodeForGroup(curAnimeGroup.AnimeGroupID, JMMServerVM.Instance.CurrentUser.JMMUserID); if (contract == null) return; AnimeEpisodeVM ep = new AnimeEpisodeVM(contract); vidHandler.ResumeOrPlay(ep); } if (listLevel == Listlevel.Series) { //curAnimeSeries = null; if (curAnimeSeries == null) return; JMMServerBinary.Contract_AnimeEpisode contract = JMMServerVM.Instance.clientBinaryHTTP.GetNextUnwatchedEpisode(curAnimeSeries.AnimeSeriesID.Value, JMMServerVM.Instance.CurrentUser.JMMUserID); if (contract == null) return; AnimeEpisodeVM ep = new AnimeEpisodeVM(contract); vidHandler.ResumeOrPlay(ep); } } catch (Exception ex) { BaseConfig.MyAnimeLog.Write(ex.ToString()); } break; case MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU: if (searchTimer.Enabled) { OnSearchAction(SearchAction.EndSearch); return; } // back one level if (listLevel == Listlevel.GroupFilter) { goto case MediaPortal.GUI.Library.Action.ActionType.ACTION_HOME; } else { string msg = string.Format("LIST LEVEL:: {0} - GF: {1} - GFSub2: {2}", listLevel, curGroupFilter, curGroupFilterSub2); BaseConfig.MyAnimeLog.Write(msg); if (listLevel == Listlevel.GroupFilterSub) { listLevel = Listlevel.GroupFilter; curGroupFilterSub = null; LoadFacade(); } if (listLevel == Listlevel.GroupFilterSub2) { // go back to GROUP FILTERS listLevel = Listlevel.GroupFilterSub; curGroupFilterSub2 = null; LoadFacade(); } if (listLevel == Listlevel.Group) { if (curGroupFilterSub2 == null) { // go back to GROUP FILTERS listLevel = Listlevel.GroupFilter; } else { listLevel = Listlevel.GroupFilterSub2; } LoadFacade(); curAnimeGroup = null; } if (listLevel == Listlevel.Series) { // go back to GROUP AnimeGroupVM parentGroup = curAnimeGroupViewed.ParentGroup; if (parentGroup == null) listLevel = Listlevel.Group; ShowParentLevelForGroup(parentGroup); LoadFacade(); curAnimeEpisodeType = null; curAnimeSeries = null; } if (listLevel == Listlevel.EpisodeTypes) { // go back to SERIES AnimeSeriesVM parentSeries = curAnimeEpisodeType.AnimeSeries; ShowParentLevelForSeries(parentSeries); LoadFacade(); return; } if (listLevel == Listlevel.Episode) { AnimeSeriesVM parentSeries = curAnimeEpisodeType.AnimeSeries; if (parentSeries.EpisodeTypesToDisplay.Count == 1) ShowParentLevelForSeries(parentSeries); else { listLevel = Listlevel.EpisodeTypes; curAnimeEpisodeType = null; } LoadFacade(); return; } } break; default: base.OnAction(action); break; } }
public AnimeEpisodeTypeVM(AnimeSeriesVM series, AnimeEpisodeVM ep) { AnimeSeries = series; EpisodeType = (enEpisodeType)ep.EpisodeType; EpisodeTypeDescription = AnimeEpisodeTypeVM.EpisodeTypeTranslated(EpisodeType); }
private bool ShowContextMenuMovieDB(AnimeSeriesVM ser, string previousMenu) { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) return true; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; //int moviedbid = -1; string displayName = ""; if (ser.CrossRef_AniDB_MovieDB != null && ser.AniDB_Anime.AniDB_AnimeCrossRefs != null && ser.AniDB_Anime.AniDB_AnimeCrossRefs.MovieDB_Movie != null) { displayName = ser.AniDB_Anime.AniDB_AnimeCrossRefs.MovieDB_Movie.MovieName; } else return false; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = displayName; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); dlg.Add("Remove MovieDB Association"); dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); switch (selection) { case 0: //show previous return true; case 1: JMMServerVM.Instance.clientBinaryHTTP.RemoveLinkAniDBOther(ser.AniDB_Anime.AnimeID, (int)CrossRefType.MovieDB); return false; default: //close menu return false; } } }
private bool ShowContextMenuSeries(string previousMenu) { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) return true; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return true; AnimeSeriesVM ser = currentitem.TVTag as AnimeSeriesVM; if (ser == null) return true; //keep showing the dialog until the user closes it int selectedLabel = 0; string currentMenu = ser.SeriesName; while (true) { dlg.Reset(); dlg.SetHeading(currentMenu); if (previousMenu != string.Empty) dlg.Add("<<< " + previousMenu); dlg.Add("Series Information"); dlg.Add("Mark all as watched"); dlg.Add("Mark all as unwatched"); dlg.Add("Databases >>>"); dlg.Add("Images >>>"); dlg.Add("Edit Series >>>"); dlg.Add("Random Episode"); dlg.Add("Post-processing >>>"); dlg.SelectedLabel = selectedLabel; dlg.DoModal(GUIWindowManager.ActiveWindow); selectedLabel = dlg.SelectedLabel; int selection = selectedLabel + ((previousMenu == string.Empty) ? 1 : 0); switch (selection) { case 0: //show previous return true; case 1: ShowAnimeInfoWindow(); return false; case 2: // Mark ALL as Watched { JMMServerHelper.SetWatchedStatusOnSeries(true, int.MaxValue, ser.AnimeSeriesID.Value); JMMServerBinary.Contract_AnimeSeries contract = JMMServerVM.Instance.clientBinaryHTTP.GetSeries(ser.AnimeSeriesID.Value, JMMServerVM.Instance.CurrentUser.JMMUserID); if (contract != null) { AnimeSeriesVM serTemp = new AnimeSeriesVM(contract); Utils.PromptToRateSeriesOnCompletion(serTemp); } LoadFacade(); return false; } case 3: // Mark ALL as Unwatched { JMMServerHelper.SetWatchedStatusOnSeries(false, int.MaxValue, ser.AnimeSeriesID.Value); LoadFacade(); return false; } case 4: if (!ShowContextMenuDatabases(ser, currentMenu)) return false; break; case 5: if (!ShowContextMenuImages(currentMenu)) return false; break; case 6: if (!ShowContextMenuSeriesEdit(currentMenu)) return false; break; case 7: RandomWindow_CurrentEpisode = null; RandomWindow_CurrentSeries = null; RandomWindow_LevelObject = ser; RandomWindow_RandomLevel = RandomSeriesEpisodeLevel.Series; RandomWindow_RandomType = RandomObjectType.Episode; GUIWindowManager.ActivateWindow(Constants.WindowIDs.RANDOM); return false; case 8: if (!ShowContextMenuPostProcessing(currentMenu)) return false; break; default: //close menu return false; } } }