private void btnOk_Click(object sender, EventArgs e) { try { if (CodeStatsPackage._settingsForm != null && CodeStatsPackage._settingsForm.Visible) { CodeStatsPackage._settingsForm.Close(); } } finally { } try { string apiKey = txtAPIKey.Text.Trim(); //if (true) //{ _CodeStatsConfigFile.ApiKey = apiKey; _CodeStatsConfigFile.SaveConfigFile(); CodeStatsPackage._hasAlreadyShownInvalidApiTokenMessage = false; /*} * else // - kept in case we check API tokens in future * { * MessageBox.Show("Please enter valid API token."); * DialogResult = DialogResult.None; // do not close dialog box * }*/ } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnOk_Click(object sender, EventArgs e) { //should the api key window be open already, close it as the api key has been set here, so the user doesn't need to provide it again try { if (CodeStatsPackage._apikeyForm != null && CodeStatsPackage._apikeyForm.Visible) { CodeStatsPackage._apikeyForm.Close(); } } finally { } try { codeStatsSettingsProvider.ApiKey = APIKeyInputBox.Text.Trim(); codeStatsSettingsProvider.TrackPlainText = TrackPlainTextCheckbox.Checked; codeStatsSettingsProvider.EnableDebugLogging = DebugModeCheckBox.Checked; codeStatsSettingsProvider.Proxy = ProxyImputBox.Text; codeStatsSettingsProvider.PulseEndpoint = PulseEndpointTextBox.Text.Trim(); codeStatsSettingsProvider.SaveConfigFile(); NotifyOnSettingsSaved(); } catch (Exception ex) { Logger.Error("Error when saving data from SettingsForm", ex); MessageBox.Show(ex.Message); } }