private async Task Dispaly(int m)//将反序列化之后的类的内容显示到屏幕上
        {
            travellists_uri = "http://apis.baidu.com/qunartravel/travellist/travellist?" + "query=" + App.travellists_query + "&" + "page=" + now_page.ToString();
            try
            {
                travellists_json = await get_resquest.Get_Resquset_Result(new Uri(travellists_uri));  //网络请求拿到Json

                travellists_json = ConvertUnicodeToChinese.ConvertToChinese_Result(travellists_json); //内容转码
                ReFresh_List(travellists_json, m);                                                    //加载游记内容
                now_page++;
                prs.Visibility = Visibility.Collapsed;                                                //隐藏加载下一页新闻内容时显示的进度条
            }
            catch (Exception)
            {
                var dig      = new MessageDialog("可能你的网络有问题哦", "刷呀游记");
                var btnRetry = new UICommand("等会再试吧");
                dig.Commands.Add(btnRetry);
                var result = await dig.ShowAsync();

                if (null != result && result.Label == "等会再试吧")
                {
                    Search_Box.Focus(FocusState.Programmatic);
                    return;
                }
                throw;
            }
        }
예제 #2
0
        private async Task Dispaly(int m) //将反序列化之后的类的内容显示到屏幕上
        {
            if (uri_choice == 0)          //选择文字笑话
            {
                jokes_uri = "http://apis.baidu.com/showapi_open_bus/showapi_joke/joke_text?" + "page=" + now_page.ToString();
            }
            else if (uri_choice == 1)//选择图片笑话
            {
                jokes_uri = "http://apis.baidu.com/showapi_open_bus/showapi_joke/joke_pic?" + "page=" + now_page.ToString();
            }
            try
            {
                jokes_json = await get_resquest.Get_Resquset_Result(new Uri(jokes_uri));  //网络请求拿到Json

                jokes_json = ConvertUnicodeToChinese.ConvertToChinese_Result(jokes_json); //内容转码
                ReFresh_List(jokes_json, m);                                              //加载新闻内容
                now_page++;
                prs.Visibility = Visibility.Collapsed;                                    //隐藏加载下一页新闻内容时显示的进度条
            }
            catch (Exception)
            {
                var dig      = new MessageDialog("可能你的网络有问题哦", "刷呀笑话");
                var btnRetry = new UICommand("等会再试吧");
                dig.Commands.Add(btnRetry);
                var result = await dig.ShowAsync();

                if (null != result && result.Label == "等会再试吧")
                {
                    return;
                }
                throw;
            }
        }
예제 #3
0
        private async Task Dispaly(int m)//将反序列化之后的类的内容显示到屏幕上
        {
            news_uri = "http://apis.baidu.com/showapi_open_bus/channel_news/search_news?" + "channelName=" + App.news_channel_name + "&" + "title=" + App.news_title + "&" + "page=" + now_page.ToString();
            try
            {
                news_json = await get_resquest.Get_Resquset_Result(new Uri(news_uri));  //网络请求拿到Json

                news_json = ConvertUnicodeToChinese.ConvertToChinese_Result(news_json); //内容转码
                ReFresh_List(news_json, m);                                             //加载新闻内容
                now_page++;
                prs.Visibility = Visibility.Collapsed;                                  //隐藏加载下一页新闻内容时显示的进度条
            }
            catch (Exception)
            {
                var dig      = new MessageDialog("可能你的网络有问题哦", "刷呀新闻");
                var btnRetry = new UICommand("等会再试吧");
                dig.Commands.Add(btnRetry);
                var result = await dig.ShowAsync();

                if (null != result && result.Label == "等会再试吧")
                {
                    Search_Box.Focus(FocusState.Programmatic);
                    return;
                }
                throw;
            }
        }
        private async Task Cities_Lists_Add()                               //初始化城市列表
        {
            cities_lists_uri = "http://apis.baidu.com/tngou/hospital/city"; //城市列表接口
            try
            {
                cities_lists_json = await get_resquest.Get_Resquset_Result(new Uri(cities_lists_uri));          //网络请求拿到Json

                cities_lists_json         = ConvertUnicodeToChinese.ConvertToChinese_Result(cities_lists_json); //内容转码
                pane_listview.ItemsSource = App.cities_lists_list;                                              //列表绑定

                #region 添加外国地名在列表之前
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "美洲"
                });
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "欧洲"
                });
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "非洲"
                });
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "澳洲"
                });
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "俄罗斯"
                });
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "迪拜"
                });
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "韩国"
                });
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "日本"
                });
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "泰国"
                });
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "马来西亚"
                });
                App.cities_lists_list.Add(new Cities_Lists {
                    province = "新加坡"
                });
                #endregion

                for (int i = 0; i < 34; i++)
                {
                    cities_lists = JsonToObject.Cities_Lists_JsonConvert(cities_lists_json, i);
                    App.cities_lists_list.Add(cities_lists);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #5
0
        private async Task News_Channel_Add()                                                  //加载汉堡菜单中的新闻频道列表
        {
            pane_listview.ItemsSource = App.news_channel_list;                                 //将集合news_channel_list绑定新闻频道列表pane_listview
            channel_uri  = "http://apis.baidu.com/showapi_open_bus/channel_news/channel_news"; //新闻频道列表接口
            channel_json = await get_resquest.Get_Resquset_Result(new Uri(channel_uri));       //网络请求拿到新闻频道的Json

            channel_json = ConvertUnicodeToChinese.ConvertToChinese_Result(channel_json);      //内容转码
            try
            {
                all_channel_num = JsonToObject.All_News_Channel_Num(channel_json);
                for (int i = 0; i < all_channel_num; i++)
                {
                    news_channel = JsonToObject.News_Channel_JsonConvert(channel_json, i);
                    App.news_channel_list.Add(news_channel);
                }
            }

            catch (Exception)
            {
                throw;
            }
        }
예제 #6
0
        private async void Get_Weather()//获取天气信息
        {
            if (App.allowed_get_position == 0)
            {
                try
                {
                    weather_uri  = "http://apistore.baidu.com/microservice/weather?" + "cityname=" + cityname; //天气api
                    weather_json = await get_request.Get_Resquset_Result(new Uri(weather_uri));                //得到天气Json

                    weather_json = ConvertUnicodeToChinese.ConvertToChinese_Result(weather_json);
                    weather_mes  = JsonToObject.Weather_JsonConvert(weather_json);

                    #region 给天气的相关属性赋值
                    roading.IsActive  = false;
                    city.Text         = App._city = weather_mes.city;
                    date.Text         = App._date = weather_mes.date;
                    high_temp.Text    = App._h_tmp = weather_mes.h_tmp + "°";
                    low_temp.Text     = App._l_tmp = weather_mes.l_tmp + "°";
                    temp.Text         = App._temp = weather_mes.temp;
                    temp_c.Visibility = Visibility.Visible;
                    time.Text         = App._time = weather_mes.time;
                    weather_info.Text = App._weather = weather_mes.weather;
                    #endregion
                }
                catch (Exception)
                {
                    var dig      = new MessageDialog("无法获取你的位置", "刷呀天气");
                    var btnRetry = new UICommand("等会再试吧");
                    dig.Commands.Add(btnRetry);
                    var result = await dig.ShowAsync();

                    return;

                    throw;
                }
            }
        }