private async void TakePhotoButton_Click(object sender, RoutedEventArgs e) { BitmapImage bitmapSource = await PhotoHelper.GetPhotoFromCameraLaunch(); if (bitmapSource == null) { return; } // Specify a random location // var currentLocation = await LocationHelper.GetRandomGeoposition(); //Geopoint geopoint = new Geopoint(currentLocation); var currentLocation = await LocationHelper.GetCurrentLocationAsync(); LocationData location = new LocationData { Position = currentLocation.Geopoint.Position, ImageSource = bitmapSource }; this.Locations.Add(location); this.LocationsView.UpdateLayout(); LocationsView.SelectedItem = location; await LocationHelper.TryUpdateMissingLocationInfoAsync(location, null); }
/// <summary> /// Gets the current location if the geolocator is available, /// and updates the Geolocator status message depending on the results. /// </summary> /// <returns>The current location.</returns> private async Task <LocationData> GetCurrentLocationAsync() { var currentLocation = await LocationHelper.GetCurrentLocationAsync(); this.UpdateLocationStatus(currentLocation != null); return(currentLocation); }
public async Task RefreshForecastAsync() { IsBusy = true; NeedsRefresh = false; WeatherInformation.Forecast results = null; Forecast.Clear(); switch (LocationType) { case LocationType.Location: if (Location == null) { Location = await LocationHelper.GetCurrentLocationAsync(); } results = await WeatherHelper.GetForecastAsync(Location.Latitude, Location.Longitude); break; case LocationType.City: results = await WeatherHelper.GetForecastAsync(CityName, CountryCode); break; } IsBusy = false; }
/// <summary> /// Gets the current location if the geolocator is available, /// and updates the Geolocator status message depending on the results. /// </summary> /// <returns>The current location.</returns> private async Task <LocationPin> GetCurrentLocationAsync() { var currentLocation = await LocationHelper.GetCurrentLocationAsync(); App.currentLocation = currentLocation; return(currentLocation); }
public async Task RefreshCurrentConditionsAsync() { IsBusy = true; NeedsRefresh = false; WeatherInformation.ResponseWeather resultsResponse = null; switch (LocationType) { case LocationType.Location: if (Location == null) { Location = await LocationHelper.GetCurrentLocationAsync(); } resultsResponse = await WeatherHelper.GetCurrentConditionsAsync(Location.Latitude, Location.Longitude); break; case LocationType.City: resultsResponse = await WeatherHelper.GetCurrentConditionsAsync(CityName, CountryCode); break; } CurrentConditionsWeather.main = resultsResponse.weather[0].main; CurrentConditionsWeather.description = resultsResponse.weather[0].description; //CurrentConditionsWeather[0].icon = resultsResponse.weather[0].icon; CurrentConditionsWeather.icon = resultsResponse.weather[0].icon; CurrentConditionsResponse.name = resultsResponse.name; //CurrentConditionsResponse.weather.Contains() = resultsWeather; CurrentConditionsResponse.id = resultsResponse.id; CurrentConditionsMain.temp_max = resultsResponse.main.temp_max; CurrentConditionsMain.temp_min = resultsResponse.main.temp_min; CurrentConditionsMain.temp = resultsResponse.main.temp; //CurrentConditions.Humidity = results.Humidity; CurrentConditionsResponse.dt = resultsResponse.dt; ChangedConditions.temp_max = Convert.ToInt32(CurrentConditionsMain.temp_max - 273.15); ChangedConditions.temp_min = Convert.ToInt32(CurrentConditionsMain.temp_min - 273.15); ChangedConditions.temp = Convert.ToInt32(CurrentConditionsMain.temp - 273.15); ChangedConditions.grades = "C"; IsBusy = false; }