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); }
public AnimeEpisodeTypeVM(AnimeSeriesVM series, AnimeEpisodeVM ep) { AnimeSeries = series; EpisodeType = (enEpisodeType)ep.EpisodeType; EpisodeTypeDescription = AnimeEpisodeTypeVM.EpisodeTypeTranslated(EpisodeType); }
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; } } } }
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; } }
private void ShowChildrenLevelForSeries() { List<AnimeEpisodeTypeVM> episodeTypes = curAnimeSeries.EpisodeTypesToDisplay; if (episodeTypes.Count > 1) { listLevel = Listlevel.EpisodeTypes; } else if (episodeTypes.Count == 1) { setGUIProperty(guiProperty.SeriesTitle, curAnimeSeries.SeriesName); // only one so lets go straight to the episodes curAnimeEpisodeType = episodeTypes[0]; listLevel = Listlevel.Episode; SetFanartForEpisodes(); BaseConfig.MyAnimeLog.Write("Current list level: {0} - {1}", listLevel, curAnimeEpisodeType); } }
private void SetEpisodeTypeListItem(ref GUIListItem item, AnimeEpisodeTypeVM epType) { string sIconList = GUIGraphicsContext.Skin + @"\Media\MyAnime3\anime3_ListIcon.png"; string sUnWatchedFilename = GUIGraphicsContext.Skin + @"\Media\MyAnime3\anime3_UnWatched_left.png"; try { item = new GUIListItem(epType.EpisodeTypeDescription); item.DVDLabel = epType.EpisodeTypeDescription; item.TVTag = epType; int unwatched = 0; int watched = 0; if (curAnimeSeries != null) curAnimeSeries.GetWatchedUnwatchedCount(epType.EpisodeType, ref unwatched, ref watched); item.IsPlayed = (unwatched == 0); View.eLabelStyleGroups style = View.eLabelStyleGroups.WatchedUnwatched; switch (style) { case View.eLabelStyleGroups.WatchedUnwatched: 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 (unwatched > 0) { item.IconImage = sUnWatchedFilename; item.Label3 = unwatched.ToString() + " New"; item.Label2 = " "; } else { item.Label2 = " "; item.Label3 = " "; } break; case View.eLabelStyleGroups.TotalEpisodes: int totalEps = unwatched + watched; item.IconImage = sUnWatchedFilename; item.Label3 = totalEps.ToString() + " Episodes"; item.Label2 = " "; break;*/ } } catch (Exception ex) { BaseConfig.MyAnimeLog.Write("Failed to create episode type item: {0}", ex); } }
private void EpisodeType_OnItemSelected(GUIListItem item) { if (m_bQuickSelect) return; if (dummyIsAvailable != null) dummyIsAvailable.Visible = true; clearGUIProperty("SeriesGroup.Year"); clearGUIProperty("SeriesGroup.Genre"); clearGUIProperty("SeriesGroup.Episodes"); clearGUIProperty("SeriesGroup.Rating"); clearGUIProperty(guiProperty.SeriesTitle); clearGUIProperty(guiProperty.Subtitle); clearGUIProperty(guiProperty.Description); clearGUIProperty("SeriesGroup.EpisodeCountNormal"); clearGUIProperty("SeriesGroup.EpisodeCountSpecial"); clearGUIProperty("SeriesGroup.EpisodeCountUnwatched"); clearGUIProperty("SeriesGroup.EpisodeCountWatched"); clearGUIProperty("SeriesGroup.RatingVoteCount"); clearGUIProperty("SeriesGroup.RawRating"); if (item == null || item.TVTag == null || !(item.TVTag is AnimeEpisodeTypeVM)) return; AnimeEpisodeTypeVM epType = item.TVTag as AnimeEpisodeTypeVM; if (epType == null) return; curAnimeEpisodeType = epType; if (curAnimeSeries == null) return; AniDB_AnimeVM anAnime = curAnimeSeries.AniDB_Anime; setGUIProperty(guiProperty.SeriesTitle, curAnimeSeries.SeriesName); setGUIProperty(guiProperty.Subtitle, ""); setGUIProperty(guiProperty.Description, curAnimeSeries.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 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); int unwatched = 0; int watched = 0; if (curAnimeSeries != null) curAnimeSeries.GetWatchedUnwatchedCount(epType.EpisodeType, ref unwatched, ref watched); // set watched/unavailable flag if (dummyIsWatched != null) dummyIsWatched.Visible = (unwatched == 0); setGUIProperty("SeriesGroup.EpisodeCountUnwatched", unwatched.ToString()); setGUIProperty("SeriesGroup.EpisodeCountWatched", watched.ToString()); // Delayed Image Loading of Series Banners listPoster.Filename = ImageAllocator.GetSeriesImageAsFileName(curAnimeSeries, GUIFacadeControl.Layout.List); }