Improves UI state after environment autoload

Updates the visibility of UI panels for Winget and drivers when a previous environment is automatically loaded.

This ensures that if Winget apps or driver models are present, their corresponding UI sections are made visible. Additionally, it updates the "select all" checkbox state for Winget results and attempts to pre-select the hardware make for loaded drivers.
This commit is contained in:
rbalsleyMSFT
2025-09-09 18:00:52 -07:00
parent 3ef26f2918
commit bdf1b63833
@@ -741,6 +741,14 @@ function Invoke-AutoLoadPreviousEnvironment {
$State.Controls.lstWingetResults.ItemsSource = $appsBuffer.ToArray() $State.Controls.lstWingetResults.ItemsSource = $appsBuffer.ToArray()
$loadedWinget = $true $loadedWinget = $true
WriteLog "AutoLoad: Winget AppList loaded with $($appsBuffer.Count) entries." WriteLog "AutoLoad: Winget AppList loaded with $($appsBuffer.Count) entries."
# Ensure Winget search/list panel is visible when apps are present
if ($null -ne $State.Controls.wingetSearchPanel) {
$State.Controls.wingetSearchPanel.Visibility = 'Visible'
}
# Update the Select All header checkbox state if present
if ($null -ne $State.Controls.chkSelectAllWingetResults -and (Get-Command -Name Update-SelectAllHeaderCheckBoxState -ErrorAction SilentlyContinue)) {
Update-SelectAllHeaderCheckBoxState -ListView $State.Controls.lstWingetResults -HeaderCheckBox $State.Controls.chkSelectAllWingetResults
}
} }
else { else {
WriteLog "AutoLoad: AppList JSON did not contain an 'apps' array." WriteLog "AutoLoad: AppList JSON did not contain an 'apps' array."
@@ -855,6 +863,25 @@ function Invoke-AutoLoadPreviousEnvironment {
} }
$loadedDrivers = $true $loadedDrivers = $true
WriteLog "AutoLoad: Loaded $($State.Data.allDriverModels.Count) driver model entries." WriteLog "AutoLoad: Loaded $($State.Data.allDriverModels.Count) driver model entries."
# Ensure driver-related panels are visible since models were auto-loaded
if ($null -ne $State.Controls.spModelFilterSection) { $State.Controls.spModelFilterSection.Visibility = 'Visible' }
if ($null -ne $State.Controls.lstDriverModels) { $State.Controls.lstDriverModels.Visibility = 'Visible' }
if ($null -ne $State.Controls.spDriverActionButtons) { $State.Controls.spDriverActionButtons.Visibility = 'Visible' }
# Optionally set Make combo to the first make represented in the loaded list (if none selected yet)
try {
if ($State.Controls.cmbMake.SelectedIndex -lt 0 -and $State.Data.allDriverModels.Count -gt 0) {
$firstMake = ($State.Data.allDriverModels | Select-Object -First 1).Make
if (-not [string]::IsNullOrWhiteSpace($firstMake)) {
$makeItem = $State.Controls.cmbMake.Items | Where-Object { $_ -eq $firstMake } | Select-Object -First 1
if ($makeItem) { $State.Controls.cmbMake.SelectedItem = $makeItem }
}
}
}
catch {
WriteLog "AutoLoad: Non-fatal error setting Make selection: $($_.Exception.Message)"
}
} }
else { else {
WriteLog "AutoLoad: Drivers JSON empty or did not contain expected structure." WriteLog "AutoLoad: Drivers JSON empty or did not contain expected structure."