private void DisplayWeather(CurrentWeather weatherData, Image weatherPicture)
 {
     labelCity.Text        = weatherData.cityName.ToString();
     labelTemperature.Text = weatherData.temperature.ToString("N1") + " °C";
     labelPressure.Text    = weatherData.pressure.ToString("N0") + " hPa";
     labelWind.Text        = weatherData.windSpeed.ToString("N0") + " m/s";
     labelClouds.Text      = weatherData.clouds.ToString();
     labelHumidity.Text    = weatherData.humidity.ToString() + " %";
     labelSunrise.Text     = weatherData.sunrise.ToLocalTime().ToShortTimeString();
     labelSunset.Text      = weatherData.sunset.ToLocalTime().ToShortTimeString();
     pictureWeather.Image  = weatherPicture;
 }
Exemplo n.º 2
0
        public CurrentWeather GetCurrentWeatherFromXml(XmlDocument xml)
        {
            var result = new CurrentWeather();

            result.cityName = getParam(xml, "//city", "name");
            var temperatureKelvin = double.Parse(getParam(xml, "//temperature", "value"), System.Globalization.CultureInfo.InvariantCulture);
            var unitHelper        = new UnitHelper();

            result.temperature = unitHelper.getTemperatureCelsius(temperatureKelvin);
            result.pressure    = double.Parse(getParam(xml, "//pressure", "value"), System.Globalization.CultureInfo.InvariantCulture);
            result.humidity    = Convert.ToInt32(getParam(xml, "//humidity", "value"));
            result.windSpeed   = double.Parse(getParam(xml, "//speed", "value"), System.Globalization.CultureInfo.InvariantCulture);
            result.clouds      = Convert.ToInt32(getParam(xml, "//clouds", "value"));
            result.sunrise     = DateTime.Parse(getParam(xml, "//sun", "rise"));
            result.sunset      = DateTime.Parse(getParam(xml, "//sun", "set"));
            result.iconId      = getParam(xml, "//weather", "icon");

            return(result);
        }