private static void OnIsEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { GpsLayer layer = d as GpsLayer; if (!(bool)e.NewValue) { if (layer.GeoPositionWatcher != null) { layer.GeoPositionWatcher.Stop(); } } else { layer.TryStartGps(); } }
private static void GeoPositionWatcherPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { GpsLayer layer = d as GpsLayer; if (e.OldValue != null) { layer.DetachListeners(e.OldValue as IGeoPositionWatcher <GeoCoordinate>); } if (e.NewValue != null) { layer.AttachListeners(e.NewValue as IGeoPositionWatcher <GeoCoordinate>); if (layer.IsInitialized && layer.IsEnabled) { layer.TryStartGps(); } } }