private async void BtnLoadMore_Clicked(object sender, EventArgs e)
        {
            if (this.btnLoadMore.Text == "点击隐藏!")
            {
                this.skltLoadMore.IsVisible = false;
                this.btnShrink.IsVisible    = true;
                pic_listView.ScrollTo(StoreSeries.LastOrDefault(), position: ScrollToPosition.End, animated: true);
                return;
            }

            if (this.btnLoadMore.Text == "没有更多数据了!")
            {
                this.btnLoadMore.Text = "点击隐藏!";
                pic_listView.ScrollTo(StoreSeries.LastOrDefault(), position: ScrollToPosition.End, animated: true);
                return;
            }

            LoadingStart();

            double itemNumber = StoreSeries.Count / count + 1;

            page = (int)Math.Ceiling(itemNumber);

            StoreSeries = new ObservableCollection <PictureInfo>(StoreSeries.Union(Paging(page, count, RandomSeries)));

            this.pic_listView.ItemsSource = StoreSeries;


            if (Paging(page, count, RandomSeries).Count < count)
            {
                this.btnLoadMore.Text = "加载服务器数据中...";

                string Account = OptionText_Helper.ReadAllText("Account");

                Times++;

                var q = await GetListViewData(Account, Times);

                if (q.Count == 0)
                {
                    this.btnLoadMore.Text = "没有更多数据了!";

                    pic_listView.ScrollTo(StoreSeries.LastOrDefault(), position: ScrollToPosition.End, animated: true);

                    LoadingEnd();
                    return;
                }

                foreach (var item in q)
                {
                    RandomSeries.Add(item);
                }

                this.btnLoadMore.Text = "点击加载更多...";

                BtnLoadMore_Clicked(sender, e);
            }

            pic_listView.ScrollTo(StoreSeries.LastOrDefault(), position: ScrollToPosition.End, animated: true);

            LoadingEnd();
        }
Beispiel #2
0
        public void RefreshRandomSeries()
        {
            try
            {
                logger.Trace("XXX1 RefreshRandomSeries");
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    RandomSeries.Clear();
                });

                logger.Trace("XXX2 RefreshRandomSeries");
                List <AnimeSeriesVM> serList = new List <AnimeSeriesVM>();
                List <AnimeGroupVM>  grps    = new List <AnimeGroupVM>(MainListHelperVM.Instance.AllGroups);
                logger.Trace("XXX3 RefreshRandomSeries");

                foreach (AnimeGroupVM grp in grps)
                {
                    // ignore sub groups
                    if (grp.AnimeGroupParentID.HasValue)
                    {
                        continue;
                    }

                    foreach (AnimeSeriesVM ser in grp.AllAnimeSeries)
                    {
                        if (!ser.IsComplete)
                        {
                            continue;
                        }
                        if (ser.AllFilesWatched)
                        {
                            continue;
                        }
                        if (!JMMServerVM.Instance.CurrentUser.EvaluateSeries(ser))
                        {
                            continue;
                        }

                        serList.Add(ser);
                    }
                }

                DateTime start = DateTime.Now;
                logger.Trace("XXX4 RefreshRandomSeries");

                var serShuffledList = serList.OrderBy(a => Guid.NewGuid());

                //serList.Shuffle();

                TimeSpan ts = DateTime.Now - start;
                logger.Trace(string.Format("XXX5 Shuffled {0} series list in {1} ms", serList.Count, ts.TotalMilliseconds));

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    foreach (AnimeSeriesVM ser in serShuffledList.Take(AppSettings.DashMetro_RandomSeries_Items))
                    {
                        string imageName = "";
                        if (AppSettings.DashMetroImageType == DashboardMetroImageType.Fanart)
                        {
                            imageName = ser.AniDB_Anime.FanartPath;
                        }
                        else
                        {
                            imageName = ser.AniDB_Anime.PosterPathWithRandoms;
                        }

                        RandomSeries.Add(new RandomSeriesTile()
                        {
                            Details     = "",
                            AnimeName   = ser.SeriesName,
                            Picture     = imageName,
                            AnimeSeries = ser,
                            TileSize    = "Large",
                            Height      = 100
                        });
                    }

                    ViewRandomSeries.Refresh();
                });

                OnFinishedProcess(new FinishedProcessEventArgs(DashboardMetroProcessType.RandomSeries));
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
            finally
            {
            }
        }