예제 #1
0
        private async void UpdateTile()
        {
            //取得台灣各城市UV資料
            TaiwanUVOpenDataService twUVDataSer = new TaiwanUVOpenDataService();
            List<TaiwanCityUV> twCityUVData = await twUVDataSer.GetTaiwanUVData();

            // 建立 TileUpdateManager 物件以更新動態磚
            var updater = TileUpdateManager.CreateTileUpdaterForApplication();

            // 最多可Queue 五則通知
            updater.EnableNotificationQueue(true);
            updater.Clear();

            // 取得動態磚範本XML
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Block);

            //設定動態磚資料
            if (twCityUVData.Count > 0)
            {
                System.Random rnd = new System.Random();

                TaiwanCityUV tileCityUV = twCityUVData[rnd.Next(0, twCityUVData.Count-1)];

                tileXml.GetElementsByTagName("text")[0].InnerText =" "+ tileCityUV.UVI.ToString();
                tileXml.GetElementsByTagName("text")[1].InnerText = tileCityUV.SiteName + " 紫外線";

                // Create a new tile notification. 

            }
            else
            {
                tileXml.GetElementsByTagName("text")[0].InnerText = "未知";
                tileXml.GetElementsByTagName("text")[1].InnerText ="未取得資料";


            }

            updater.Update(new TileNotification(tileXml));
        }
예제 #2
0
 //取得資料
 public async Task LoadData()
 {
     TaiwanUVOpenDataService tUV = new TaiwanUVOpenDataService();
     TaiwanUVData = new ObservableCollection<TaiwanCityUV>(await tUV.GetTaiwanUVData());
 }