public static List <GroupFilterVM> GetTopLevelPredefinedGroupFilters() { List <GroupFilterVM> gfs = new List <GroupFilterVM>(); GroupFilterVM gf = new GroupFilterVM(); gf.GroupFilterID = Constants.StaticGF.Predefined_Years; gf.FilterConditions = new List <GroupFilterConditionVM>(); gf.ApplyToSeries = 0; gf.BaseCondition = 1; gf.PredefinedCriteria = ""; gf.GroupFilterName = "By Year"; gfs.Add(gf); GroupFilterVM gfGenres = new GroupFilterVM(); gfGenres.GroupFilterID = Constants.StaticGF.Predefined_Categories; gfGenres.FilterConditions = new List <GroupFilterConditionVM>(); gfGenres.ApplyToSeries = 0; gfGenres.BaseCondition = 1; gfGenres.PredefinedCriteria = ""; gfGenres.GroupFilterName = "By Category"; gfs.Add(gfGenres); return(gfs); }
void btnRandomSeries_Click(object sender, RoutedEventArgs e) { GroupFilterVM gf = this.DataContext as GroupFilterVM; if (gf == null) { return; } MainWindow mainwdw = (MainWindow)Window.GetWindow(this); RandomSeriesForm frm = new RandomSeriesForm(); frm.Owner = Window.GetWindow(this);; frm.Init(RandomSeriesEpisodeLevel.GroupFilter, gf); bool?result = frm.ShowDialog(); if (result.HasValue && result.Value && frm.Series != null) { if (mainwdw == null) { return; } mainwdw.ShowPinnedSeries(frm.Series); } }
public static List <SortDescription> GetSortDescriptions(GroupFilterVM gf) { List <SortDescription> sortlist = new List <SortDescription>(); foreach (GroupFilterSortingCriteria gfsc in gf.SortCriteriaList) { sortlist.Add(GetSortDescription(gfsc.SortType, gfsc.SortDirection)); } return(sortlist); }
void chkApplyToSeriesEditing_Click(object sender, RoutedEventArgs e) { chkApplyToSeries.IsChecked = chkApplyToSeriesEditing.IsChecked; GroupFilterVM gf = this.DataContext as GroupFilterVM; if (gf == null) { return; } gf.ApplyToSeries = chkApplyToSeriesEditing.IsChecked.Value ? 1 : 0; }
public void Init(GroupFilterVM gf, GroupFilterSortingCriteria gfsc) { groupFilter = gf; groupFilterSortingCriteria = gfsc; try { cboSortType.Items.Clear(); foreach (string stype in GroupFilterHelper.GetAllSortTypes()) { if (gf != null) { bool alreadyExists = false; foreach (GroupFilterSortingCriteria gfsc_old in gf.SortCriteriaList) { if (GroupFilterHelper.GetTextForEnum_Sorting(gfsc_old.SortType) == stype) { alreadyExists = true; break; } } if (!alreadyExists) { cboSortType.Items.Add(stype); } } } if (cboSortType.Items.Count > 0) { cboSortType.SelectedIndex = 0; } cboDirection.Items.Clear(); cboDirection.Items.Add(GroupFilterHelper.GetTextForEnum_SortDirection(GroupFilterSortDirection.Asc)); cboDirection.Items.Add(GroupFilterHelper.GetTextForEnum_SortDirection(GroupFilterSortDirection.Desc)); cboDirection.SelectedIndex = 0; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void Init(GroupFilterVM gf, GroupFilterSortingCriteria gfsc) { groupFilter = gf; groupFilterSortingCriteria = gfsc; try { cboSortType.Items.Clear(); foreach (string stype in GroupFilterHelper.GetAllSortTypes()) { if (gf != null) { bool alreadyExists = false; foreach (GroupFilterSortingCriteria gfsc_old in gf.SortCriteriaList) { if (GroupFilterHelper.GetTextForEnum_Sorting(gfsc_old.SortType) == stype) { alreadyExists = true; break; } } if (!alreadyExists) cboSortType.Items.Add(stype); } } if (cboSortType.Items.Count > 0) cboSortType.SelectedIndex = 0; cboDirection.Items.Clear(); cboDirection.Items.Add(GroupFilterHelper.GetTextForEnum_SortDirection(GroupFilterSortDirection.Asc)); cboDirection.Items.Add(GroupFilterHelper.GetTextForEnum_SortDirection(GroupFilterSortDirection.Desc)); cboDirection.SelectedIndex = 0; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void GroupFilterAdmin_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { GroupFilterVM gf = this.DataContext as GroupFilterVM; if (gf == null) { return; } if (gf.BaseCondition == 1) { cboBaseConditionEditing.SelectedIndex = 0; cboBaseConditionEditing.SelectedIndex = 0; } else { cboBaseConditionEditing.SelectedIndex = 1; cboBaseConditionEditing.SelectedIndex = 1; } }
void cboBaseConditionEditing_SelectionChanged(object sender, SelectionChangedEventArgs e) { GroupFilterVM gf = this.DataContext as GroupFilterVM; if (gf == null) { return; } if (cboBaseConditionEditing.SelectedIndex == 0) { gf.BaseCondition = 1; } else { gf.BaseCondition = 2; } cboBaseCondition.SelectedIndex = cboBaseConditionEditing.SelectedIndex; }
public static List <GroupFilterVM> GetGroupFiltersFromDatabase() { List <GroupFilterVM> gfs = new List <GroupFilterVM>(); try { List <JMMServerBinary.Contract_GroupFilter> gf_cons = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupFilters(); foreach (JMMServerBinary.Contract_GroupFilter gf_con in gf_cons) { GroupFilterVM gf = new GroupFilterVM(gf_con); gf.AllowEditing = true; gfs.Add(gf); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } gfs.Sort(); return(gfs); }
public static List<GroupFilterVM> GetGroupFiltersFromDatabase() { List<GroupFilterVM> gfs = new List<GroupFilterVM>(); try { List<JMMServerBinary.Contract_GroupFilter> gf_cons = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupFilters(); foreach (JMMServerBinary.Contract_GroupFilter gf_con in gf_cons) { GroupFilterVM gf = new GroupFilterVM(gf_con); gf.AllowEditing = true; gfs.Add(gf); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } gfs.Sort(); return gfs; }
void lbFilterConditions_Editing_MouseDoubleClick(object sender, MouseButtonEventArgs e) { GroupFilterVM gf = this.DataContext as GroupFilterVM; if (gf == null) { return; } GroupFilterConditionVM gfc = lbFilterConditions_Editing.SelectedItem as GroupFilterConditionVM; if (gfc == null) { return; } try { GroupFilterConditionForm frm = new GroupFilterConditionForm(); frm.Owner = Window.GetWindow(this); frm.Init(gf, gfc); bool?result = frm.ShowDialog(); if (result.HasValue && result.Value == true) { Window win = Window.GetWindow(this); MainWindow main = win as MainWindow; //gf.FilterConditions.Add(gfc); MainListHelperVM.Instance.ViewGroupsForms.Filter = main.GroupFilter_GroupSearch; MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
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; } }
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 void CommandBinding_DeleteFilterCondition(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) return; try { if (obj.GetType() == typeof(GroupFilterConditionVM)) { GroupFilterConditionVM gfc = (GroupFilterConditionVM)obj; MessageBoxResult res = MessageBox.Show(string.Format("Are you sure you want to delete the Filter Condition: {0}", gfc.NiceDescription), "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.Yes) { // remove from group list //gfc.Delete(); // fund the GroupFilter foreach (GroupFilterVM gf in MainListHelperVM.Instance.AllGroupFilters) { if (!gf.AllowEditing) continue; // all filter if (gf.GroupFilterID == gfc.GroupFilterID) { int pos = -1; for (int i = 0; i < gf.FilterConditions.Count; i++) { if (gfc.ConditionOperator == gf.FilterConditions[i].ConditionOperator && gfc.ConditionParameter == gf.FilterConditions[i].ConditionParameter && gfc.ConditionType == gf.FilterConditions[i].ConditionType) { pos = i; break; } } if (pos >= 0) gf.FilterConditions.RemoveAt(pos); groupFilterVM = gf; MainListHelperVM.Instance.ViewGroupsForms.Filter = GroupFilter_GroupSearch; MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf); } } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private List <AnimeSeriesVM> GetSeriesForGroupFilter() { List <AnimeSeriesVM> serList = new List <AnimeSeriesVM>(); try { if (LevelType != RandomSeriesEpisodeLevel.GroupFilter) { return(serList); } GroupFilterVM gf = LevelObject as GroupFilterVM; if (gf == null) { return(serList); } foreach (AnimeGroupVM grp in MainListHelperVM.Instance.AllGroupsDictionary.Values) { // ignore sub groups if (grp.AnimeGroupParentID.HasValue) { continue; } foreach (AnimeSeriesVM ser in grp.AllAnimeSeries) { if (gf.EvaluateGroupFilter(ser)) { // tags if (!string.IsNullOrEmpty(SelectedTags)) { string filterParm = SelectedTags.Trim(); string[] cats = filterParm.Split(','); bool foundCat = false; if (cboCatFilter.SelectedIndex == 1) { foundCat = true; // all } foreach (string cat in cats) { if (cat.Trim().Length == 0) { continue; } if (cat.Trim() == ",") { continue; } bool fnd = ser.AllTags.Contains(cat, StringComparer.InvariantCultureIgnoreCase); if (cboCatFilter.SelectedIndex == 0) // any { if (fnd) { foundCat = true; break; } } else //all { if (!fnd) { foundCat = false; break; } } } if (!foundCat) { continue; } } serList.Add(ser); } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(serList); }
public static List<GroupFilterVM> GetChildGroupFilters(GroupFilterVM gf) { return JMMServerHelper.GetChildGroupFilters(gf); }
private void SetDisplayDetails() { string combinedDetails = ""; setGUIProperty("LevelType", "-"); setGUIProperty("LevelName", "-"); setGUIProperty("NumberOfMatches", "-"); setGUIProperty("CombinedFilterDetails", "-"); setGUIProperty("Series.CategoryType", "-"); setGUIProperty("Episode.CategoryType", "-"); setGUIProperty("Series.Categories", "-"); setGUIProperty("Episode.Categories", "-"); if (MainWindow.RandomWindow_RandomLevel == RandomSeriesEpisodeLevel.GroupFilter) { setGUIProperty("LevelType", "Group Filter"); GroupFilterVM gf = MainWindow.RandomWindow_LevelObject as GroupFilterVM; setGUIProperty("LevelName", gf.GroupFilterName); combinedDetails += "Group Filter: " + gf.GroupFilterName; } if (MainWindow.RandomWindow_RandomLevel == RandomSeriesEpisodeLevel.Group) { setGUIProperty("LevelType", "Group"); AnimeGroupVM grp = MainWindow.RandomWindow_LevelObject as AnimeGroupVM; setGUIProperty("LevelName", grp.GroupName); combinedDetails += "Group: " + grp.GroupName; } if (MainWindow.RandomWindow_RandomLevel == RandomSeriesEpisodeLevel.Series) { setGUIProperty("LevelType", "Series"); AnimeSeriesVM ser = MainWindow.RandomWindow_LevelObject as AnimeSeriesVM; setGUIProperty("LevelName", ser.SeriesName); combinedDetails += "Series: " + ser.SeriesName; } if (MainWindow.RandomWindow_RandomType == RandomObjectType.Series) { combinedDetails += string.Format(" ({0} Matches)", MainWindow.RandomWindow_MatchesFound); } setGUIProperty("CombinedFilterDetails", combinedDetails); setGUIProperty("NumberOfMatches", MainWindow.RandomWindow_MatchesFound.ToString()); setGUIProperty("Series.Categories", MainWindow.RandomWindow_SeriesCategories); setGUIProperty("Episode.Categories", MainWindow.RandomWindow_EpisodeCategories); if (MainWindow.RandomWindow_SeriesAllCategories) { setGUIProperty("Series.CategoryType", "All"); } else { setGUIProperty("Series.CategoryType", "Any"); } if (MainWindow.RandomWindow_EpisodeAllCategories) { setGUIProperty("Episode.CategoryType", "All"); } else { setGUIProperty("Episode.CategoryType", "Any"); } }
public static List<SortPropOrFieldAndDirection> GetSortDescriptions(GroupFilterVM gf) { List<SortPropOrFieldAndDirection> sortlist = new List<SortPropOrFieldAndDirection>(); foreach (GroupFilterSortingCriteria gfsc in gf.SortCriteriaList) { sortlist.Add(GetSortDescription(gfsc.SortType, gfsc.SortDirection)); } return sortlist; }
/// <summary> /// Moves group sorting up and down /// </summary> /// <param name="gfsc"></param> /// <param name="direction">1 = up, 2 = down</param> private void GroupFilterSortMoveUpDown(GroupFilterSortingCriteria gfsc, int direction) { // find the sorting condition foreach (GroupFilterVM gf in MainListHelperVM.Instance.AllGroupFiltersDictionary.Values) { if (!gf.AllowEditing) continue; // all filter if (gf.GroupFilterID == gfsc.GroupFilterID) { int pos = -1; for (int i = 0; i < gf.SortCriteriaList.Count; i++) { if (gfsc.SortType == gf.SortCriteriaList[i].SortType) { pos = i; break; } } if (direction == 1) // up { if (pos > 0) { gf.SortCriteriaList.Move(pos, pos - 1); groupFilterVM = gf; MainListHelperVM.Instance.ViewGroupsForms.Filter = GroupFilter_GroupSearch; MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf); } } else { if (pos + 1 < gf.SortCriteriaList.Count) { gf.SortCriteriaList.Move(pos, pos + 1); groupFilterVM = gf; MainListHelperVM.Instance.ViewGroupsForms.Filter = GroupFilter_GroupSearch; MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf); } } } } }
private void CommandBinding_NewFilterSorting(object sender, ExecutedRoutedEventArgs e) { try { object obj = e.Parameter; if (obj == null) return; GroupFilterVM gf = (GroupFilterVM)obj; GroupFilterSortingCriteria gfsc = new GroupFilterSortingCriteria(); GroupFilterSortingForm frm = new GroupFilterSortingForm(); frm.Owner = this; frm.Init(gf, gfsc); bool? result = frm.ShowDialog(); if (result.HasValue && result.Value == true) { gf.SortCriteriaList.Add(gfsc); groupFilterVM = gf; MainListHelperVM.Instance.ViewGroupsForms.Filter = GroupFilter_GroupSearch; MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private bool SetGroupFilterListItem(ref GUIListItem item, GroupFilterVM grpFilter) { item = new GUIListItem(grpFilter.GroupFilterName); item.DVDLabel = grpFilter.GroupFilterName; item.TVTag = grpFilter; item.IsPlayed = false; return true; }
private List <AnimeSeriesVM> GetSeriesForGroupFilter() { List <AnimeSeriesVM> serList = new List <AnimeSeriesVM>(); try { BaseConfig.MyAnimeLog.Write("Getting list of candidate random series"); if (MainWindow.RandomWindow_RandomLevel != RandomSeriesEpisodeLevel.GroupFilter) { return(serList); } GroupFilterVM gf = MainWindow.RandomWindow_LevelObject as GroupFilterVM; if (gf == null) { return(serList); } BaseConfig.MyAnimeLog.Write("Getting list of candidate random series for: " + gf.GroupFilterName); bool allCats = MainWindow.RandomWindow_SeriesAllCategories; if (MainWindow.RandomWindow_RandomType == RandomObjectType.Episode) { allCats = MainWindow.RandomWindow_EpisodeAllCategories; } bool completeSeries = true; bool allWatched = true; bool unwatched = true; bool partiallyWatched = true; if (togWatched != null) { allWatched = togWatched.Selected; } if (togUnwatched != null) { unwatched = togUnwatched.Selected; } if (togPartiallyWatched != null) { partiallyWatched = togPartiallyWatched.Selected; } if (togCompleteOnly != null) { completeSeries = togCompleteOnly.Selected; } List <JMMServerBinary.Contract_AnimeGroup> contracts = JMMServerVM.Instance.clientBinaryHTTP.GetAnimeGroupsForFilter( gf.GroupFilterID.Value, JMMServerVM.Instance.CurrentUser.JMMUserID, BaseConfig.Settings.SingleSeriesGroups); BaseConfig.MyAnimeLog.Write("Total groups for filter = " + contracts.Count.ToString()); string selectedCategories = MainWindow.RandomWindow_SeriesCategories; if (MainWindow.RandomWindow_RandomType == RandomObjectType.Episode) { selectedCategories = MainWindow.RandomWindow_EpisodeCategories; } foreach (JMMServerBinary.Contract_AnimeGroup grpContract in contracts) { AnimeGroupVM grp = new AnimeGroupVM(grpContract); // ignore sub groups if (grp.AnimeGroupParentID.HasValue) { continue; } foreach (AnimeSeriesVM ser in grp.AllSeries) { // categories if (!string.IsNullOrEmpty(selectedCategories)) { string filterParm = selectedCategories.Trim(); string[] cats = filterParm.Split(','); bool foundCat = false; if (allCats) { foundCat = true; // all } int index = 0; foreach (string cat in cats) { string thiscat = cat.Trim(); if (thiscat.Trim().Length == 0) { continue; } if (thiscat.Trim() == ",") { continue; } index = ser.CategoriesString.IndexOf(thiscat, 0, StringComparison.InvariantCultureIgnoreCase); if (!allCats) // any { if (index > -1) { foundCat = true; break; } } else //all { if (index < 0) { foundCat = false; break; } } } if (!foundCat) { continue; } } if (!ser.IsComplete && completeSeries) { continue; } if (allWatched && ser.AllFilesWatched) { serList.Add(ser); continue; } if (unwatched && !ser.AnyFilesWatched) { serList.Add(ser); continue; } if (partiallyWatched && ser.AnyFilesWatched && !ser.AllFilesWatched) { serList.Add(ser); continue; } } } } catch (Exception ex) { BaseConfig.MyAnimeLog.Write(ex.ToString()); } return(serList); }
public void SetGroupFilterSortingOnForms(GroupFilterVM gf) { ViewGroupsForms.SortDescriptions.Clear(); if (gf != null) { List<SortDescription> sortlist = GroupFilterHelper.GetSortDescriptions(gf); foreach (SortDescription sd in sortlist) ViewGroupsForms.SortDescriptions.Add(sd); } }
public static List<AnimeGroupVM> GetAnimeGroupsForFilter(GroupFilterVM groupFilter) { DateTime start = DateTime.Now; List<AnimeGroupVM> allGroups = new List<AnimeGroupVM>(); if (JMMServerVM.Instance.CurrentUser == null) return allGroups; try { List<JMMServerBinary.Contract_AnimeGroup> rawGrps = JMMServerVM.Instance.clientBinaryHTTP.GetAnimeGroupsForFilter(groupFilter.GroupFilterID.Value, JMMServerVM.Instance.CurrentUser.JMMUserID, BaseConfig.Settings.SingleSeriesGroups); if (rawGrps == null) return allGroups; foreach (JMMServerBinary.Contract_AnimeGroup contract in rawGrps) allGroups.Add(new AnimeGroupVM(contract)); // apply sorting List<SortPropOrFieldAndDirection> sortCriteria = GroupFilterHelper.GetSortDescriptions(groupFilter); if (sortCriteria.Count == 0) { // default sort by name SortPropOrFieldAndDirection sortProp = GroupFilterHelper.GetSortDescription(GroupFilterSorting.SortName, GroupFilterSortDirection.Asc); sortCriteria.Add(sortProp); } allGroups = Sorting.MultiSort<AnimeGroupVM>(allGroups, sortCriteria); foreach (SortPropOrFieldAndDirection scrit in sortCriteria) { BaseConfig.MyAnimeLog.Write(string.Format("Sorting: {0} / {1} / {2}", scrit.sPropertyOrFieldName, scrit.fSortDescending, scrit.sortType)); } TimeSpan ts = DateTime.Now - start; string msg = string.Format("JMMServerHelper: Got groups for filter: {0} - {1} in {2} ms", groupFilter.GroupFilterName, allGroups.Count, ts.TotalMilliseconds); BaseConfig.MyAnimeLog.Write(msg); } catch (Exception ex) { BaseConfig.MyAnimeLog.Write(ex.ToString()); } return allGroups; }
public static List<GroupFilterVM> GetAllGroupFilters() { List<GroupFilterVM> gfs = new List<GroupFilterVM>(); try { /*List<JMMServerBinary.Contract_GroupFilterExtended> gf_cons = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupFiltersExtended(1); foreach (JMMServerBinary.Contract_GroupFilterExtended gf_con in gf_cons) { GroupFilterVM gf = new GroupFilterVM(); gf.Populate(gf_con); gfs.Add(gf); }*/ List<JMMServerBinary.Contract_GroupFilter> gf_cons = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupFilters(); foreach (JMMServerBinary.Contract_GroupFilter gf_con in gf_cons) { GroupFilterVM gf = new GroupFilterVM(gf_con); gfs.Add(gf); } } catch (Exception ex) { BaseConfig.MyAnimeLog.Write(ex.ToString()); } gfs.Sort(); return gfs; }
private void CommandBinding_DeleteFilterSort(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) return; try { if (obj.GetType() == typeof(GroupFilterSortingCriteria)) { GroupFilterSortingCriteria gfsc = (GroupFilterSortingCriteria)obj; MessageBoxResult res = MessageBox.Show(string.Format(JMMClient.Properties.Resources.Filter_DeleteSort), JMMClient.Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.Yes) { // find the sorting condition foreach (GroupFilterVM gf in MainListHelperVM.Instance.AllGroupFiltersDictionary.Values) { if (!gf.AllowEditing) continue; // all filter if (gf.GroupFilterID == gfsc.GroupFilterID) { int pos = -1; for (int i = 0; i < gf.SortCriteriaList.Count; i++) { if (gfsc.SortType == gf.SortCriteriaList[i].SortType) { pos = i; break; } } if (pos >= 0) gf.SortCriteriaList.RemoveAt(pos); groupFilterVM = gf; MainListHelperVM.Instance.ViewGroupsForms.Filter = GroupFilter_GroupSearch; MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf); } } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void GroupFilter_OnItemSelected(GUIListItem item) { GroupFilterVM grpFilter = item.TVTag as GroupFilterVM; if (grpFilter == null) return; curGroupFilter = grpFilter; if (displayGrpFilterTimer != null) displayGrpFilterTimer.Stop(); displayGrpFilterTimer = new System.Timers.Timer(); displayGrpFilterTimer.AutoReset = false; displayGrpFilterTimer.Interval = BaseConfig.Settings.InfoDelay; // 250ms displayGrpFilterTimer.Elapsed += new System.Timers.ElapsedEventHandler(displayGrpFilterTimer_Elapsed); displayGrpFilterTimer.Enabled = true; }
public void Init(GroupFilterVM gf, GroupFilterConditionVM gfc) { groupFilter = gf; groupFilterCondition = gfc; try { cboConditionType.Items.Clear(); foreach (string cond in GroupFilterHelper.GetAllConditionTypes()) cboConditionType.Items.Add(cond); PopulateAnimeGroups(); PopulateTags(); PopulateCustomTags(); PopulateVideoQuality(); PopulateAnimeTypes(); PopulateLanguages(); // find the right condition int idx = 0; for (int i = 0; i < cboConditionType.Items.Count; i++) { GroupFilterConditionType conditionTypeTemp = GroupFilterHelper.GetEnumForText_ConditionType(cboConditionType.Items[i].ToString()); if (conditionTypeTemp == gfc.ConditionTypeEnum) { idx = i; break; } } cboConditionType.SelectedIndex = idx; GroupFilterConditionType conditionType = GroupFilterHelper.GetEnumForText_ConditionType(cboConditionType.SelectedItem.ToString()); cboConditionOperator.Items.Clear(); foreach (string op in GroupFilterHelper.GetAllowedOperators(conditionType)) cboConditionOperator.Items.Add(op); cboConditionType.SelectionChanged += new SelectionChangedEventHandler(cboConditionType_SelectionChanged); cboConditionOperator.SelectionChanged += new SelectionChangedEventHandler(cboConditionOperator_SelectionChanged); // find the right operator idx = 0; for (int i = 0; i < cboConditionOperator.Items.Count; i++) { GroupFilterOperator opTypeTemp = GroupFilterHelper.GetEnumForText_Operator(cboConditionOperator.Items[i].ToString()); if (opTypeTemp == gfc.ConditionOperatorEnum) { idx = i; break; } } cboConditionOperator.SelectedIndex = idx; GroupFilterOperator opType = GroupFilterHelper.GetEnumForText_Operator(cboConditionOperator.Items[idx].ToString()); // display the selected filter value switch (conditionType) { case GroupFilterConditionType.AirDate: case GroupFilterConditionType.SeriesCreatedDate: case GroupFilterConditionType.EpisodeAddedDate: case GroupFilterConditionType.EpisodeWatchedDate: case GroupFilterConditionType.LatestEpisodeAirDate: if (opType == GroupFilterOperator.LastXDays) txtParameter.Text = gfc.ConditionParameter; else { DateTime airDate = GroupFilterHelper.GetDateFromString(gfc.ConditionParameter); dpDate.SelectedDate = airDate; } break; case GroupFilterConditionType.AnimeGroup: // don't display anything break; case GroupFilterConditionType.AnimeType: case GroupFilterConditionType.Tag: case GroupFilterConditionType.CustomTags: case GroupFilterConditionType.ReleaseGroup: case GroupFilterConditionType.Studio: case GroupFilterConditionType.VideoQuality: case GroupFilterConditionType.AniDBRating: case GroupFilterConditionType.UserRating: case GroupFilterConditionType.AudioLanguage: case GroupFilterConditionType.SubtitleLanguage: case GroupFilterConditionType.Year: txtParameter.Text = gfc.ConditionParameter; break; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public static List <GroupFilterVM> GetGroupFiltersForPredefined(GroupFilterVM pre) { List <GroupFilterVM> gfs = new List <GroupFilterVM>(); if (pre.GroupFilterID.Value == Constants.StaticGF.Predefined_Years) { List <int> years = new List <int>(); List <JMMServerBinary.Contract_AnimeSeries> contracts = JMMServerVM.Instance.clientBinaryHTTP.GetAllSeries(JMMServerVM.Instance.CurrentUser.JMMUserID); foreach (JMMServerBinary.Contract_AnimeSeries serContract in contracts) { AnimeSeriesVM ser = new AnimeSeriesVM(serContract); int startYear = 0; if (!ser.Stat_AirDate_Min.HasValue) { continue; } startYear = ser.Stat_AirDate_Min.Value.Year; int endYear = DateTime.Now.AddYears(1).Year; if (ser.Stat_AirDate_Max.HasValue) { endYear = ser.Stat_AirDate_Max.Value.Year; } for (int i = startYear; i <= endYear; i++) { if (!years.Contains(i)) { years.Add(i); } } } years.Sort(); foreach (int yr in years) { GroupFilterVM gf = new GroupFilterVM(); gf.GroupFilterID = Constants.StaticGF.Predefined_Years_Child; gf.FilterConditions = new List <GroupFilterConditionVM>(); gf.ApplyToSeries = 0; gf.BaseCondition = 1; gf.GroupFilterName = yr.ToString(); gf.PredefinedCriteria = yr.ToString(); gfs.Add(gf); } } else if (pre.GroupFilterID.Value == Constants.StaticGF.Predefined_Categories) { List <string> categories = new List <string>(); List <AnimeGroupVM> grps = JMMServerHelper.GetAnimeGroupsForFilter(GroupFilterHelper.AllGroupsFilter); foreach (AnimeGroupVM grp in grps) { foreach (string cat in grp.Categories) { if (!categories.Contains(cat) && !string.IsNullOrEmpty(cat)) { categories.Add(cat); } } } categories.Sort(); foreach (string cat in categories) { GroupFilterVM gf = new GroupFilterVM(); gf.GroupFilterID = Constants.StaticGF.Predefined_Categories_Child; gf.FilterConditions = new List <GroupFilterConditionVM>(); gf.ApplyToSeries = 0; gf.BaseCondition = 1; gf.GroupFilterName = cat; gf.PredefinedCriteria = cat; gfs.Add(gf); } } return(gfs); }
private void CommandBinding_Edit(object sender, ExecutedRoutedEventArgs e) { //object obj = lbGroupsSeries.SelectedItem; object obj = e.Parameter; if (obj == null) return; try { if (obj.GetType() == typeof(AnimeGroupVM)) { AnimeGroupVM grp = (AnimeGroupVM)obj; if (grp.AnimeGroupID.HasValue) { groupBeforeChanges = new AnimeGroupVM(); Cloner.Clone(grp, groupBeforeChanges); } grp.IsReadOnly = false; grp.IsBeingEdited = true; } if (obj.GetType() == typeof(GroupFilterVM)) { GroupFilterVM gf = (GroupFilterVM)obj; if (gf.GroupFilterID.HasValue && gf.GroupFilterID.Value!=0) { groupFilterBeforeChanges = new GroupFilterVM(); groupFilterBeforeChanges.FilterName = gf.FilterName; groupFilterBeforeChanges.BaseCondition = gf.BaseCondition; groupFilterBeforeChanges.ApplyToSeries = gf.ApplyToSeries; groupFilterBeforeChanges.FilterConditions = new ObservableCollection<GroupFilterConditionVM>(); groupFilterBeforeChanges.SortCriteriaList = new ObservableCollection<GroupFilterSortingCriteria>(); foreach (GroupFilterConditionVM gfc_cur in gf.FilterConditions) { GroupFilterConditionVM gfc = new GroupFilterConditionVM(); gfc.ConditionOperator = gfc_cur.ConditionOperator; gfc.ConditionParameter = gfc_cur.ConditionParameter; gfc.ConditionType = gfc_cur.ConditionType; gfc.GroupFilterConditionID = gfc_cur.GroupFilterConditionID; gfc.GroupFilterID = gfc_cur.GroupFilterID; groupFilterBeforeChanges.FilterConditions.Add(gfc); } foreach (GroupFilterSortingCriteria gfcs_cur in gf.SortCriteriaList) { GroupFilterSortingCriteria gfsc = new GroupFilterSortingCriteria(); gfsc.GroupFilterID = gfcs_cur.GroupFilterID; gfsc.SortDirection = gfcs_cur.SortDirection; gfsc.SortType = gfcs_cur.SortType; groupFilterBeforeChanges.SortCriteriaList.Add(gfsc); } //Cloner.Clone(gf, groupFilterBeforeChanges); } gf.IsLocked = false; gf.IsBeingEdited = true; groupFilterVM = gf; MainListHelperVM.Instance.ViewGroupsForms.Filter = GroupFilter_GroupSearch; MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf); } if (obj.GetType() == typeof(AnimeSeriesVM)) { } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } EnableDisableGroupControls(false); }
private List <AnimeSeriesVM> GetSeriesForGroupFilter() { List <AnimeSeriesVM> serList = new List <AnimeSeriesVM>(); try { if (LevelType != RandomSeriesEpisodeLevel.GroupFilter) { return(serList); } GroupFilterVM gf = LevelObject as GroupFilterVM; if (gf == null) { return(serList); } List <AnimeGroupVM> grps = new List <AnimeGroupVM>(MainListHelperVM.Instance.AllGroups); foreach (AnimeGroupVM grp in grps) { // ignore sub groups if (grp.AnimeGroupParentID.HasValue) { continue; } if (gf.EvaluateGroupFilter(grp)) { foreach (AnimeSeriesVM ser in grp.AllAnimeSeries) { if (gf.EvaluateGroupFilter(ser)) { // tags if (!string.IsNullOrEmpty(SelectedTags)) { string filterParm = SelectedTags.Trim(); string[] cats = filterParm.Split(','); bool foundCat = false; if (cboCatFilter.SelectedIndex == 1) { foundCat = true; // all } int index = 0; foreach (string cat in cats) { if (cat.Trim().Length == 0) { continue; } if (cat.Trim() == ",") { continue; } index = ser.TagsString.IndexOf(cat, 0, StringComparison.InvariantCultureIgnoreCase); if (cboCatFilter.SelectedIndex == 0) // any { if (index > -1) { foundCat = true; break; } } else //all { if (index < 0) { foundCat = false; break; } } } if (!foundCat) { continue; } } if (!ser.IsComplete && chkComplete.IsChecked.Value) { continue; } if (chkWatched.IsChecked.Value && ser.AllFilesWatched) { serList.Add(ser); continue; } if (chkUnwatched.IsChecked.Value && !ser.AnyFilesWatched) { serList.Add(ser); continue; } if (chkPartiallyWatched.IsChecked.Value && ser.AnyFilesWatched && !ser.AllFilesWatched) { serList.Add(ser); continue; } } } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(serList); }
private void CommandBinding_NewGroupFilter(object sender, ExecutedRoutedEventArgs e) { try { GroupFilterVM gfNew = new GroupFilterVM(); gfNew.AllowEditing = true; gfNew.IsBeingEdited = true; gfNew.IsLocked = false; gfNew.IsSystemGroupFilter = false; gfNew.FilterName = JMMClient.Properties.Resources.Filter_New; gfNew.ApplyToSeries = 0; gfNew.BaseCondition = (int)GroupFilterBaseCondition.Include; gfNew.FilterConditions = new ObservableCollection<GroupFilterConditionVM>(); MainListHelperVM.Instance.AllGroupFiltersDictionary[0]=gfNew; groupFilterVM = gfNew; MainListHelperVM.Instance.ViewGroupsForms.Filter = GroupFilter_GroupSearch; MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gfNew); SetDetailBinding(gfNew); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public static bool EvaluateGroupFilter(GroupFilterVM gf, AnimeSeriesVM ser) { return gf.EvaluateGroupFilter(ser); }
void lbGroupsSeries_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { //epListMain.DataContext = null; System.Windows.Controls.ListBox lb = (System.Windows.Controls.ListBox)sender; object obj = lb.SelectedItem; if (obj == null) return; if (obj.GetType() == typeof(AnimeSeriesVM)) { AnimeSeriesVM series = obj as AnimeSeriesVM; series.RefreshBase(); //MainListHelperVM.Instance.LastAnimeSeriesID = series.AnimeSeriesID.Value; MainListHelperVM.Instance.CurrentSeries = series; } if (obj.GetType() == typeof(AnimeGroupVM)) { AnimeGroupVM grp = obj as AnimeGroupVM; //MainListHelperVM.Instance.LastAnimeGroupID = grp.AnimeGroupID.Value; } if (obj.GetType() == typeof(GroupFilterVM)) { GroupFilterVM gf = obj as GroupFilterVM; //MainListHelperVM.Instance.LastGroupFilterID = gf.GroupFilterID.Value; groupFilterVM = gf; MainListHelperVM.Instance.ViewGroupsForms.Filter = GroupFilter_GroupSearch; MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf); } if (!string.IsNullOrEmpty(MainListHelperVM.Instance.CurrentOpenGroupFilter) && lbGroupsSeries.SelectedItem != null) MainListHelperVM.Instance.LastGroupForGF[MainListHelperVM.Instance.CurrentOpenGroupFilter] = lbGroupsSeries.SelectedIndex; //SetDetailBinding(MainListHelperVM.Instance.AllGroups[0]); SetDetailBinding(obj); if (obj.GetType() == typeof(AnimeSeriesVM)) { AnimeSeriesVM series = obj as AnimeSeriesVM; //epListMain.DataContext = series; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public static bool EvaluateGroupFilter(GroupFilterVM gf, AnimeGroupVM grp) { return gf.EvaluateGroupFilter(grp); }
public void Init(GroupFilterVM gf, GroupFilterConditionVM gfc) { groupFilter = gf; groupFilterCondition = gfc; try { cboConditionType.Items.Clear(); foreach (string cond in GroupFilterHelper.GetAllConditionTypes()) { cboConditionType.Items.Add(cond); } PopulateAnimeGroups(); PopulateTags(); PopulateCustomTags(); PopulateVideoQuality(); PopulateAnimeTypes(); PopulateLanguages(); // find the right condition int idx = 0; for (int i = 0; i < cboConditionType.Items.Count; i++) { GroupFilterConditionType conditionTypeTemp = GroupFilterHelper.GetEnumForText_ConditionType(cboConditionType.Items[i].ToString()); if (conditionTypeTemp == gfc.ConditionTypeEnum) { idx = i; break; } } cboConditionType.SelectedIndex = idx; GroupFilterConditionType conditionType = GroupFilterHelper.GetEnumForText_ConditionType(cboConditionType.SelectedItem.ToString()); cboConditionOperator.Items.Clear(); foreach (string op in GroupFilterHelper.GetAllowedOperators(conditionType)) { cboConditionOperator.Items.Add(op); } cboConditionType.SelectionChanged += new SelectionChangedEventHandler(cboConditionType_SelectionChanged); cboConditionOperator.SelectionChanged += new SelectionChangedEventHandler(cboConditionOperator_SelectionChanged); // find the right operator idx = 0; for (int i = 0; i < cboConditionOperator.Items.Count; i++) { GroupFilterOperator opTypeTemp = GroupFilterHelper.GetEnumForText_Operator(cboConditionOperator.Items[i].ToString()); if (opTypeTemp == gfc.ConditionOperatorEnum) { idx = i; break; } } cboConditionOperator.SelectedIndex = idx; GroupFilterOperator opType = GroupFilterHelper.GetEnumForText_Operator(cboConditionOperator.Items[idx].ToString()); // display the selected filter value switch (conditionType) { case GroupFilterConditionType.AirDate: case GroupFilterConditionType.SeriesCreatedDate: case GroupFilterConditionType.EpisodeAddedDate: case GroupFilterConditionType.EpisodeWatchedDate: case GroupFilterConditionType.LatestEpisodeAirDate: if (opType == GroupFilterOperator.LastXDays) { txtParameter.Text = gfc.ConditionParameter; } else { DateTime airDate = GroupFilterHelper.GetDateFromString(gfc.ConditionParameter); dpDate.SelectedDate = airDate; } break; case GroupFilterConditionType.AnimeGroup: // don't display anything break; case GroupFilterConditionType.AnimeType: case GroupFilterConditionType.Tag: case GroupFilterConditionType.CustomTags: case GroupFilterConditionType.ReleaseGroup: case GroupFilterConditionType.Studio: case GroupFilterConditionType.VideoQuality: case GroupFilterConditionType.AniDBRating: case GroupFilterConditionType.UserRating: case GroupFilterConditionType.AudioLanguage: case GroupFilterConditionType.SubtitleLanguage: case GroupFilterConditionType.Year: txtParameter.Text = gfc.ConditionParameter; break; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private Tuple<Fanart, string> FindFanartForGroupFilter(GroupFilterVM gf) { if (gf.Childs.Count > 0) { foreach (int v in gf.Childs.Randomize(gf.Childs.Count)) { Contract_GroupFilter cq = JMMServerVM.Instance.clientBinaryHTTP.GetGroupFilter(v); if (cq != null) { GroupFilterVM gfm = new GroupFilterVM(cq); Tuple<Fanart, string> n = FindFanartForGroupFilter(gfm); if (n != null) return n; } } } else if (gf.Groups.ContainsKey(JMMServerVM.Instance.CurrentUser.JMMUserID) && gf.Groups[JMMServerVM.Instance.CurrentUser.JMMUserID].Count > 0) { foreach (int v in gf.Groups[JMMServerVM.Instance.CurrentUser.JMMUserID].Randomize(gf.Groups.Count)) { Contract_AnimeGroup g = JMMServerVM.Instance.clientBinaryHTTP.GetGroup(v, JMMServerVM.Instance.CurrentUser.JMMUserID); if (g != null) { AnimeGroupVM gvm = new AnimeGroupVM(g); Fanart fanart = new Fanart(gvm); if (!string.IsNullOrEmpty(fanart.FileName)) { string f = ImageAllocator.GetGroupImageAsFileName(gvm, GUIFacadeControl.Layout.List); if (f != null) return new Tuple<Fanart, string>(fanart, f); } } } } return null; }