コード例 #1
0
        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();
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 private async void grantPermissionButton_Click(object sender, EventArgs e)
 {
     UpdateLocationState();
     await UwpLocation.RequestAccess();
 }