コード例 #1
0
ファイル: DashboardVM.cs プロジェクト: craige1/jmmclient
        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
            {
            }
        }
コード例 #2
0
        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 <VM_AnimeEpisode_User> epContracts =
                        VM_ShokoServer.Instance.ShokoServices.GetEpisodesRecentlyAdded(VM_UserSettings.Instance.Dash_RecentAdditions_Items, VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList <VM_AnimeEpisode_User>();

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate
                    {
                        foreach (VM_AnimeEpisode_User ep in epContracts)
                        {
                            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 <VM_AnimeSeries_User> serContracts =
                        VM_ShokoServer.Instance.ShokoServices.GetSeriesRecentlyAdded(VM_UserSettings.Instance.Dash_RecentAdditions_Items, VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList <VM_AnimeSeries_User>();

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate
                    {
                        foreach (VM_AnimeSeries_User ser in serContracts)
                        {
                            RecentAdditions.Add(ser);
                        }
                        ViewRecentAdditions.Refresh();
                    });
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }