Refactor USB drive configuration options and improve UI handling for related checkboxes

This commit is contained in:
rbalsleyMSFT
2025-02-15 15:26:52 -08:00
parent 931e9d13f7
commit 0669c64da1
2 changed files with 94 additions and 92 deletions
+53 -33
View File
@@ -113,14 +113,14 @@ function Get-UIConfig {
$username = $window.FindName('txtUsername').Text $username = $window.FindName('txtUsername').Text
# General Build Options (Build tab WrapPanel) # General Build Options (Build tab WrapPanel)
$buildUSB = $window.FindName('chkBuildUSBDrive').IsChecked $buildUSB = $window.FindName('chkBuildUSBDriveEnable').IsChecked
$compactOS = $window.FindName('chkCompactOS').IsChecked $compactOS = $window.FindName('chkCompactOS').IsChecked
$optimize = $window.FindName('chkOptimize').IsChecked $optimize = $window.FindName('chkOptimize').IsChecked
$allowVHDXCaching = $window.FindName('chkAllowVHDXCaching').IsChecked
$createCapture = $window.FindName('chkCreateCaptureMedia').IsChecked $createCapture = $window.FindName('chkCreateCaptureMedia').IsChecked
$createDeployMedia = $window.FindName('chkCreateDeploymentMedia').IsChecked $createDeployMedia = $window.FindName('chkCreateDeploymentMedia').IsChecked
# Build USB Drive Section (new) # Build USB Drive Section (new)
$buildUSB_USB = $window.FindName('chkBuildUSBDrive').IsChecked
$promptExt = $window.FindName('chkPromptExternalHardDiskMedia').IsChecked $promptExt = $window.FindName('chkPromptExternalHardDiskMedia').IsChecked
$allowExt = $window.FindName('chkAllowExternalHardDiskMedia').IsChecked $allowExt = $window.FindName('chkAllowExternalHardDiskMedia').IsChecked
@@ -194,7 +194,8 @@ function Get-UIConfig {
# Build configuration hashtable (unsorted) # Build configuration hashtable (unsorted)
$config = [ordered]@{ $config = [ordered]@{
AllowExternalHardDiskMedia = $allowExt AllowExternalHardDiskMedia = $allowExt
BuildUSBDrive = $buildUSB_USB AllowVHDXCaching = $allowVHDXCaching
BuildUSBDrive = $buildUSB
CompactOS = $compactOS CompactOS = $compactOS
CopyAutopilot = $copyAutopilot CopyAutopilot = $copyAutopilot
CopyOfficeConfigXML = $copyOfficeConfig CopyOfficeConfigXML = $copyOfficeConfig
@@ -209,7 +210,7 @@ function Get-UIConfig {
CleanupDrivers = $window.FindName('chkCleanupDrivers').IsChecked CleanupDrivers = $window.FindName('chkCleanupDrivers').IsChecked
Disksize = $diskSize Disksize = $diskSize
DownloadDrivers = $downloadDrivers DownloadDrivers = $downloadDrivers
EnablePromptExternalHardDiskMedia = $promptExt PromptExternalHardDiskMedia = $promptExt
FFUCaptureLocation = $ffuCaptureLocation FFUCaptureLocation = $ffuCaptureLocation
FFUDevelopmentPath = $ffuDevPath FFUDevelopmentPath = $ffuDevPath
ISOPath = $isoPath # <-- NEW: Add Windows ISO Path to config ISOPath = $isoPath # <-- NEW: Add Windows ISO Path to config
@@ -668,42 +669,54 @@ $window.Add_Loaded({
$script:chkSelectAllUSBDrives.IsChecked = $allSelected $script:chkSelectAllUSBDrives.IsChecked = $allSelected
}) })
# Add handler to show/hide USB drive controls based on Build USB Drive checkbox # Add handler to show/hide USB drive section based on Build USB Drive checkbox
$script:chkBuildUSBDrive = $window.FindName('chkBuildUSBDrive') $script:chkBuildUSBDriveEnable = $window.FindName('chkBuildUSBDriveEnable')
$script:usbPanel = ($window.FindName('btnCheckUSBDrives').Parent.Parent) # Get the outer Grid instead of immediate parent $script:usbSection = $window.FindName('usbDriveSection')
$script:usbPanel.Visibility = if ($script:chkBuildUSBDrive.IsChecked) { 'Visible' } else { 'Collapsed' } $script:chkSelectSpecificUSBDrives = $window.FindName('chkSelectSpecificUSBDrives')
$script:usbSelectionPanel = $window.FindName('usbDriveSelectionPanel')
$script:chkBuildUSBDrive.Add_Checked({ # Set initial visibility states
$script:usbPanel.Visibility = 'Visible' $script:usbSection.Visibility = if ($script:chkBuildUSBDriveEnable.IsChecked) { 'Visible' } else { 'Collapsed' }
$script:usbSelectionPanel.Visibility = if ($script:chkSelectSpecificUSBDrives.IsChecked) { 'Visible' } else { 'Collapsed' }
$script:chkBuildUSBDriveEnable.Add_Checked({
$script:usbSection.Visibility = 'Visible'
$script:chkSelectSpecificUSBDrives.IsEnabled = $true
}) })
$script:chkBuildUSBDrive.Add_Unchecked({ $script:chkBuildUSBDriveEnable.Add_Unchecked({
$script:usbSection.Visibility = 'Collapsed'
$script:chkSelectSpecificUSBDrives.IsEnabled = $false
$script:chkSelectSpecificUSBDrives.IsChecked = $false
$script:lstUSBDrives.Items.Clear() $script:lstUSBDrives.Items.Clear()
$script:chkSelectAllUSBDrives.IsChecked = $false $script:chkSelectAllUSBDrives.IsChecked = $false
$script:usbPanel.Visibility = 'Collapsed'
}) })
# Add commands for keyboard selection # Add handler to show/hide USB drive selection panel based on Select Specific USB Drives checkbox
$script:lstUSBDrives = $window.FindName('lstUSBDrives') $script:chkSelectSpecificUSBDrives.Add_Checked({
$script:lstUSBDrives.Add_KeyDown({ $script:usbSelectionPanel.Visibility = 'Visible'
param($sender, $e) })
if ($e.Key -eq 'Space') {
$selectedItem = $script:lstUSBDrives.SelectedItem $script:chkSelectSpecificUSBDrives.Add_Unchecked({
if ($selectedItem) { $script:usbSelectionPanel.Visibility = 'Collapsed'
$selectedItem.IsSelected = !$selectedItem.IsSelected $script:lstUSBDrives.Items.Clear()
# Update Select All checkbox state $script:chkSelectAllUSBDrives.IsChecked = $false
$allSelected = -not ($script:lstUSBDrives.Items | Where-Object { -not $_.IsSelected })
$script:chkSelectAllUSBDrives.IsChecked = $allSelected
}
}
}) })
# Add handler for item selection changed # Set initial state of Select Specific USB Drives checkbox
$script:lstUSBDrives.Add_SelectionChanged({ $script:chkSelectSpecificUSBDrives.IsEnabled = $script:chkBuildUSBDriveEnable.IsChecked
param($sender, $e)
# Update Select All checkbox state # Add handler for Allow External Hard Disk Media checkbox
$allSelected = -not ($script:lstUSBDrives.Items | Where-Object { -not $_.IsSelected }) $script:chkAllowExternalHardDiskMedia = $window.FindName('chkAllowExternalHardDiskMedia')
$script:chkSelectAllUSBDrives.IsChecked = $allSelected $script:chkPromptExternalHardDiskMedia = $window.FindName('chkPromptExternalHardDiskMedia')
$script:chkAllowExternalHardDiskMedia.Add_Checked({
$script:chkPromptExternalHardDiskMedia.IsEnabled = $true
})
$script:chkAllowExternalHardDiskMedia.Add_Unchecked({
$script:chkPromptExternalHardDiskMedia.IsEnabled = $false
$script:chkPromptExternalHardDiskMedia.IsChecked = $false
}) })
}) })
@@ -775,13 +788,20 @@ $btnLoadConfig.Add_Click({
$window.FindName('txtFFUCaptureLocation').Text = $configContent.FFUCaptureLocation $window.FindName('txtFFUCaptureLocation').Text = $configContent.FFUCaptureLocation
$window.FindName('txtShareName').Text = $configContent.ShareName $window.FindName('txtShareName').Text = $configContent.ShareName
$window.FindName('txtUsername').Text = $configContent.Username $window.FindName('txtUsername').Text = $configContent.Username
$window.FindName('chkBuildUSBDrive').IsChecked = $configContent.BuildUSBDrive $window.FindName('chkBuildUSBDriveEnable').IsChecked = $configContent.BuildUSBDrive
$window.FindName('chkCompactOS').IsChecked = $configContent.CompactOS $window.FindName('chkCompactOS').IsChecked = $configContent.CompactOS
$window.FindName('chkOptimize').IsChecked = $configContent.Optimize $window.FindName('chkOptimize').IsChecked = $configContent.Optimize
$window.FindName('chkPromptExternalHardDiskMedia').IsChecked = $configContent.EnablePromptExternalHardDiskMedia $window.FindName('chkAllowVHDXCaching').IsChecked = $configContent.AllowVHDXCaching
$window.FindName('chkAllowExternalHardDiskMedia').IsChecked = $configContent.AllowExternalHardDiskMedia $window.FindName('chkAllowExternalHardDiskMedia').IsChecked = $configContent.AllowExternalHardDiskMedia
$window.FindName('chkPromptExternalHardDiskMedia').IsChecked = $configContent.PromptExternalHardDiskMedia
$window.FindName('chkCreateCaptureMedia').IsChecked = $configContent.CreateCaptureMedia $window.FindName('chkCreateCaptureMedia').IsChecked = $configContent.CreateCaptureMedia
$window.FindName('chkCreateDeploymentMedia').IsChecked = $configContent.CreateDeploymentMedia $window.FindName('chkCreateDeploymentMedia').IsChecked = $configContent.CreateDeploymentMedia
# USB Drive Modification group
$window.FindName('chkCopyAutopilot').IsChecked = $configContent.CopyAutopilot
$window.FindName('chkCopyUnattend').IsChecked = $configContent.CopyUnattend
$window.FindName('chkCopyPPKG').IsChecked = $configContent.CopyPPKG
# Post Build Cleanup group # Post Build Cleanup group
$window.FindName('chkCleanupAppsISO').IsChecked = $configContent.CleanupAppsISO $window.FindName('chkCleanupAppsISO').IsChecked = $configContent.CleanupAppsISO
$window.FindName('chkCleanupCaptureISO').IsChecked = $configContent.CleanupCaptureISO $window.FindName('chkCleanupCaptureISO').IsChecked = $configContent.CleanupCaptureISO
+41 -59
View File
@@ -193,71 +193,53 @@
<!-- Row 7: General Build Options Checkboxes --> <!-- Row 7: General Build Options Checkboxes -->
<WrapPanel Grid.Row="7" Margin="0,5"> <WrapPanel Grid.Row="7" Margin="0,5">
<CheckBox x:Name="chkBuildUSBDrive" Content="Build USB Drive" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will partition and format a USB drive and copy the captured FFU to the drive."/> <CheckBox x:Name="chkBuildUSBDriveEnable" Content="Build USB Drive" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will partition and format a USB drive and copy the captured FFU to the drive."/>
<CheckBox x:Name="chkCompactOS" Content="Compact OS" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will compact the OS when building the FFU."/> <CheckBox x:Name="chkCompactOS" Content="Compact OS" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will compact the OS when building the FFU."/>
<CheckBox x:Name="chkOptimize" Content="Optimize" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will optimize during FFU build."/> <CheckBox x:Name="chkOptimize" Content="Optimize" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will optimize the OS when building the FFU."/>
<CheckBox x:Name="chkCreateCaptureMedia" Content="Create Capture Media" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will create WinPE capture media."/> <CheckBox x:Name="chkAllowVHDXCaching" Content="Allow VHDX Caching" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will cache the VHDX file to cache folder and create a config json file to track Windows build information."/>
<CheckBox x:Name="chkCreateDeploymentMedia" Content="Create Deployment Media" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will create WinPE deployment media."/> <CheckBox x:Name="chkCreateCaptureMedia" Content="Create Capture Media" Margin="5" VerticalAlignment="Center" Tag="When set to $true, this will create WinPE capture media for use when InstallApps is set to $true."/>
<CheckBox x:Name="chkCreateDeploymentMedia" Content="Create Deployment Media" Margin="5" VerticalAlignment="Center" Tag="When set to $true, this will create WinPE deployment media for use when deploying to a physical device."/>
</WrapPanel> </WrapPanel>
<!-- Row 8: Build USB Drive Section --> <!-- Row 8: Build USB Drive Section -->
<Grid Grid.Row="8" Margin="0,10,0,5" x:Name="usbDriveSection"> <StackPanel Grid.Row="8" Margin="0,10,0,5" x:Name="usbDriveSection" Visibility="Collapsed">
<Grid.RowDefinitions> <TextBlock Text="Build USB Drive Settings" FontWeight="Bold" FontSize="16" Margin="0,0,0,10"/>
<RowDefinition Height="Auto"/> <StackPanel Margin="5,0,0,10">
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Header -->
<TextBlock Grid.Row="0" Text="Build USB Drive" FontWeight="Bold" FontSize="16" Margin="0,0,0,5"/>
<!-- External Hard Disk Media Settings -->
<StackPanel Grid.Row="1" Margin="5,0,0,10">
<CheckBox x:Name="chkPromptExternalHardDiskMedia" Content="Prompt for External Hard Disk Media" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will prompt before using external hard disk media."/>
<CheckBox x:Name="chkAllowExternalHardDiskMedia" Content="Allow External Hard Disk Media" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will allow the use of external hard disk media."/> <CheckBox x:Name="chkAllowExternalHardDiskMedia" Content="Allow External Hard Disk Media" Margin="5" VerticalAlignment="Center" Tag="When set to $true, will allow the use of external hard disk media."/>
<CheckBox x:Name="chkPromptExternalHardDiskMedia" Content="Prompt for External Hard Disk Media" Margin="5,5,5,5" IsEnabled="False" VerticalAlignment="Center" Tag="When set to $true, will prompt before using external hard disk media."/>
<CheckBox x:Name="chkSelectSpecificUSBDrives" Content="Select Specific USB Drives" Margin="5" VerticalAlignment="Center" Tag="Enable to select specific USB drives for building"/>
<!-- USB Drive Selection Section -->
<Grid x:Name="usbDriveSelectionPanel" Margin="5,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Button and Select All row -->
<DockPanel Grid.Row="0" Margin="0,5" LastChildFill="False">
<Button x:Name="btnCheckUSBDrives" Content="Check USB drives" DockPanel.Dock="Left" Padding="10,5"/>
<CheckBox x:Name="chkSelectAllUSBDrives" Content="Select All" DockPanel.Dock="Left" Margin="15,0,0,0" VerticalAlignment="Center"/>
</DockPanel>
<!-- ListView row -->
<ListView x:Name="lstUSBDrives" Grid.Row="1" Margin="0,5" Height="150">
<ListView.View>
<GridView>
<GridViewColumn Header="Selected" Width="70">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Model" DisplayMemberBinding="{Binding Model}" Width="200"/>
<GridViewColumn Header="Serial Number" DisplayMemberBinding="{Binding SerialNumber}" Width="150"/>
<GridViewColumn Header="Size (GB)" DisplayMemberBinding="{Binding Size}" Width="80"/>
</GridView>
</ListView.View>
</ListView>
</Grid>
</StackPanel> </StackPanel>
</StackPanel>
<!-- USB Drive Detection -->
<Grid Grid.Row="2" Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="btnCheckUSBDrives" Content="Check USB Drives" Grid.Row="0" Grid.Column="0" Margin="5" Padding="10,5"/>
<CheckBox x:Name="chkSelectAllUSBDrives" Content="Select All" Grid.Row="0" Grid.Column="1" Margin="10,5" VerticalAlignment="Center"/>
<ListView x:Name="lstUSBDrives" Grid.Row="1" Grid.ColumnSpan="2" Height="100" Margin="5">
<ListView.View>
<GridView>
<GridViewColumn Header="Selected" Width="70">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Model" DisplayMemberBinding="{Binding Model}" Width="200"/>
<GridViewColumn Header="Serial Number" DisplayMemberBinding="{Binding SerialNumber}" Width="150"/>
<GridViewColumn Header="Size (GB)" DisplayMemberBinding="{Binding Size}" Width="80"/>
</GridView>
</ListView.View>
</ListView>
<!-- USB Drive Options -->
<StackPanel Grid.Row="2" Grid.ColumnSpan="2" Margin="5">
<TextBlock Text="USB Drive Options" FontWeight="Bold" Margin="0,5"/>
<CheckBox x:Name="chkCopyAutopilot" Content="Copy Autopilot" Margin="5" VerticalAlignment="Center" Tag="Copy Autopilot files to deployment partition."/>
<CheckBox x:Name="chkCopyUnattend" Content="Copy Unattend" Margin="5" VerticalAlignment="Center" Tag="Copy Unattend files to deployment partition."/>
<CheckBox x:Name="chkCopyPPKG" Content="Copy Provisioning Package" Margin="5" VerticalAlignment="Center" Tag="Copy PPKG files to deployment partition."/>
</StackPanel>
</Grid>
</Grid>
<!-- Row 9: Post-Build Cleanup --> <!-- Row 9: Post-Build Cleanup -->
<StackPanel Grid.Row="9" Margin="0,10,0,5"> <StackPanel Grid.Row="9" Margin="0,10,0,5">