コード例 #1
0
        async private void _geolocator_StatusChanged(Geolocator sender, StatusChangedEventArgs args)
        {
            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
            {
                var current_view = ApplicationView.GetForCurrentView();
                var status       = args.Status;
                switch (status)
                {
                case PositionStatus.Disabled:
                    _last_page_before_nav_lost = root_frame.CurrentSourcePageType;
                    root_frame.Navigate(typeof(NoLocationPage));
                    break;

                case PositionStatus.Ready:

                    var root_frame_type = root_frame.Content?.GetType();
                    if (root_frame_type != _last_page_before_nav_lost &&
                        root_frame_type != typeof(UserIntroPage))
                    {
                        root_frame.Navigate(_last_page_before_nav_lost);
                    }
                    CurrentLocation = await _geolocator.GetGeopositionAsync();
                    GeoLocationChanged?.Invoke(CurrentLocation.Coordinate.Point);
                    break;

                case PositionStatus.Initializing:
                    break;

                default:
                    break;
                }
            });
        }
コード例 #2
0
        async private void _geolocator_StatusChanged(Geolocator sender, StatusChangedEventArgs args)
        {
            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
            {
                var current_view = ApplicationView.GetForCurrentView();
                var status       = args.Status;
                switch (status)
                {
                case PositionStatus.Disabled:
                    _last_page_before_nav_lost = root_frame.CurrentSourcePageType;
                    root_frame.Navigate(typeof(NoLocationPage));
                    break;

                case PositionStatus.Ready:
                    current_view.TitleBar.BackgroundColor = Colors.Transparent;
                    root_frame.Navigate(_last_page_before_nav_lost);
                    CurrentLocation = await _geolocator.GetGeopositionAsync();
                    GeoLocationChanged?.Invoke(CurrentLocation.Coordinate.Point);
                    break;

                case PositionStatus.Initializing:
                    current_view.TitleBar.BackgroundColor = Colors.Yellow;
                    break;

                default:
                    current_view.TitleBar.BackgroundColor = Colors.Red;
                    break;
                }
            });
        }
コード例 #3
0
        async private void ApplicationHostPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (App.State.UserProfile == null)
            {
                root_frame.Navigate(typeof(UserIntroPage));
            }
            else
            {
                var access_status = await Geolocator.RequestAccessAsync();

                switch (access_status)
                {
                case GeolocationAccessStatus.Allowed:
                    root_frame.Navigate(typeof(LandingPage));
                    CurrentLocation = await _geolocator.GetGeopositionAsync();

                    GeoLocationChanged?.Invoke(CurrentLocation.Coordinate.Point);
                    var fence_id = App.State.NextEvent.EventID.ToString();
                    var fences   = GeofenceMonitor.Current.Geofences;
                    var fence    = fences.Where(i => i.Id == fence_id).FirstOrDefault();
                    if (fence == null)
                    {
                        Geocircle event_radius = new Geocircle(new BasicGeoposition
                        {
                            Latitude  = App.State.NextEvent.Latitude.Value,
                            Longitude = App.State.NextEvent.Longitude.Value,
                        }, 100);

                        fence = new Geofence(fence_id, event_radius);

                        //add a geofence
                        GeofenceMonitor.Current.Geofences.Add(fence);
                    }

                    break;

                case GeolocationAccessStatus.Denied:
                    root_frame.Navigate(typeof(NoLocationPage));
                    break;

                case GeolocationAccessStatus.Unspecified:
                    break;
                }
            }
        }
コード例 #4
0
        async private Task InitializeLocation()
        {
            CurrentLocation = await _geolocator.GetGeopositionAsync();

            GeoLocationChanged?.Invoke(CurrentLocation.Coordinate.Point);
            var fence_id = App.State.NextEvent.EventID.ToString();
            var fences   = GeofenceMonitor.Current.Geofences;
            var fence    = fences.Where(i => i.Id == fence_id).FirstOrDefault();

            if (fence == null)
            {
                Geocircle event_radius = new Geocircle(new BasicGeoposition
                {
                    Latitude  = App.State.NextEvent.Latitude.Value,
                    Longitude = App.State.NextEvent.Longitude.Value,
                }, 100);

                fence = new Geofence(fence_id, event_radius);

                //add a geofence
                GeofenceMonitor.Current.Geofences.Add(fence);
            }
        }
コード例 #5
0
 private void _geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
 {
     CurrentLocation = args.Position;
     GeoLocationChanged?.Invoke(CurrentLocation.Coordinate.Point);
 }
コード例 #6
0
 public void Process(GeoLocationChanged @event)
 {
     // http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=370678173d62334da13aac92efa77910
 }
コード例 #7
0
 internal void AddOrUpdateLocationTrait()
 {
     m_Database.GetTraitProvider(out MARSTraitDataProvider <Vector2> vector2TraitProvider);
     vector2TraitProvider?.AddOrUpdateTrait((int)ReservedDataIDs.ImmediateEnvironment, TraitNames.Geolocation, m_CurrentLocation);
     GeoLocationChanged?.Invoke(m_CurrentLocation);
 }