public void ShowAllGroups() { try { CurrentWrapper = null; CurrentWrapperIsGroup = true; BreadCrumbs.Clear(); BreadCrumbs.Add(null); CurrentWrapperList.Clear(); foreach (GroupFilterVM grpFilter in AllGroupFiltersDictionary.Values) { //if (grpFilter.FilterConditions.Count == 0) // AllGroupFilter = grpFilter; if (!grpFilter.GroupFilterParentId.HasValue) { CurrentWrapperList.Add(grpFilter); } } ShowChildWrappers(AllGroupFilter); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void ShowAllGroups() { try { CurrentWrapper = null; CurrentWrapperIsGroup = true; BreadCrumbs.Clear(); BreadCrumbs.Add(null); CurrentWrapperList.Clear(); AllGroupFilters.Clear(); foreach (GroupFilterVM grpFilter in GroupFilterHelper.AllGroupFilters) { //if (grpFilter.FilterConditions.Count == 0) // AllGroupFilter = grpFilter; AllGroupFilters.Add(grpFilter); CurrentWrapperList.Add(grpFilter); } ShowChildWrappers(AllGroupFilter); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
//[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); } }
//[LogExecutionTime] public void ShowChildWrappers(IListWrapper wrapper) { try { CurrentWrapper = wrapper; CurrentWrapperIsGroup = wrapper is VM_GroupFilter; CurrentListWrapperIsGroup = wrapper is VM_AnimeGroup_User; if (wrapper is VM_AnimeGroup_User) { //LastAnimeGroupID = ((VM_AnimeGroup_User)wrapper).AnimeGroupID.Value; Instance.CurrentOpenGroupFilter = "VM_AnimeGroup_User|" + ((VM_AnimeGroup_User)wrapper).AnimeGroupID; } if (wrapper is VM_GroupFilter) { CurrentGroupFilter = (VM_GroupFilter)wrapper; //LastGroupFilterID = ((GroupFilterVM)wrapper).GroupFilterID.Value; Instance.CurrentOpenGroupFilter = "GroupFilterVM|" + ((VM_GroupFilter)wrapper).GroupFilterID; } if (wrapper is VM_AnimeSeries_User) { CurrentSeries = (VM_AnimeSeries_User)wrapper; //LastAnimeSeriesID = ((VM_AnimeSeries_User)wrapper).AnimeSeriesID.Value; Instance.CurrentOpenGroupFilter = "NoGroup"; } if (wrapper == null) { Instance.CurrentOpenGroupFilter = "Init"; } Application.Current.Dispatcher.Invoke(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 (BreadCrumbs[i] == null) { continue; } if (wrapper is VM_GroupFilter && BreadCrumbs[i] is VM_GroupFilter) { VM_GroupFilter wrapObj = (VM_GroupFilter)wrapper; VM_GroupFilter bcObj = (VM_GroupFilter)BreadCrumbs[i]; if (wrapObj.GroupFilterName == bcObj.GroupFilterName) { pos = i; } } else if (wrapper is VM_AnimeGroup_User && BreadCrumbs[i] is VM_AnimeGroup_User) { VM_AnimeGroup_User wrapObj = (VM_AnimeGroup_User)wrapper; VM_AnimeGroup_User bcObj = (VM_AnimeGroup_User)BreadCrumbs[i]; if (wrapObj.AnimeGroupID == bcObj.AnimeGroupID) { pos = i; } } else if (wrapper is VM_AnimeSeries_User && BreadCrumbs[i] is VM_AnimeSeries_User) { VM_AnimeSeries_User wrapObj = (VM_AnimeSeries_User)wrapper; VM_AnimeSeries_User bcObj = (VM_AnimeSeries_User)BreadCrumbs[i]; if (wrapObj.AnimeSeriesID == bcObj.AnimeSeriesID) { pos = i; } } else if (wrapper is VM_AnimeEpisodeType && BreadCrumbs[i] is VM_AnimeEpisodeType) { VM_AnimeEpisodeType wrapObj = (VM_AnimeEpisodeType)wrapper; VM_AnimeEpisodeType bcObj = (VM_AnimeEpisodeType)BreadCrumbs[i]; if (wrapObj.EpisodeTypeDescription == bcObj.EpisodeTypeDescription) { pos = i; } } else if (wrapper is VM_AnimeEpisode_User && BreadCrumbs[i] is VM_AnimeEpisode_User) { VM_AnimeEpisode_User wrapObj = (VM_AnimeEpisode_User)wrapper; VM_AnimeEpisode_User bcObj = (VM_AnimeEpisode_User)BreadCrumbs[i]; 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); } } } else if (pos == 0) { BreadCrumbs.Clear(); } BreadCrumbs.Add(wrapper); if (wrapper is VM_GroupFilter) { 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 (VM_GroupFilter grpFilter in AllGroupFiltersDictionary.Values .Where(a => a != null && !a.ParentGroupFilterID.HasValue).OrderBy(a => a.GroupFilterName)) { CurrentWrapperList.Add(grpFilter); } } else { CurrentWrapperList.Clear(); foreach (IListWrapper wp in wrapper.GetDirectChildren()) { CurrentWrapperList.Add(wp); } } SetGroupFilterSortingOnMainList(); ViewGroups.Refresh(); //new FilterMainListBox(ViewGroups, SearchTextBox, CurrentGroupFilter); }); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }