示例#1
0
        private async void CurrentTemp(string city)
        {
            string      weburl = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "&mode=xml&appid=ac8f09c254df15f52f73415ebeee573a";
            var         xml    = await new WebClient().DownloadStringTaskAsync(new Uri(weburl));
            XmlDocument doc    = new XmlDocument();

            doc.LoadXml(xml);
            CurrentTemperature.Text = WeatherConversion.GetCurrentTemperatureCelFromDoc(doc, "value").ToString() + "°C";
        }
示例#2
0
 private async void TemperatureChartDraw(string city)
 {
     try
     {
         string      weburl = "http://api.openweathermap.org/data/2.5/forecast?q=" + city + "&mode=xml&appid=ac8f09c254df15f52f73415ebeee573a";
         var         xml    = await new WebClient().DownloadStringTaskAsync(new Uri(weburl));
         XmlDocument doc    = new XmlDocument();
         doc.LoadXml(xml);
         var tempSequence = WeatherConversion.GetTemperatureSequenceCelFromDoc(doc, "value");
         myChart.AddFullChart(tempSequence, 5, tempSequence.Length / 5, city);
         CurrentTemp(city);
     }
     catch
     {
     }
 }