diff --git a/ast-visual-studio-extension/CxPreferences/CxPreferencesUI.cs b/ast-visual-studio-extension/CxPreferences/CxPreferencesUI.cs index f8dfa19e..904badb 100644 --- a/ast-visual-studio-extension/CxPreferences/CxPreferencesUI.cs +++ b/ast-visual-studio-extension/CxPreferences/CxPreferencesUI.cs @@ -39,10 +39,15 @@ public void Initialize(CxPreferencesModule preferencesModule) cxPreferencesModule = preferencesModule; tbApiKey.Text = cxPreferencesModule.ApiKey; tbAdditionalParameters.Text = cxPreferencesModule.AdditionalParameters; - ascaCheckBox.Checked = cxPreferencesModule.AscaCheckBox; - + ascaCheckBox.Checked = cxPreferencesModule.AscaCheckBox; + UpdateAscaUiState(); + } + private void UpdateAscaUiState() + { + label1.Visible = ascaCheckBox.Checked; // Show or hide label based on ASCA state } + private void OnApiKeyChange(object sender, EventArgs e) { cxPreferencesModule.ApiKey = tbApiKey.Text.Trim(); @@ -104,10 +109,9 @@ private async void AscaCheckBox_CheckedChanged(object sender, EventArgs e) { bool isChecked = ascaCheckBox.Checked; cxPreferencesModule.AscaCheckBox = isChecked; + UpdateAscaUiState(); if (isChecked) { - // Display the "AI Secure Coding Assistant..." label text - label1.Visible = true; CxCLI.CxWrapper cxWrapper = new CxCLI.CxWrapper(GetCxConfig(), GetType()); _ascaService = ASCAService.GetInstance(cxWrapper); await _ascaService.InitializeASCAAsync(); @@ -115,8 +119,6 @@ private async void AscaCheckBox_CheckedChanged(object sender, EventArgs e) } else { - // Hide the "AI Secure Coding Assistant..." label text - label1.Visible = false; // If ASCA is disabled, dispose the service if it exists if (_ascaService != null) {