async void ChangedEventHandler(object sender, GeoEventArgs e)
        {
            if (!mLocSet)
            {
                CoreDispatcher disp = CoreApplication.MainView.CoreWindow.Dispatcher;

                double dlat = e.Lat;
                double dlon = e.Lon;

                await disp.RunAsync(CoreDispatcherPriority.Normal, () => { rbNorth.IsChecked = dlat > 0;
                                                                           rbSouth.IsChecked = dlat < 0;
                                                                           rbEast.IsChecked  = dlon > 0;
                                                                           rbWest.IsChecked  = dlon < 0;
                                                                           tbWait.Visibility = Visibility.Collapsed; });

                await disp.RunAsync(CoreDispatcherPriority.Normal, () => { ResetMapPositions(dlat, dlon); });

                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                              () =>
                {
                    tbCurCoords.Text = GPSConverter.ConvertDeg2DegMinutes(dlat) + "," + GPSConverter.ConvertDeg2DegMinutes(dlon);
                    IsEnabled        = true;
                });

                mLocSet = true;
            }
        }
Exemplo n.º 2
0
        private async void OnGPSTimer(object state)
        {
            GeoLocation p = state as GeoLocation;

            switch (p.mAccessStatus)
            {
            case GeolocationAccessStatus.Allowed:
                Geolocator geolocator = new Geolocator {
                    DesiredAccuracyInMeters = 10
                };

                Geoposition pos = await geolocator.GetGeopositionAsync();

                double dlat = pos.Coordinate.Point.Position.Latitude;
                double dlon = pos.Coordinate.Point.Position.Longitude;

                GeoEventArgs args = new GeoEventArgs(dlat, dlon);

                Changed(this, args);
                break;
            }
        }