diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs b/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs index 6022979..5acdb3e 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/BranchesCombobox.cs @@ -97,7 +97,11 @@ public async Task LoadBranchesAsync(string projectId) /// public void OnChangeBranch(object sender, SelectionChangedEventArgs e) { - if (!(sender is ComboBox branchesCombo) || branchesCombo.SelectedItem == null || branchesCombo.SelectedIndex == -1) return; + if (!(sender is ComboBox branchesCombo) || branchesCombo.SelectedItem == null || branchesCombo.SelectedIndex == -1) + { + cxToolbar.CheckScanButtonStateByCombos(); + return; + } ResetFilteringState(branchesCombo.SelectedItem as ComboBoxItem); @@ -118,7 +122,7 @@ public void OnChangeBranch(object sender, SelectionChangedEventArgs e) _ = scansCombobox.LoadScansAsync(projectId, selectedBranch); - cxToolbar.ScanButtonByCombos(); + cxToolbar.CheckScanButtonStateByCombos(); } protected override void ResetOthersComboBoxesAndResults() { diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs b/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs index 70c6814..d7b7713 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/CxToolbar.cs @@ -163,7 +163,7 @@ public void Init() control.IsChecked = readOnlyStore.GetBoolean(SettingsUtils.groupByCollection, groupBy.ToString(), SettingsUtils.groupByDefaultValues[groupBy]); } - ScanButtonByCombos(); + CheckScanButtonStateByCombos(); _ = IdeScansEnabledAsync(); @@ -311,11 +311,11 @@ private static async Task ASTProjectMatchesWorkspaceProjectAsync(EnvDTE.DT return false; } - public void ScanButtonByCombos() + public void CheckScanButtonStateByCombos() { - var projectId = SettingsUtils.GetToolbarValue(Package, SettingsUtils.projectIdProperty); - var branch = SettingsUtils.GetToolbarValue(Package, SettingsUtils.branchProperty); - ScanStartButton.IsEnabled = !(string.IsNullOrEmpty(projectId) || string.IsNullOrEmpty(branch)); + var isProject = ProjectsCombo?.SelectedItem != null && ProjectsCombo.SelectedIndex != -1; + var isBranch = BranchesCombo?.SelectedItem != null && BranchesCombo.SelectedIndex != -1; + ScanStartButton.IsEnabled = isProject && isBranch; } private async Task IdeScansEnabledAsync() @@ -410,7 +410,7 @@ private async Task PollScanStartedAsync() var scanId = SettingsUtils.GetToolbarValue(Package, SettingsUtils.createdScanIdProperty); if (string.IsNullOrWhiteSpace(scanId)) { - ScanStartButton.IsEnabled = true; + CheckScanButtonStateByCombos(); return; }; var options = default(TaskHandlerOptions); diff --git a/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs b/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs index 3be40db..dcb7220 100644 --- a/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs +++ b/ast-visual-studio-extension/CxExtension/Toolbar/ProjectsCombobox.cs @@ -143,7 +143,11 @@ private async Task LoadProjectsComboboxAsync() public void OnChangeProject(object sender, SelectionChangedEventArgs e) { ComboBox projectsCombo = cxToolbar.ProjectsCombo; - if (projectsCombo == null || projectsCombo.SelectedItem == null || projectsCombo.SelectedIndex == -1) return; + if (projectsCombo == null || projectsCombo.SelectedItem == null || projectsCombo.SelectedIndex == -1) + { + cxToolbar.CheckScanButtonStateByCombos(); + return; + } ResetFilteringState(projectsCombo.SelectedItem as ComboBoxItem); @@ -168,7 +172,7 @@ public void OnChangeProject(object sender, SelectionChangedEventArgs e) _ = branchesCombobox.LoadBranchesAsync(selectedProject); - cxToolbar.ScanButtonByCombos(); + cxToolbar.CheckScanButtonStateByCombos(); } protected override void ResetOthersComboBoxesAndResults()