private async void WeatherUpdate(object sender, EventArgs args)
 {
     WeatherModel weather = ((OpenWeatherMap.WeatherUpdateEventArgs)args).UpdatedWeather;
     await uiThreadDispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         OutsideIcon.Source      = new BitmapImage(new Uri(weather.Icon));
         OutsideCondition.Text   = weather.Condition;
         OutsideTemperature.Text = FormatTemperature(weather.Temperature);
         OutsideHumidity.Text    = FormatHumidity(weather.Humidity);
         OutsidePressure.Text    = FormatPressure(weather.Pressure);
     });
 }
Example #2
0
        private async void FetchWeather()
        {
            JsonObject json = await new HttpHelper(BuildRequest()).TryGetJsonAsync();

            if (json == null)
            {
                return;
            }

            JsonObject mainJson    = json.GetNamedObject("main");
            JsonObject weatherJson = json.GetNamedArray("weather").GetObjectAt(0);
            string     description = weatherJson.GetNamedString("main") + " - " + weatherJson.GetNamedString("description");
            var        weather     = new WeatherModel(mainJson.GetNamedNumber("temp") - 273.15, mainJson.GetNamedNumber("humidity"),
                                                      mainJson.GetNamedNumber("pressure") / 10, description, String.Format("http://openweathermap.org/img/w/{0}.png", weatherJson.GetNamedString("icon")));

            WeatherUpdate?.Invoke(this, new WeatherUpdateEventArgs(weather));
        }
Example #3
0
 public WeatherUpdateEventArgs(WeatherModel updatedWeather)
 {
     _updatedWeather = updatedWeather;
 }