From f44e06c57ea5e69ce4360c932e238e80263a308f Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:10:15 -0700 Subject: [PATCH] Refactor USB drive list with dynamic selection and sorting Updates the USB drive selection UI to align with other list views in the application. This change replaces the static "Select All" checkbox with a dynamic, selectable column that includes the checkbox in the header. This refactoring provides a more consistent user experience and adds column sorting functionality to the USB drive list. Additionally, the underlying shared function for creating selectable columns is improved to use the central UI state object for managing controls, removing the dependency on script-scoped variables for better encapsulation. --- FFUDevelopment/BuildFFUVM_UI.ps1 | 14 ++-- FFUDevelopment/BuildFFUVM_UI.xaml | 9 +-- .../FFUUI.Core/FFUUI.Core.Handlers.psm1 | 47 ++++++------ .../FFUUI.Core/FFUUI.Core.Initialize.psm1 | 71 +++++++++++++++++-- .../FFUUI.Core/FFUUI.Core.Shared.psm1 | 30 +++++--- 5 files changed, 117 insertions(+), 54 deletions(-) diff --git a/FFUDevelopment/BuildFFUVM_UI.ps1 b/FFUDevelopment/BuildFFUVM_UI.ps1 index 2a79b99..dbf1877 100644 --- a/FFUDevelopment/BuildFFUVM_UI.ps1 +++ b/FFUDevelopment/BuildFFUVM_UI.ps1 @@ -205,7 +205,6 @@ $window.Add_Loaded({ $script:uiState.Controls.chkSelectSpecificUSBDrives.IsEnabled = $false $script:uiState.Controls.chkSelectSpecificUSBDrives.IsChecked = $false $script:uiState.Controls.lstUSBDrives.Items.Clear() - $script:uiState.Controls.chkSelectAllUSBDrives.IsChecked = $false }) $script:uiState.Controls.chkSelectSpecificUSBDrives.Add_Checked({ $script:uiState.Controls.usbSelectionPanel.Visibility = 'Visible' @@ -213,7 +212,6 @@ $window.Add_Loaded({ $script:uiState.Controls.chkSelectSpecificUSBDrives.Add_Unchecked({ $script:uiState.Controls.usbSelectionPanel.Visibility = 'Collapsed' $script:uiState.Controls.lstUSBDrives.Items.Clear() - $script:uiState.Controls.chkSelectAllUSBDrives.IsChecked = $false }) $script:uiState.Controls.chkSelectSpecificUSBDrives.IsEnabled = $script:uiState.Controls.chkBuildUSBDriveEnable.IsChecked $script:uiState.Controls.chkAllowExternalHardDiskMedia.Add_Checked({ @@ -961,8 +959,8 @@ $btnLoadConfig.Add_Click({ # Update the ListView's ItemsSource after populating the data list $lstAppsScriptVars.ItemsSource = $script:uiState.Data.appsScriptVariablesDataList.ToArray() # Update the header checkbox state - if ($null -ne (Get-Variable -Name 'chkSelectAllAppsScriptVariables' -Scope Script -ErrorAction SilentlyContinue)) { - Update-SelectAllHeaderCheckBoxState -ListView $lstAppsScriptVars -HeaderCheckBox $script:chkSelectAllAppsScriptVariables + if ($null -ne $script:uiState.Controls.chkSelectAllAppsScriptVariables) { + Update-SelectAllHeaderCheckBoxState -ListView $lstAppsScriptVars -HeaderCheckBox $script:uiState.Controls.chkSelectAllAppsScriptVariables } # Update USB Drive selection if present in config @@ -1016,9 +1014,11 @@ $btnLoadConfig.Add_Click({ } $script:uiState.Controls.lstUSBDrives.Items.Refresh() - # Update the Select All checkbox state - $allSelected = $script:uiState.Controls.lstUSBDrives.Items.Count -gt 0 -and -not ($script:uiState.Controls.lstUSBDrives.Items | Where-Object { -not $_.IsSelected }) - $script:uiState.Controls.chkSelectAllUSBDrives.IsChecked = $allSelected + # Update the Select All header checkbox state + $headerChk = $script:uiState.Controls.chkSelectAllUSBDrivesHeader + if ($null -ne $headerChk) { + Update-SelectAllHeaderCheckBoxState -ListView $script:uiState.Controls.lstUSBDrives -HeaderCheckBox $headerChk + } WriteLog "LoadConfig: USBDriveList processing complete." } else { diff --git a/FFUDevelopment/BuildFFUVM_UI.xaml b/FFUDevelopment/BuildFFUVM_UI.xaml index 335014d..626c140 100644 --- a/FFUDevelopment/BuildFFUVM_UI.xaml +++ b/FFUDevelopment/BuildFFUVM_UI.xaml @@ -198,19 +198,12 @@