private void HandleGeofenceStateChanged(GeofenceMonitor monitor, Object o) { // Iterate over and process the accumulated reports var reports = monitor.ReadReports(); foreach (var report in reports) { switch (report.NewState) { case GeofenceState.Entered: case GeofenceState.Exited: var updateArgs = new FenceUpdateEventArgs { FenceId = report.Geofence.Id, Reason = report.NewState.ToString(), Position = report.Geoposition.Coordinate.Point.Position, Timestamp = report.Geoposition.Coordinate.Timestamp }; OnFenceUpdated(updateArgs); break; case GeofenceState.Removed: var removedArgs = new FenceRemovedEventArgs { FenceId = report.Geofence.Id, WhyRemoved = report.RemovalReason.ToString() }; OnFenceRemoved(removedArgs); break; } } }
private void OnFenceUpdated(FenceUpdateEventArgs args) { var handler = FenceUpdated; if (handler != null) { handler(this, args); } }
private async void HandleGeofenceHelperFenceUpdated(Object sender, FenceUpdateEventArgs args) { Debug.WriteLine("Fence {0} updated - {1} at {2:G}. Latitude = {3}, Longitude = {4}", args.FenceId, args.Reason, args.Timestamp, args.Position.Latitude, args.Position.Longitude); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { var fenceUpdateMessage = String.Format("Fence {0} updated - {1} at {2:G}. Latitude = {3}, Longitude = {4}", args.FenceId, args.Reason, args.Timestamp, args.Position.Latitude, args.Position.Longitude); await ShowMessage(fenceUpdateMessage); }); }