From d05f9aa267e146f3f916939ac0dde676c2a2d8c9 Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Mon, 26 May 2025 17:59:28 -0700 Subject: [PATCH] Enhance USB drive selection logic in LoadConfig process - Added functionality to automatically check "Select Specific USB Drives" if USBDriveList is present and not empty in the configuration. - Implemented checks for both PSCustomObject and hashtable types for backward compatibility. - Included logging for the auto-check condition to improve traceability during configuration loading. --- FFUDevelopment/BuildFFUVM_UI.ps1 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/FFUDevelopment/BuildFFUVM_UI.ps1 b/FFUDevelopment/BuildFFUVM_UI.ps1 index 3c75744..17e6a84 100644 --- a/FFUDevelopment/BuildFFUVM_UI.ps1 +++ b/FFUDevelopment/BuildFFUVM_UI.ps1 @@ -2836,6 +2836,30 @@ $btnLoadConfig.Add_Click({ } else { WriteLog "LoadConfig Info: Key 'USBDriveList' not found or is null in configuration file. Skipping USB drive selection." } + + # If BuildUSBDrive is enabled and USBDriveList was present and not empty in the config, + # ensure "Select Specific USB Drives" is checked to show the list. + $shouldAutoCheckSpecificDrives = $false + if ($window.FindName('chkBuildUSBDriveEnable').IsChecked -and $usbDriveListKeyExists -and ($null -ne $configContent.USBDriveList)) { + if ($configContent.USBDriveList -is [System.Management.Automation.PSCustomObject]) { + if ($configContent.USBDriveList.PSObject.Properties.Count -gt 0) { + $shouldAutoCheckSpecificDrives = $true + } + } + elseif ($configContent.USBDriveList -is [hashtable]) { # Fallback for older configs + if ($configContent.USBDriveList.Keys.Count -gt 0) { + $shouldAutoCheckSpecificDrives = $true + } + } + } + + if ($shouldAutoCheckSpecificDrives) { + WriteLog "LoadConfig: Auto-checking 'Select Specific USB Drives' due to pre-selected USB drives in config." + $window.FindName('chkSelectSpecificUSBDrives').IsChecked = $true + } + else { + WriteLog "LoadConfig: Condition to auto-check 'Select Specific USB Drives' was NOT met." + } WriteLog "LoadConfig: Configuration loading process finished." } }