public Task<Address_Validated> Automatically_Validate_Address(string textAddress) { var tcs = new TaskCompletionSource<Address_Validated>(); var geocoding = maps.ServiceHelper.GetGeocodeService(); geocoding.GeocodeCompleted += (sender, e) => { //if (e.Error != null) // tcs.SetCanceled(); if (e.Error == null && e.Result.Results.GroupBy(f=> f.Address.FormattedAddress).Count() == 1) { var validated = new Address_Validated(e.Result.Results.First(), null); //MessageBus.Current.SendMessage(new Address_Validated(e.Result.Results.First(), search_Address)); tcs.TrySetResult(validated); } else { tcs.SetCanceled(); //MessageBus.Current.SendMessage(search_Address.To_Manual()); //var task = Manually_Validate_Address(textAddress); //task.Wait(); } }; geocoding.GeocodeAsync(new maps.GeocodeService.GeocodeRequest { Credentials = new Microsoft.Maps.MapControl.Credentials() { Token = maps.ServiceHelper.GeocodeServiceCredentials }, Culture = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString(), Query = textAddress }); return tcs.Task; }
public void Change_Destination(Address_Validated result) { if (result == null) return; Destination = new Location_Reference(result.Location, result.Address); //Destination = new Location_Reference() //{ // Location = result.Location, // Resolved_Address = result.Address, // Search_Address = result.Address.FormattedAddress, //}; //Destination.Validate(); //System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => //{ // Location = result.Location; // Resolved_Address = result.Address; // Search_Address = result.Address.FormattedAddress; // Validate(); //}); }
public void Confirm_Position() { PositionConfirmed = true; var validated = new Address_Validated(SelectedResult, Serving); if (Serving != null && SelectedResult != null) MessageBus.Current.SendMessage(validated); Task.TrySetResult(validated); }