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 bool EvaluateGroupFilter(GroupFilterVM gf, AnimeSeriesVM ser) { return gf.EvaluateGroupFilter(ser); }
public static bool EvaluateGroupFilter(GroupFilterVM gf, AnimeGroupVM grp) { return gf.EvaluateGroupFilter(grp); }
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); }