Ejemplo n.º 1
0
 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);
         }
     }
 }
Ejemplo n.º 2
0
 //[LogExecutionTime]
 public void SetGroupFilterSortingOnMainList()
 {
     if (CurrentWrapper is GroupFilterVM)
     {
         GroupFilterVM gf = CurrentWrapper as GroupFilterVM;
         ViewGroups.SortDescriptions.Clear();
         if (gf != null)
         {
             List <SortDescription> sortlist = GroupFilterHelper.GetSortDescriptions(gf);
             foreach (SortDescription sd in sortlist)
             {
                 ViewGroups.SortDescriptions.Add(sd);
             }
         }
     }
     else
     {
         ViewGroups.SortDescriptions.Clear();
     }
 }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        public void RefreshGroupFiltersOnly()
        {
            //LoadTestData();
            //return;

            try
            {
                // set this to null so that it will be refreshed the next time it is needed
                List <JMMServerBinary.Contract_GroupFilter> gfRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupFilters();


                if (gfRaw.Count == 0)
                {
                    return;
                }

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    object p = CurrentWrapper;


                    GroupFilterVM vms = AllGroupFiltersDictionary.Values.Where(a => a.GroupFilterID == 0).FirstOrDefault();
                    AllGroupFiltersDictionary.Clear();
                    if (vms != null)
                    {
                        AllGroupFiltersDictionary.Add(0, vms);
                    }
                    foreach (JMMServerBinary.Contract_GroupFilter gf_con in gfRaw.OrderBy(a => a.GroupFilterName))
                    {
                        GroupFilterVM gf = new GroupFilterVM(gf_con);
                        gf.AllowEditing  = !gf.IsLocked;
                        AllGroupFiltersDictionary[gf.GroupFilterID.Value] = gf;
                    }

                    //Restore previous condition
                    if (p is GroupFilterVM)
                    {
                        int id = ((GroupFilterVM)p).GroupFilterID.Value;
                        if (AllGroupFiltersDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllGroupFiltersDictionary[id];
                        }
                    }
                    else if (p is AnimeGroupVM)
                    {
                        int id = ((AnimeGroupVM)p).AnimeGroupID.Value;
                        if (AllGroupsDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllGroupsDictionary[id];
                        }
                    }
                    else if (p is AnimeSeriesVM)
                    {
                        int id = ((AnimeSeriesVM)p).AnimeSeriesID.Value;
                        if (AllSeriesDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllSeriesDictionary[id];
                        }
                    }
                    OnRefreshed();
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
 public static bool EvaluateGroupFilter(GroupFilterVM gf, AnimeSeriesVM ser)
 {
     return(gf.EvaluateGroupFilter(ser));
 }
Ejemplo n.º 7
0
 public static bool EvaluateGroupFilter(GroupFilterVM gf, AnimeGroupVM grp)
 {
     return(gf.EvaluateGroupFilter(grp));
 }