Пример #1
0
        private async void GetInfo()
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;
                string results = await WebClientClass.GetResults(new Uri("https://picaapi.picacomic.com/categories"));

                CategoriesModel list = JsonConvert.DeserializeObject <CategoriesModel>(results);
                if (list.code == 200)
                {
                    List <CategoriesModel> ls = new List <CategoriesModel>();
                    ls.Add(new CategoriesModel()
                    {
                        title = "支持嗶咔", thumb = new CategoriesModel()
                        {
                            image = "ms-appx:///Assets/Cat/cat_support.jpg"
                        }
                    });
                    ls.Add(new CategoriesModel()
                    {
                        title = "Avnight", thumb = new CategoriesModel()
                        {
                            image = "ms-appx:///Assets/Cat/cat_love_pica.jpg"
                        }
                    });
                    ls.Add(new CategoriesModel()
                    {
                        title = "嗶咔排行榜", thumb = new CategoriesModel()
                        {
                            image = "ms-appx:///Assets/Cat/cat_leaderboard.jpg"
                        }
                    });
                    ls.Add(new CategoriesModel()
                    {
                        title = "隨機本子", thumb = new CategoriesModel()
                        {
                            image = "ms-appx:///Assets/Cat/cat_random.jpg"
                        }
                    });
                    ls.Add(new CategoriesModel()
                    {
                        title = "最近更新", thumb = new CategoriesModel()
                        {
                            image = "ms-appx:///Assets/Cat/cat_latest.jpg"
                        }
                    });
                    list.data.categories.InsertRange(0, ls);
                    gv_Cat.ItemsSource = list.data.categories;
                }
                else
                {
                    messShow.Show(list.message, 3000);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867)
                {
                    messShow.Show("檢查你的網絡連接!", 3000);
                }
                else
                {
                    messShow.Show("讀取信息失敗了,挂個VPN試試?", 3000);
                }
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }