Example #1
0
 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 static bool EvaluateGroupTextSearch(AnimeGroupVM grp, string filterText)
        {
            if (String.IsNullOrEmpty(filterText) || grp == null)
            {
                return(true);
            }

            // do this so that when viewing sub groups they don't get filtered
            if (grp.AnimeGroupParentID.HasValue)
            {
                return(true);
            }

            // get all possible names for the group

            // search the group name
            int index = grp.GroupName.IndexOf(filterText, 0, StringComparison.InvariantCultureIgnoreCase);

            if (index > -1)
            {
                return(true);
            }

            // search the sort name
            index = grp.SortName.IndexOf(filterText, 0, StringComparison.InvariantCultureIgnoreCase);
            if (index > -1)
            {
                return(true);
            }

            // check the tags
            if (grp.Stat_AllTags != null && grp.Stat_AllTags.Count > 0)
            {
                if (grp.Stat_AllTags.Contains(filterText, StringComparer.InvariantCultureIgnoreCase))
                {
                    return(true);
                }
            }

            // check the custom tags
            if (grp.Stat_AllCustomTags != null && grp.Stat_AllCustomTags.Count > 0)
            {
                if (grp.Stat_AllCustomTags.Contains(filterText, StringComparer.InvariantCultureIgnoreCase))
                {
                    return(true);
                }
            }

            // search the titles (romaji name, english names) etc from anidb
            if (grp.Stat_AllTitles != null && grp.Stat_AllTitles.Count > 0)
            {
                if (grp.Stat_AllTitles.SubContains(filterText))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
        public void PopulateIsFave()
        {
            IsFave    = false;
            IsNotFave = true;

            AnimeGroupVM grp = TopLevelAnimeGroup;

            if (grp != null)
            {
                IsFave    = grp.BIsFave;
                IsNotFave = grp.BIsNotFave;
            }
        }
Example #4
0
        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);
            }
        }
Example #5
0
 public bool EvaluateGroupFilter(AnimeGroupVM grp)
 {
     if (this.IsBeingEdited && CollectionChanged)
     {
         Populate(JMMServerVM.Instance.clientBinaryHTTP.EvaluateGroupFilter(this.ToContract()));
         CollectionChanged = false;
     }
     if (Groups == null || !Groups.ContainsKey(JMMServerVM.Instance.CurrentUser.JMMUserID.Value))
     {
         return(false);
     }
     if (grp.AnimeGroupID.HasValue)
     {
         return(Groups[JMMServerVM.Instance.CurrentUser.JMMUserID.Value].Contains(grp.AnimeGroupID.Value));
     }
     return(false);
 }
Example #6
0
        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);
            }
        }
Example #7
0
        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);
            }
        }
Example #8
0
        private void LoadTestData()
        {
            System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
            {
                AllGroups.Clear();
                AllSeries.Clear();

                AnimeGroupVM grpNew = new AnimeGroupVM();
                grpNew.GroupName    = grpNew.SortName = "Bleach";
                AllGroups.Add(grpNew);

                grpNew           = new AnimeGroupVM();
                grpNew.GroupName = grpNew.SortName = "Naruto";
                AllGroups.Add(grpNew);

                grpNew           = new AnimeGroupVM();
                grpNew.GroupName = grpNew.SortName = "High School of the Dead";
                AllGroups.Add(grpNew);

                grpNew           = new AnimeGroupVM();
                grpNew.GroupName = grpNew.SortName = "Gundam";
                AllGroups.Add(grpNew);
            });
        }
Example #9
0
        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);
            }
        }
Example #10
0
        //[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);
            }
        }
Example #11
0
 public static bool EvaluateGroupFilter(GroupFilterVM gf, AnimeGroupVM grp)
 {
     return(gf.EvaluateGroupFilter(grp));
 }