public void init(DropDown.ListItem it) { lbl1.Content = it.w; lbl2.Content = it.dur; BitmapImage image = new BitmapImage(new Uri(string.Format(@"res\wth\{0}.png", it.imgsrc), UriKind.Relative)); img.Source = image; rect.Fill = it.brush; rect.Opacity = 0.60; }
//该函数需要优化 public void updateInfo(int type = 0) { if (type == 0) { //实时天气 if (m_weather == null || m_weather["temp"] == "暂无实况") { popMsg("本区暂无实况"); return; } titleName.Content = m_weather["city"]; temp.Content = m_weather["temp"] + "℃"; windsd.Content = m_weather["WD"] + m_weather["WS"] + " 湿度" + m_weather["SD"]; time.Content = string.Format("{0}月{1}日 {2}", DateTime.Now.Month, DateTime.Now.Day, m_weather["time"]); } else { //预报天气 //string[] days = { "今天", "周一", "周二", "周三", "周四", "周五", "周六", "周日" }; var alc = new byte[, ] { { 84, 27, 134 }, { 186, 151, 197 }, { 166, 207, 229 }, { 12, 180, 234 }, { 230, 28, 100 } }; forecastList.clear(); for (int i = 1; i <= 5; ++i) { DropDown.ListItem it = new DropDown.ListItem(); it.w = "未来" + i + "天"; it.dur = m_forcast["temp" + (i + 1)]; it.imgsrc = m_forcast["img" + ((i + 1) * 2)]; it.brush = new SolidColorBrush(Color.FromRgb(alc[i - 1, 0], alc[i - 1, 1], alc[i - 1, 2])); if (it.imgsrc == "99") { it.imgsrc = m_forcast["img" + ((i + 1) * 2 - 1)]; } forecastList.addItem(it); } lblWeather.Content = m_forcast["weather1"]; lblTips.Content = "穿衣指数:" + m_forcast["index_d"]; lbl_1.Content = "紫外线:" + m_forcast["index_uv"]; lbl_2.Content = "洗车:" + m_forcast["index_xc"]; lbl_3.Content = "旅游:" + m_forcast["index_tr"]; lbl_4.Content = "舒适指数:" + m_forcast["index_co"]; mainImg.Source = new BitmapImage(new Uri(string.Format(@"res\wth\{0}.png", m_forcast["img1"]), UriKind.Relative)); } }
//该函数需要优化 public void updateInfo(int type = 0) { if (type == 0) { //实时天气 if (m_weather == null || m_weather["temp"] == "暂无实况") { popMsg("本区暂无实况"); return; } titleName.Content = m_weather["city"]; temp.Content = m_weather["temp"] + "℃"; windsd.Content = m_weather["WD"] + m_weather["WS"] + " 湿度" + m_weather["SD"]; time.Content = string.Format("{0}月{1}日 {2}", DateTime.Now.Month, DateTime.Now.Day, m_weather["time"]); } else { //预报天气 //string[] days = { "今天", "周一", "周二", "周三", "周四", "周五", "周六", "周日" }; var alc = new byte[,] { { 84, 27 ,134}, {186,151,197}, {166,207,229}, {12,180,234}, {230,28,100} }; forecastList.clear(); for (int i = 1; i <= 5; ++i) { DropDown.ListItem it = new DropDown.ListItem(); it.w = "未来" + i + "天"; it.dur = m_forcast["temp" + (i + 1)]; it.imgsrc = m_forcast["img" + ((i + 1) * 2)]; it.brush = new SolidColorBrush(Color.FromRgb(alc[i - 1, 0], alc[i - 1, 1], alc[i - 1, 2])); if (it.imgsrc == "99") it.imgsrc = m_forcast["img" + ((i + 1) * 2 - 1)]; forecastList.addItem(it); } lblWeather.Content = m_forcast["weather1"]; lblTips.Content = "穿衣指数:" + m_forcast["index_d"]; lbl_1.Content = "紫外线:" + m_forcast["index_uv"]; lbl_2.Content = "洗车:" + m_forcast["index_xc"]; lbl_3.Content = "旅游:" + m_forcast["index_tr"]; lbl_4.Content = "舒适指数:" + m_forcast["index_co"]; mainImg.Source = new BitmapImage(new Uri(string.Format(@"res\wth\{0}.png", m_forcast["img1"]), UriKind.Relative)); } }