Example #1
0
        private void btnTips_Click(object sender, RoutedEventArgs e)
        {
            if (((SolidColorBrush)btnTips.Foreground).Color == Colors.LightYellow)
            {
                btnTips.Foreground = new SolidColorBrush(Colors.Black);
                if (WebTipsContent != null)
                {
                    WebTipsContent.Tapped -= (s1, e1) => btnTips_Click(null, null);
                    mainGrid.Children.Remove(WebTipsContent);
                }
            }
            else
            {
                btnTips.Foreground = new SolidColorBrush(Colors.LightYellow);

                if (WebTipsContent == null)
                {
                    WebTipsContent = new WebInfoContent();                      //创建web提示窗口
                }
                WebTipsContent.DataContext = infoList;                          //绑定get到的信息

                WebTipsContent.Tapped += (s1, e1) => btnTips_Click(null, null); //注册单击事件,单击可关闭

                mainGrid.Children.Add(WebTipsContent);
            }
        }
Example #2
0
        public async Task GetNetInfo()
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    string uriStr = "http://www.cjw1115.com/Info?id=" + DateTime.Now;
                    using (HttpResponseMessage respnese = await client.GetAsync(new Uri(uriStr)))
                    {
                        await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
                        {
                            if (infoList == null)
                            {
                                infoList = new  ObservableCollection <InfoEntity>();
                            }

                            //获取json信息
                            string json = await respnese.Content.ReadAsStringAsync();
                            var list    = WebInfoContent.PraseJson(json);
                            //添加前清空数据
                            infoList.Clear();
                            foreach (var item in list)
                            {
                                infoList.Add(item);
                            }
                            WriteWebInfoToLocal(infoList);
                        });
                    }
                }
            }
            catch (Exception ex) { }
        }