public void RefreshContinueWatching()
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate {
                    ContinueWatching.Clear();
                });

                DateTime start = DateTime.Now;

                List <VM_AnimeEpisode_User> epContracts =
                    VM_ShokoServer.Instance.ShokoServices.GetContinueWatchingFilter(VM_ShokoServer.Instance.CurrentUser.JMMUserID, VM_UserSettings.Instance.DashMetro_WatchNext_Items).CastList <VM_AnimeEpisode_User>();

                TimeSpan ts = DateTime.Now - start;
                logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: contracts: {0}", ts.TotalMilliseconds);

                start = DateTime.Now;
                List <VM_AnimeEpisode_User> epList = new List <VM_AnimeEpisode_User>();
                foreach (VM_AnimeEpisode_User ep in epContracts)
                {
                    ep.RefreshAnime();
                    if (ep.AniDB_Anime == null)
                    {
                        ep.RefreshAnime(true); // this might be a new series
                    }
                    epList.Add(ep);
                }
                ts = DateTime.Now - start;
                logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: episode details: {0}", ts.TotalMilliseconds);

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate
                {
                    foreach (VM_AnimeEpisode_User ep in epList)
                    {
                        var imageName = AppSettings.DashMetroImageType == DashboardMetroImageType.Fanart ? ep.AniDB_Anime.FanartPath : ep.AniDB_Anime.PosterPathWithRandoms;

                        ContinueWatching.Add(new ContinueWatchingTile()
                        {
                            EpisodeDetails    = ep.EpisodeNumberAndName,
                            AnimeName         = ep.AnimeSeries.SeriesName,
                            Picture           = imageName,
                            AnimeSeries       = ep.AnimeSeries,
                            UnwatchedEpisodes = ep.AnimeSeries.UnwatchedEpisodeCount,
                            TileSize          = "Large",
                            Height            = 100
                        });
                    }

                    ViewContinueWatching.Refresh();
                });

                OnFinishedProcess(new FinishedProcessEventArgs(DashboardMetroProcessType.ContinueWatching));
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Esempio n. 2
0
        public void RefreshContinueWatching()
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    ContinueWatching.Clear();
                });

                DateTime start = DateTime.Now;

                List <JMMServerBinary.Contract_AnimeEpisode> epContracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetContinueWatchingFilter(JMMServerVM.Instance.CurrentUser.JMMUserID.Value, UserSettingsVM.Instance.DashMetro_WatchNext_Items);

                TimeSpan ts = DateTime.Now - start;
                logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: contracts: {0}", ts.TotalMilliseconds);

                start = DateTime.Now;
                List <AnimeEpisodeVM> epList = new List <AnimeEpisodeVM>();
                foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
                {
                    AnimeEpisodeVM ep        = new AnimeEpisodeVM(contract);
                    string         animename = ep.AnimeName;             // just do this to force anidb anime detail record to be loaded
                    ep.RefreshAnime();
                    //ep.SetTvDBInfo();
                    epList.Add(ep);
                }
                ts = DateTime.Now - start;
                logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: episode details: {0}", ts.TotalMilliseconds);

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    foreach (AnimeEpisodeVM ep in epList)
                    {
                        string imageName = "";
                        if (AppSettings.DashMetroImageType == DashboardMetroImageType.Fanart)
                        {
                            imageName = ep.AniDB_Anime.FanartPathPreferThumb;
                        }
                        else
                        {
                            imageName = ep.AniDB_Anime.PosterPathWithRandoms;
                        }

                        ContinueWatching.Add(new ContinueWatchingTile()
                        {
                            EpisodeDetails    = ep.EpisodeNumberAndName, AnimeName = ep.AnimeSeries.SeriesName,
                            Picture           = imageName,
                            AnimeSeries       = ep.AnimeSeries,
                            UnwatchedEpisodes = ep.AnimeSeries.UnwatchedEpisodeCount,
                            TileSize          = "Large",
                            Height            = 100
                        });
                    }

                    ViewContinueWatching.Refresh();
                });

                OnFinishedProcess(new FinishedProcessEventArgs(DashboardMetroProcessType.ContinueWatching));
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }