/// <summary> /// 通过本地更新磁贴,未来天气 /// </summary> /// <param name="future"></param> /// <param name="cityName"></param> /// <param name="getWeatherTypeRespose"></param> /// <param name="getUserRespose"></param> private void UpdateTileByClientForTomorrow(string tileId, Model.Weather.Daily_forecastItem daily_forecast, string cityName) { string tileXmlString = "<tile>" + "<visual version='2'>" + "<binding template='TileWide310x150Text01' fallback='TileWideText01'>" + "<text id='1'>" + cityName + "</text>" + "<text id='2'>" + daily_forecast.tmp.min + "°~" + daily_forecast.tmp.max + "° " + (daily_forecast.cond.code_d == daily_forecast.cond.code_n ? daily_forecast.cond.txt_d : daily_forecast.cond.txt_d + "转" + daily_forecast.cond.txt_n) + "</text>" + "<text id='3'>" + daily_forecast.wind.dir + " " + daily_forecast.wind.sc + " 级</text>" + "<text id='4'>湿度: " + daily_forecast.hum + "%</text>" + "<text id='5'>能见度: " + daily_forecast.vis + "km</text>" + "</binding>" + "<binding template='TileSquare150x150PeekImageAndText01' fallback='TileSquarePeekImageAndText01'>" + "<image id='1' src='ms-appx:///" + ((DateTime.Compare(DateTime.Now.ToLocalTime(), DateTime.Parse(daily_forecast.astro.sr)) > 1 & DateTime.Compare(DateTime.Now.ToLocalTime(), DateTime.Parse(daily_forecast.astro.ss)) < 0) ? weatherTypeRespose.WeatherTypes.Find(x => x.Code == daily_forecast.cond.code_d).TileSquarePic : weatherTypeRespose.WeatherTypes.Find(x => x.Code == daily_forecast.cond.code_n).TileSquarePic) + "'/>" + "<text id='1'>" + cityName + "</text>" + "<text id='2'>" + daily_forecast.tmp.min + "°~" + daily_forecast.tmp.max + "</text>" + "<text id='3'>" + (daily_forecast.cond.code_d == daily_forecast.cond.code_n ? daily_forecast.cond.txt_d : daily_forecast.cond.txt_d + "转" + daily_forecast.cond.txt_n) + "</text>" + "<text id='4'>" + daily_forecast.wind.dir + " " + daily_forecast.wind.sc + "</text>" + "</binding>" + "</visual>" + "</tile>"; SecondaryTileHelper.UpdateSecondaryTileNotificationsByXml(tileId, tileXmlString); }
/// <summary> /// 更新单个城市 /// </summary> /// <returns></returns> private async Task UpdateCity(Model.UserCity userCity) { string resposeString = await GetRealResposeString(userCity.CityId); GetWeatherRespose respose = Weather.Utils.JsonSerializeHelper.JsonDeserialize <GetWeatherRespose>(resposeString); string tileId = userCity.CityId + "_Weather"; if (SecondaryTileHelper.IsExists(tileId)) { UpdateSecondaryTile(respose, tileId); } await CreateFile(userCity.CityId, resposeString); }
/// <summary> /// 更新辅助磁贴信息 /// </summary> /// <param name="tileId"></param> private void UpdateSecondaryTile(GetWeatherRespose respose, string tileId) { string tileXmlString = @"<tile>" + "<visual version='2'>" + "<binding template='TileWide310x150PeekImage02' fallback='TileWidePeekImage02'>" + "<image id='1' src='ms-appx:///" + weatherTypeRespose.WeatherTypes.Find(x => x.Code == weatherRespose.result.FirstOrDefault().now.cond.code).TileWidePic + "'/>" + "<text id='1'>" + weatherRespose.result.FirstOrDefault().basic.city + "</text>" + "<text id='2'>" + weatherRespose.result.FirstOrDefault().daily_forecast.FirstOrDefault().tmp.min + "°~" + weatherRespose.result.FirstOrDefault().daily_forecast.FirstOrDefault().tmp.max + "° " + weatherRespose.result.FirstOrDefault().now.cond.txt + "</text>" + "<text id='3'>" + weatherRespose.result.FirstOrDefault().now.wind.dir + " " + weatherRespose.result.FirstOrDefault().now.wind.sc + " 级</text>" + "<text id='4'>湿度: " + weatherRespose.result.FirstOrDefault().now.hum + "%</text>" + "<text id='5'>能见度: " + weatherRespose.result.FirstOrDefault().now.vis + "km</text>" + "</binding>" + "<binding template='TileSquare150x150PeekImageAndText01' fallback='TileSquarePeekImageAndText01'>" + "<image id='1' src='ms-appx:///" + weatherTypeRespose.WeatherTypes.Find(x => x.Code == respose.result.FirstOrDefault().now.cond.code).TileSquarePic + "'/>" + "<text id='1'>" + respose.result.FirstOrDefault().basic.city + "</text>" + "<text id='2'>" + respose.result.FirstOrDefault().now.tmp + "°</text>" + "<text id='3'>" + respose.result.FirstOrDefault().now.cond.txt + "</text>" + "<text id='4'>" + respose.result.FirstOrDefault().now.wind.dir + " " + respose.result.FirstOrDefault().now.wind.sc + "</text>" + "</binding>" + "</visual>" + "</tile>"; SecondaryTileHelper.UpdateSecondaryTileNotificationsByXml(tileId, tileXmlString); }
public SecondPageViewModel() { _secondaryTileHelper = new SecondaryTileHelper(); UpdatePinMeText(); }