private async void UseCurrentLocation() { if (!_settingsModel.AllowLocationAccess) { if (_messageBoxService.Show("Allow The Other Side to get your current location?\n\nYour location information will only be used to retrieve information and will not be saved or shared with anyone.", "Location Service", System.Windows.MessageBoxButton.OKCancel) != System.Windows.MessageBoxResult.OK) { return; } _settingsModel.AllowLocationAccess = true; _settingsModel.Save(); } _systemTrayService.Show("Getting your current location..."); try { var position = await _locationService.GetPositionAsync(LocationServiceAccuracy.High, TimeSpan.FromMinutes(30), TimeSpan.FromSeconds(20)); _systemTrayService.Hide(); Position = new Coordinate(position.Latitude, position.Longitude); Center = Position; ZoomLevel = 14; } catch (Exception) { _systemTrayService.Hide(); _messageBoxService.Show("An error occurred while trying to get your current location!", "Error"); } }
private void OkExecute() { _settings.Save(); Messenger.Default.Send(new SimpleMessage { Type = SimpleMessage.MessageType.SettingsChanged }); Messenger.Default.Send(new SimpleMessage { Type = SimpleMessage.MessageType.SwitchToTimerView }); }
public SettingsViewModel(ISettingsModel settingsModel, INavigationService navigationService) { _settingsModel = settingsModel; _navigationService = navigationService; _allowLocationAccess = _settingsModel.AllowLocationAccess; SaveCommand = new RelayCommand(() => { _settingsModel.AllowLocationAccess = _allowLocationAccess; _settingsModel.Save(); _navigationService.GoBack(); }); }