private void UpdateGroupAndSeriesForEpisode(AnimeEpisodeVM ep) { try { // update the attached series JMMServerBinary.Contract_AnimeSeries serContract = JMMServerVM.Instance.clientBinaryHTTP.GetSeries(ep.AnimeSeriesID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); AnimeSeriesVM ser = AllSeriesDictionary.SureGet(serContract.AnimeSeriesID); if (ser != null) { ser.Populate(serContract); // TODO update the episode list } List <JMMServerBinary.Contract_AnimeGroup> grps = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupsAboveSeries(ep.AnimeSeriesID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (JMMServerBinary.Contract_AnimeGroup grpContract in grps) { AnimeGroupVM agrp = AllGroupsDictionary.SureGet(grpContract.AnimeGroupID); agrp?.Populate(grpContract); agrp?.PopulateSerieInfo(AllGroupsDictionary, AllSeriesDictionary); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void RefreshSeriesMissingEps() { try { System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { SeriesMissingEps.Clear(); }); List <JMMServerBinary.Contract_AnimeSeries> epSeries = JMMServerVM.Instance.clientBinaryHTTP.GetSeriesWithMissingEpisodes(UserSettingsVM.Instance.Dash_MissingEps_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { foreach (JMMServerBinary.Contract_AnimeSeries contract in epSeries) { AnimeSeriesVM ser = new AnimeSeriesVM(contract); if (JMMServerVM.Instance.CurrentUser.EvaluateSeries(ser)) { SeriesMissingEps.Add(ser); } } ViewSeriesMissingEps.Refresh(); }); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { } }
public AnimeSeriesVM GetSeriesForVideo(int videoLocalID) { try { // get the episodes that this file applies to List <JMMServerBinary.Contract_AnimeEpisode> eps = JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesForFile(videoLocalID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (JMMServerBinary.Contract_AnimeEpisode epcontract in eps) { AnimeSeriesVM thisSeries = null; foreach (AnimeSeriesVM ser in MainListHelperVM.Instance.AllSeries) { if (ser.AnimeSeriesID == epcontract.AnimeSeriesID) { thisSeries = ser; break; } } return(thisSeries); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(null); }
private bool SeriesSearchFilter(object obj) { AnimeSeriesVM ser = obj as AnimeSeriesVM; if (ser == null) { return(false); } if (SearchResultCount > 100) { return(false); } bool passed = false; passed = GroupSearchFilterHelper.EvaluateSeriesTextSearch(ser, SeriesSearchTextBox.Text.Replace("'", "`"), SerSearchType); if (passed) { SearchResultCount++; } return(passed); }
private bool SeriesSearchFilter(object obj) { AnimeSeriesVM ser = obj as AnimeSeriesVM; if (ser == null) { return(false); } if (SearchResultCount > 100) { return(false); } bool passed = false; System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { passed = GroupSearchFilterHelper.EvaluateSeriesTextSearch(ser, SeriesSearchTextBox.Text, SerSearchType); }); if (passed) { SearchResultCount++; } return(passed); }
public void UpdateHeirarchy(AnimeSeriesVM ser) { try { // update the attached series // refresh the data ser.RefreshBase(); ser.AniDB_Anime.Detail.RefreshBase(); List <JMMServerBinary.Contract_AnimeGroup> grps = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupsAboveSeries(ser.AnimeSeriesID.Value, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (AnimeGroupVM grp in MainListHelperVM.Instance.AllGroups) { foreach (JMMServerBinary.Contract_AnimeGroup grpContract in grps) { if (grp.AnimeGroupID.Value == grpContract.AnimeGroupID) { grp.Populate(grpContract); break; } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void UpdateAnime(int animeID) { try { JMMServerBinary.Contract_AniDBAnime animeRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAnime(animeID); if (animeRaw != null) { AniDB_AnimeVM anime = new AniDB_AnimeVM(animeRaw); AllAnimeDictionary[anime.AnimeID] = anime; // update the series AnimeSeriesVM ser = AllSeriesDictionary.Values.FirstOrDefault(a => a.AniDB_ID == anime.AnimeID); if (ser != null) { ser.RefreshBase(); ser.AniDB_Anime.Detail.RefreshBase(); AllSeriesDictionary[ser.AnimeSeriesID.Value] = ser; } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void RefreshRecentAdditions(RecentAdditionsType addType) { try { System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { RecentAdditions.Clear(); }); if (addType == RecentAdditionsType.Episode) { List <JMMServerBinary.Contract_AnimeEpisode> epContracts = JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesRecentlyAdded(UserSettingsVM.Instance.Dash_RecentAdditions_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts) { AnimeEpisodeVM ep = new AnimeEpisodeVM(contract); ep.RefreshAnime(); if (ep.AniDB_Anime == null) { ep.RefreshAnime(true); // this might be a new series } if (ep.AniDB_Anime != null) { ep.SetTvDBInfo(); RecentAdditions.Add(ep); } } ViewRecentAdditions.Refresh(); }); } else { List <JMMServerBinary.Contract_AnimeSeries> serContracts = JMMServerVM.Instance.clientBinaryHTTP.GetSeriesRecentlyAdded(UserSettingsVM.Instance.Dash_RecentAdditions_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { foreach (JMMServerBinary.Contract_AnimeSeries contract in serContracts) { AnimeSeriesVM ser = new AnimeSeriesVM(contract); RecentAdditions.Add(ser); } ViewRecentAdditions.Refresh(); }); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { } }
public bool EvaluateGroupFilter(AnimeSeriesVM ser) { if (Series == null || !Series.ContainsKey(JMMServerVM.Instance.CurrentUser.JMMUserID.Value)) { return(false); } if (ser.AnimeSeriesID.HasValue) { return(Series[JMMServerVM.Instance.CurrentUser.JMMUserID.Value].Contains(ser.AnimeSeriesID.Value)); } return(false); }
public void UpdateHeirarchy(VideoDetailedVM vid) { try { // get the episodes that this file applies to List <JMMServerBinary.Contract_AnimeEpisode> eps = JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesForFile(vid.VideoLocalID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (JMMServerBinary.Contract_AnimeEpisode epcontract in eps) { AnimeSeriesVM thisSeries = null; foreach (AnimeSeriesVM ser in MainListHelperVM.Instance.AllSeries) { if (ser.AnimeSeriesID == epcontract.AnimeSeriesID) { thisSeries = ser; break; } } // update the episodes if (thisSeries != null && thisSeries.AnimeSeriesID.HasValue && thisSeries.AnimeSeriesID.Value == epcontract.AnimeSeriesID) { foreach (AnimeEpisodeVM ep in thisSeries.AllEpisodes) { if (ep.AnimeEpisodeID == epcontract.AnimeEpisodeID) { ep.Populate(epcontract); // update the attached videos List <JMMServerBinary.Contract_VideoDetailed> contracts = JMMServerVM.Instance.clientBinaryHTTP.GetFilesForEpisode(ep.AnimeEpisodeID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (JMMServerBinary.Contract_VideoDetailed vidcontract in contracts) { if (vid.VideoLocalID == vidcontract.VideoLocalID) { vid.Populate(vidcontract); break; } } // update all the attached groups UpdateGroupAndSeriesForEpisode(ep); } } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void RefreshAnime(bool forced) { if (MainListHelperVM.Instance.AllSeriesDictionary.ContainsKey(this.AnimeSeriesID)) { AnimeSeriesVM ser = MainListHelperVM.Instance.AllSeriesDictionary[this.AnimeSeriesID]; aniDB_Anime = ser.AniDB_Anime; } if (forced && aniDB_Anime != null) { MainListHelperVM.Instance.UpdateAnime(aniDB_Anime.AnimeID); } }
public void RefreshGroupsSeriesData() { //LoadTestData(); //return; try { // set this to null so that it will be refreshed the next time it is needed AllAnimeDetailedDictionary = null; List <JMMServerBinary.Contract_AnimeGroup> grpsRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroups(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); List <JMMServerBinary.Contract_AnimeSeries> seriesRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllSeries(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); if (grpsRaw.Count == 0 || seriesRaw.Count == 0) { return; } System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { AllGroups.Clear(); AllSeries.Clear(); AllGroupsDictionary.Clear(); AllSeriesDictionary.Clear(); AllAnimeDictionary.Clear(); // must series before groups the binding is based on the groups, and will refresh when that is changed foreach (JMMServerBinary.Contract_AnimeSeries ser in seriesRaw) { AnimeSeriesVM serNew = new AnimeSeriesVM(ser); AllSeries.Add(serNew); AllSeriesDictionary[serNew.AnimeSeriesID.Value] = serNew; } ViewSeriesSearch.Refresh(); foreach (JMMServerBinary.Contract_AnimeGroup grp in grpsRaw) { AnimeGroupVM grpNew = new AnimeGroupVM(grp); AllGroups.Add(grpNew); AllGroupsDictionary[grpNew.AnimeGroupID.Value] = grpNew; } }); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void InitGroupsSeriesData() { //LoadTestData(); //return; try { // set this to null so that it will be refreshed the next time it is needed AllAnimeDetailedDictionary = null; List <JMMServerBinary.Contract_AnimeGroup> grpsRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroups(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); List <JMMServerBinary.Contract_AnimeSeries> seriesRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllSeries(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); if (grpsRaw.Count == 0 || seriesRaw.Count == 0) { return; } AllGroups.Clear(); AllSeries.Clear(); AllGroupsDictionary.Clear(); AllSeriesDictionary.Clear(); AllAnimeDictionary.Clear(); // must series before groups the binding is based on the groups, and will refresh when that is changed foreach (JMMServerBinary.Contract_AnimeSeries ser in seriesRaw) { AnimeSeriesVM serNew = new AnimeSeriesVM(ser); AllSeries.Add(serNew); AllSeriesDictionary[serNew.AnimeSeriesID.Value] = serNew; } foreach (JMMServerBinary.Contract_AnimeGroup grp in grpsRaw) { AnimeGroupVM grpNew = new AnimeGroupVM(grp); AllGroups.Add(grpNew); AllGroupsDictionary[grpNew.AnimeGroupID.Value] = grpNew; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public static bool EvaluateSeriesTextSearch(AnimeSeriesVM series, string filterText, SeriesSearchType searchType) { if (String.IsNullOrEmpty(filterText) || series == null) { return(true); } if (!string.IsNullOrEmpty(series.SeriesNameOverride)) { int index = series.SeriesNameOverride.IndexOf(filterText, 0, StringComparison.InvariantCultureIgnoreCase); if (index > -1) { return(true); } } return(EvaluateAnimeTextSearch(series.AniDB_Anime, filterText, searchType)); }
public AnimeSeriesVM GetSeriesForAnime(int animeID) { try { AnimeSeriesVM thisSeries = null; foreach (AnimeSeriesVM ser in MainListHelperVM.Instance.AllSeries) { if (ser.AniDB_ID == animeID) { thisSeries = ser; break; } } return(thisSeries); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(null); }
public void UpdateHeirarchy(AnimeSeriesVM ser) { try { // update the attached series // refresh the data ser.RefreshBase(); ser.AniDB_Anime.Detail.RefreshBase(); List <JMMServerBinary.Contract_AnimeGroup> grps = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupsAboveSeries(ser.AnimeSeriesID.Value, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (JMMServerBinary.Contract_AnimeGroup grpContract in grps) { AnimeGroupVM agrp = AllGroupsDictionary.SureGet(grpContract.AnimeGroupID); agrp?.Populate(grpContract); agrp?.PopulateSerieInfo(AllGroupsDictionary, AllSeriesDictionary); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public static void PromptToRateSeries(AnimeSeriesVM ser, Window parentWindow) { try { if (!AppSettings.DisplayRatingDialogOnCompletion) { return; } // if the user doesn't have all the episodes return if (ser.MissingEpisodeCount > 0) { return; } // only prompt the user if the series has finished airing // and the user has watched all the episodes if (!ser.AniDB_Anime.FinishedAiring || !ser.AllFilesWatched) { return; } if (ser.AniDB_Anime.Detail.UserHasVoted) { return; } RateSeriesForm frm = new RateSeriesForm(); frm.Owner = parentWindow; frm.Init(ser); bool?result = frm.ShowDialog(); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public static bool EvaluateGroupFilter(GroupFilterVM gf, AnimeSeriesVM ser) { return(gf.EvaluateGroupFilter(ser)); }
//[LogExecutionTime] public void ShowChildWrappers(MainListWrapper wrapper) { try { CurrentWrapper = wrapper; CurrentWrapperIsGroup = wrapper is GroupFilterVM; CurrentListWrapperIsGroup = wrapper is AnimeGroupVM; if (wrapper is AnimeGroupVM) { //LastAnimeGroupID = ((AnimeGroupVM)wrapper).AnimeGroupID.Value; MainListHelperVM.Instance.CurrentOpenGroupFilter = "AnimeGroupVM|" + ((AnimeGroupVM)wrapper).AnimeGroupID.Value; } if (wrapper is GroupFilterVM) { CurrentGroupFilter = (GroupFilterVM)wrapper; //LastGroupFilterID = ((GroupFilterVM)wrapper).GroupFilterID.Value; MainListHelperVM.Instance.CurrentOpenGroupFilter = "GroupFilterVM|" + ((GroupFilterVM)wrapper).GroupFilterID.Value; } if (wrapper is AnimeSeriesVM) { CurrentSeries = wrapper as AnimeSeriesVM; //LastAnimeSeriesID = ((AnimeSeriesVM)wrapper).AnimeSeriesID.Value; MainListHelperVM.Instance.CurrentOpenGroupFilter = "NoGroup"; } if (wrapper == null) { MainListHelperVM.Instance.CurrentOpenGroupFilter = "Init"; } System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { // update wrappers // check where this wrapper sits in the heirarchy and remove anything below it int pos = -1; if (wrapper != null) { for (int i = 0; i < BreadCrumbs.Count; i++) { if (wrapper is GroupFilterVM && BreadCrumbs[i] is GroupFilterVM) { GroupFilterVM wrapObj = wrapper as GroupFilterVM; GroupFilterVM bcObj = BreadCrumbs[i] as GroupFilterVM; if (wrapObj.FilterName == bcObj.FilterName) { pos = i; } } if (wrapper is AnimeGroupVM && BreadCrumbs[i] is AnimeGroupVM) { AnimeGroupVM wrapObj = wrapper as AnimeGroupVM; AnimeGroupVM bcObj = BreadCrumbs[i] as AnimeGroupVM; if (wrapObj.AnimeGroupID == bcObj.AnimeGroupID) { pos = i; } } if (wrapper is AnimeSeriesVM && BreadCrumbs[i] is AnimeSeriesVM) { AnimeSeriesVM wrapObj = wrapper as AnimeSeriesVM; AnimeSeriesVM bcObj = BreadCrumbs[i] as AnimeSeriesVM; if (wrapObj.AnimeSeriesID == bcObj.AnimeSeriesID) { pos = i; } } if (wrapper is AnimeEpisodeTypeVM && BreadCrumbs[i] is AnimeEpisodeTypeVM) { AnimeEpisodeTypeVM wrapObj = wrapper as AnimeEpisodeTypeVM; AnimeEpisodeTypeVM bcObj = BreadCrumbs[i] as AnimeEpisodeTypeVM; if (wrapObj.EpisodeTypeDescription == bcObj.EpisodeTypeDescription) { pos = i; } } if (wrapper is AnimeEpisodeVM && BreadCrumbs[i] is AnimeEpisodeVM) { AnimeEpisodeVM wrapObj = wrapper as AnimeEpisodeVM; AnimeEpisodeVM bcObj = BreadCrumbs[i] as AnimeEpisodeVM; if (wrapObj.AnimeEpisodeID == bcObj.AnimeEpisodeID) { pos = i; } } } } else { pos = 0; } if (pos >= 0) { for (int i = BreadCrumbs.Count - 1; i >= 0; i--) { if (i >= pos) { BreadCrumbs.RemoveAt(i); } } } BreadCrumbs.Add(wrapper); if (wrapper is GroupFilterVM) { if (AllGroupsDictionary.Count == 0) { RefreshGroupsSeriesData(); } // apply sorting // get default sorting from the group filter } // means we are at the top level if (wrapper == null) { CurrentWrapperList.Clear(); foreach (GroupFilterVM grpFilter in AllGroupFiltersDictionary.Values.Where(a => !a.GroupFilterParentId.HasValue).OrderBy(a => a.FilterName)) { CurrentWrapperList.Add(grpFilter); } } else { CurrentWrapperList.Clear(); foreach (MainListWrapper wp in wrapper.GetDirectChildren()) { CurrentWrapperList.Add(wp); } } SetGroupFilterSortingOnMainList(); ViewGroups.Refresh(); //new FilterMainListBox(ViewGroups, SearchTextBox, CurrentGroupFilter); }); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void UpdateAll() { try { Contract_MainChanges changes = JMMServerVM.Instance.clientBinaryHTTP.GetAllChanges(LastChange, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); AllAnimeDetailedDictionary = null; //Update Anime Series foreach (int sr in changes.Series.RemovedItems) { if (AllSeriesDictionary.ContainsKey(sr)) { AnimeSeriesVM vm = AllSeriesDictionary[sr]; AllSeriesDictionary.Remove(sr); } } foreach (Contract_AnimeSeries s in changes.Series.ChangedItems) { if (AllSeriesDictionary.ContainsKey(s.AnimeSeriesID)) { AnimeSeriesVM v = AllSeriesDictionary[s.AnimeSeriesID]; v.Populate(s); } else { AnimeSeriesVM v = new AnimeSeriesVM(s); AllSeriesDictionary[s.AnimeSeriesID] = v; } } //Update Anime Groups foreach (int gr in changes.Groups.RemovedItems) { if (AllGroupsDictionary.ContainsKey(gr)) { AnimeGroupVM vm = AllGroupsDictionary[gr]; AllGroupsDictionary.Remove(gr); } } foreach (Contract_AnimeGroup g in changes.Groups.ChangedItems) { AnimeGroupVM v; if (AllGroupsDictionary.ContainsKey(g.AnimeGroupID)) { v = AllGroupsDictionary[g.AnimeGroupID]; v.Populate(g); } else { v = new AnimeGroupVM(g); AllGroupsDictionary[g.AnimeGroupID] = v; } } foreach (AnimeGroupVM v in AllGroupsDictionary.Values) { v.PopulateSerieInfo(AllGroupsDictionary, AllSeriesDictionary); } //Update Group Filters foreach (int gfr in changes.Filters.RemovedItems) { if (AllGroupFiltersDictionary.ContainsKey(gfr)) { GroupFilterVM vm = AllGroupFiltersDictionary[gfr]; AllGroupFiltersDictionary.Remove(gfr); } } foreach (Contract_GroupFilter gf in changes.Filters.ChangedItems) { if (AllGroupFiltersDictionary.ContainsKey(gf.GroupFilterID.Value)) { GroupFilterVM v = AllGroupFiltersDictionary[gf.GroupFilterID.Value]; v.Populate(gf); } else { GroupFilterVM v = new GroupFilterVM(gf); AllGroupFiltersDictionary[gf.GroupFilterID.Value] = v; } } foreach (int gf in changes.Filters.ChangedItems.Select(a => a.GroupFilterID.Value)) { GroupFilterVM v = AllGroupFiltersDictionary[gf]; //Recalculate Groups Count v.GetDirectChildren(); } LastChange = changes.LastChange; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public static bool EvaluateSeriesTextSearch(AnimeSeriesVM series, string filterText) { return(EvaluateSeriesTextSearch(series, filterText, SeriesSearchType.Everything)); }