/// <summary> /// Initializes a new instance of the <see cref="GeolocationHelper"/> class. /// </summary> /// <param name="sensorSettings">The sensor settings.</param> public GeolocationHelper([NotNull] SensorSettings sensorSettings) { if (sensorSettings == null) { throw new ArgumentNullException("sensorSettings"); } _sensorSettings = sensorSettings; // Listen for sensor property changes to update the accuracy request _sensorSettings.PropertyChanged += HandleSensorSettingsPropertyChanged; _geolocator = new Geolocator(); // Listen for status change events, but also immediately get the status. // This is in case it is already at its end-state and therefore // won't generate a change event. _geolocator.StatusChanged += (o, e) => SetGeoLocatorReady(e.Status == PositionStatus.Ready); SetGeoLocatorReady(_geolocator.LocationStatus == PositionStatus.Ready); // Set the desired accuracy. Alternatively, can use // DesiredAccuracyInMeters, where < 100 meters ==> high accuracy _geolocator.DesiredAccuracy = GetDesiredPositionAccuracy(); // Listen for position changed events. // Set to not report more often than once every 10 seconds // and only when movement exceeds 50 meters _geolocator.ReportInterval = 10000; // Value in ms _geolocator.MovementThreshold = 50; // Value in meters _geolocator.PositionChanged += GeolocatorOnPositionChanged; }
/// <summary> /// Initializes a new instance of the <see cref="SensorsExamplePage"/> class. /// </summary> public SensorsExamplePage() { _sensorSettings = ((App)Application.Current).SensorSettings; _sensorHelper = new SensorHelper(_sensorSettings); _geolocationHelper = new GeolocationHelper(_sensorSettings); _geofenceHelper = new GeofenceHelper(); _geofenceHelper.FenceUpdated += HandleGeofenceHelperFenceUpdated; _geofenceHelper.FenceRemoved += HandleGeofenceHelperFenceRemoved; InitializeComponent(); AddGeofencesToMap(); _navigationHelper = new NavigationHelper(this); _navigationHelper.LoadState += HandleNavigationHelperLoadState; _navigationHelper.SaveState += HandleNavigationHelperSaveState; }
/// <summary> /// Initializes a new instance of the <see cref="SensorHelper" /> class. /// </summary> /// <param name="sensorSettings">The sensor settings.</param> public SensorHelper([NotNull] SensorSettings sensorSettings) { if (sensorSettings == null) { throw new ArgumentNullException("sensorSettings"); } _sensorSettings = sensorSettings; _sensorSettings.PropertyChanged += HandleSensorSettingsPropertyChanged; ConfigureSimpleOrientation(); ConfigureCompass(); ConfigureInclinometer(); ConfigureAccelerometer(); ConfigureGyrometer(); ConfigureOrientationSensor(); ConfigureLightSensor(); }
protected override void OnWindowCreated(WindowCreatedEventArgs args) { base.OnWindowCreated(args); var displayInformation = DisplayInformation.GetForCurrentView(); SensorSettings = new SensorSettings { DisplayOrientation = displayInformation.CurrentOrientation }; displayInformation.OrientationChanged += (sender, o) => { SensorSettings.DisplayOrientation = displayInformation.CurrentOrientation; }; SettingsPane.GetForCurrentView().CommandsRequested += OnSettingsCommandsRequested; }