private async void locationCheckBox_CheckedChanged(object sender, EventArgs e) { locationCheckBox.Enabled = false; okButton.Enabled = false; if (locationCheckBox.Checked) { locationCheckBox.CheckedChanged -= locationCheckBox_CheckedChanged; locationCheckBox.Checked = false; bool hasAccess = await UwpLocation.RequestAccess(); if (hasAccess) { JsonConfig.settings.useWindowsLocation = true; locationCheckBox.Checked = true; } locationCheckBox.CheckedChanged += locationCheckBox_CheckedChanged; } else { JsonConfig.settings.useWindowsLocation = false; } locationCheckBox.Enabled = true; UpdateGuiState(); }
private async void locationCheckBox_CheckedChanged(object sender, EventArgs e) { locationCheckBox.Enabled = false; if (locationCheckBox.Checked) { locationCheckBox.CheckedChanged -= locationCheckBox_CheckedChanged; locationCheckBox.Checked = false; bool accessGranted = await UwpLocation.RequestAccess(this); if (accessGranted) { JsonConfig.UpdateSetting("useWindowsLocation", true); locationCheckBox.Checked = true; inputBox.Enabled = false; okButton.Enabled = true; } locationCheckBox.CheckedChanged += locationCheckBox_CheckedChanged; } else { JsonConfig.UpdateSetting("useWindowsLocation", false); inputBox.Enabled = true; } locationCheckBox.Enabled = true; }
private async void grantPermissionButton_Click(object sender, EventArgs e) { UpdateLocationState(); await UwpLocation.RequestAccess(); }