コード例 #1
0
ファイル: MainListHelperVM.cs プロジェクト: RickDB/jmmclient
 public void ClearData()
 {
     AllGroupsDictionary.Clear();
     AllSeriesDictionary.Clear();
     AllAnimeDictionary.Clear();
     AllGroupFiltersDictionary.Clear();
     ViewSeriesSearch.Refresh();
     LastChange = DateTime.MinValue;
     OnRefreshed();
 }
コード例 #2
0
ファイル: MainListHelperVM.cs プロジェクト: RickDB/jmmclient
        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);
            }
        }
コード例 #3
0
        public void RefreshGroupFiltersOnly()
        {
            //LoadTestData();
            //return;

            try
            {
                // set this to null so that it will be refreshed the next time it is needed
                List <VM_GroupFilter> gfRaw = VM_ShokoServer.Instance.ShokoServices.GetAllGroupFilters().CastList <VM_GroupFilter>();


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

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


                    VM_GroupFilter vms = AllGroupFiltersDictionary.Values.FirstOrDefault(a => a.GroupFilterID == 0);
                    AllGroupFiltersDictionary.Clear();
                    if (vms != null)
                    {
                        AllGroupFiltersDictionary.Add(0, vms);
                    }
                    foreach (VM_GroupFilter gf in gfRaw.OrderBy(a => a.GroupFilterName))
                    {
                        AllGroupFiltersDictionary[gf.GroupFilterID] = gf;
                    }

                    //Restore previous condition
                    if (p is VM_GroupFilter)
                    {
                        int id = ((VM_GroupFilter)p).GroupFilterID;
                        if (AllGroupFiltersDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllGroupFiltersDictionary[id];
                        }
                    }
                    else if (p is VM_AnimeGroup_User)
                    {
                        int id = ((VM_AnimeGroup_User)p).AnimeGroupID;
                        if (AllGroupsDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllGroupsDictionary[id];
                        }
                    }
                    else if (p is VM_AnimeSeries_User)
                    {
                        int id = ((VM_AnimeSeries_User)p).AnimeSeriesID;
                        if (AllSeriesDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllSeriesDictionary[id];
                        }
                    }
                    OnRefreshed();
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }