public TaskGps() { gpsPoint = new GpsPoint(); InitializeComponent(); GeoCoordinateWatcher geo = new GeoCoordinateWatcher(); geo.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(geo_PositionChanged); geo.Start(); }
private void showAddress(GpsPoint point) { string URL = "http://dev.virtualearth.net/REST/v1/Locations/" + point.Latitude + "," + point.Longitude + "?o=json&key=AkTjmP71KlW6dUMUX1h7vD98Tpn02-K36swYe1peSSuw12TkpgRG3bmU7GBT612D"; WebClient client = new WebClient(); client.OpenReadCompleted += client_OpenReadCompleted; client.OpenReadAsync(new Uri(URL, UriKind.Absolute)); }
private void salvarGps(string latitude, string longitude) { try { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { if (gpsPoint.TaskId != 0) { gpsPoint.Latitude = latitude; gpsPoint.Longitude = longitude; GpsPoint gpsPointOld = banco.GpsPoints.Where(o => o.Id.Equals(gpsPoint.Id)).First(); gpsPointOld.Latitude = gpsPoint.Latitude; gpsPointOld.Longitude = gpsPoint.Longitude; } else { gpsPoint = new GpsPoint() { Latitude = latitude, Longitude = longitude, TaskId = task.Id }; banco.GpsPoints.InsertOnSubmit(gpsPoint); } banco.SubmitChanges(); MessageBox.Show("Location finded."); } } catch (NullReferenceException e) { MessageBox.Show("Ops, We just got an error."); } }