Ejemplo n.º 1
0
        private async void OneDay_OnLoaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var postion = await LocationData.getPosition();

#pragma warning disable CS0618 // Type or member is obsolete
                var lat = postion.Coordinate.Latitude;
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
                var lon = postion.Coordinate.Longitude;
#pragma warning restore CS0618 // Type or member is obsolete

                OpenWeatherMap1day.RootObject myWeather = await ApiHandle.GetWeatherOneDay(lat, lon);

                Debug.WriteLine(myWeather);
                string icon = string.Format("ms-appx:///Assets/Weather/{0}.png", myWeather.weather[0].icon);
                ResultImage.Source        = new BitmapImage(new Uri(icon, UriKind.Absolute));
                TempTextBlock.Text        = myWeather.main.temp.ToString();
                DescriptionTextBlock.Text = myWeather.weather[0].description;
                LocationTextBlock.Text    = myWeather.name;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Can not connect to API");
            }
        }