Skip to content

Commit

Permalink
Update CxPreferencesUI.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
elchananarb committed Nov 28, 2024
1 parent 04a391d commit f1b9ee5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ast-visual-studio-extension/CxPreferences/CxPreferencesUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -104,19 +109,16 @@ 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();

}
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)
{
Expand Down

0 comments on commit f1b9ee5

Please sign in to comment.