mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Add Drivers.json path configuration to UI and core logic
- Introduced a new TextBox and Button in the UI for specifying the Drivers.json file path. - Updated the UI layout to accommodate the new Drivers.json path input. - Enhanced the core logic to set a default path for Drivers.json based on the Drivers folder. - Implemented functionality to browse and select the Drivers.json file, allowing users to create or select an existing file.
This commit is contained in:
@@ -614,7 +614,7 @@ function Get-UIConfig {
|
||||
Disksize = [int64]$window.FindName('txtDiskSize').Text * 1GB # Renamed from DiskSize
|
||||
DownloadDrivers = $window.FindName('chkDownloadDrivers').IsChecked # UI Only parameter
|
||||
DriversFolder = $window.FindName('txtDriversFolder').Text
|
||||
DriversJsonPath = "$($window.FindName('txtDriversFolder').Text)\Drivers.json" # Parameter from Sample_default.json, derived
|
||||
DriversJsonPath = $script:txtDriversJsonPath.Text # Read from the new TextBox
|
||||
FFUCaptureLocation = $window.FindName('txtFFUCaptureLocation').Text
|
||||
FFUDevelopmentPath = $window.FindName('txtFFUDevPath').Text
|
||||
FFUPrefix = $window.FindName('txtVMNamePrefix').Text
|
||||
@@ -1810,6 +1810,9 @@ $window.Add_Loaded({
|
||||
# Drivers tab defaults from General Defaults
|
||||
$window.FindName('txtDriversFolder').Text = $script:generalDefaults.DriversFolder
|
||||
$window.FindName('txtPEDriversFolder').Text = $script:generalDefaults.PEDriversFolder
|
||||
$script:txtDriversJsonPath = $window.FindName('txtDriversJsonPath') # Assign new TextBox
|
||||
$script:txtDriversJsonPath.Text = $script:generalDefaults.DriversJsonPath # Set default text
|
||||
$script:btnBrowseDriversJsonPath = $window.FindName('btnBrowseDriversJsonPath') # Assign new Button
|
||||
$window.FindName('chkDownloadDrivers').IsChecked = $script:generalDefaults.DownloadDrivers
|
||||
$window.FindName('chkInstallDrivers').IsChecked = $script:generalDefaults.InstallDrivers
|
||||
$window.FindName('chkCopyDrivers').IsChecked = $script:generalDefaults.CopyDrivers
|
||||
@@ -2608,6 +2611,36 @@ $script:chkInstallApps.Add_Unchecked({
|
||||
$selectedPath = Show-ModernFolderPicker -Title "Select PE Drivers Folder"
|
||||
if ($selectedPath) { $window.FindName('txtPEDriversFolder').Text = $selectedPath }
|
||||
})
|
||||
$script:btnBrowseDriversJsonPath.Add_Click({
|
||||
$sfd = New-Object System.Windows.Forms.SaveFileDialog
|
||||
$sfd.Filter = "JSON files (*.json)|*.json|All files (*.*)|*.*"
|
||||
$sfd.Title = "Select or Create Drivers.json File"
|
||||
$sfd.FileName = "Drivers.json"
|
||||
$sfd.CheckFileExists = $false # Allow creating a new file or selecting existing
|
||||
|
||||
# Set initial directory based on current TextBox value or DriversFolder default
|
||||
$currentDriversJsonPath = $script:txtDriversJsonPath.Text
|
||||
$initialDirectory = $null
|
||||
if (-not [string]::IsNullOrWhiteSpace($currentDriversJsonPath) -and (Split-Path -Path $currentDriversJsonPath -IsValid)) {
|
||||
$initialDirectory = Split-Path -Path $currentDriversJsonPath -Parent
|
||||
if (-not (Test-Path -Path $initialDirectory -PathType Container)) {
|
||||
# If parent of current path doesn't exist, fall back
|
||||
$initialDirectory = $script:generalDefaults.DriversFolder
|
||||
}
|
||||
}
|
||||
else {
|
||||
$initialDirectory = $script:generalDefaults.DriversFolder
|
||||
}
|
||||
# Ensure the fallback directory exists, otherwise use FFUDevelopmentPath
|
||||
if (-not (Test-Path -Path $initialDirectory -PathType Container)) {
|
||||
$initialDirectory = $window.FindName('txtFFUDevPath').Text # Fallback to FFU Dev Path
|
||||
}
|
||||
$sfd.InitialDirectory = $initialDirectory
|
||||
|
||||
if ($sfd.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
|
||||
$script:txtDriversJsonPath.Text = $sfd.FileName
|
||||
}
|
||||
})
|
||||
|
||||
# Driver Checkbox Conditional Logic
|
||||
$script:chkInstallDrivers.Add_Checked({
|
||||
@@ -3098,6 +3131,7 @@ $btnLoadConfig.Add_Click({
|
||||
# WriteLog "LoadConfig Info: 'Model' key ('$($configContent.Model)') from config is not directly mapped to a single UI input. Set 'Make' and use 'Get Models'."
|
||||
Set-UIValue -ControlName 'txtDriversFolder' -PropertyName 'Text' -ConfigObject $configContent -ConfigKey 'DriversFolder' -WindowInstance $window
|
||||
Set-UIValue -ControlName 'txtPEDriversFolder' -PropertyName 'Text' -ConfigObject $configContent -ConfigKey 'PEDriversFolder' -WindowInstance $window
|
||||
Set-UIValue -ControlName 'txtDriversJsonPath' -PropertyName 'Text' -ConfigObject $configContent -ConfigKey 'DriversJsonPath' -WindowInstance $window # Load DriversJsonPath
|
||||
Set-UIValue -ControlName 'chkCopyPEDrivers' -PropertyName 'IsChecked' -ConfigObject $configContent -ConfigKey 'CopyPEDrivers' -WindowInstance $window
|
||||
Set-UIValue -ControlName 'chkCompressDriversToWIM' -PropertyName 'IsChecked' -ConfigObject $configContent -ConfigKey 'CompressDownloadedDriversToWim' -WindowInstance $window
|
||||
|
||||
|
||||
@@ -679,6 +679,8 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<!-- PE Drivers Folder -->
|
||||
<RowDefinition Height="Auto"/>
|
||||
<!-- Drivers.json Path -->
|
||||
<RowDefinition Height="Auto"/>
|
||||
<!-- Download Drivers Checkbox -->
|
||||
<RowDefinition Height="Auto"/>
|
||||
<!-- Make Section (Indented) -->
|
||||
@@ -695,9 +697,9 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<!-- Copy Drivers to USB -->
|
||||
<RowDefinition Height="Auto"/>
|
||||
<!-- Copy PE Drivers Checkbox -->
|
||||
<!-- Compress Driver Model Folder to WIM -->
|
||||
<RowDefinition Height="*"/>
|
||||
<!-- Spacer/Remaining -->
|
||||
<!-- Copy PE Drivers Checkbox & Spacer/Remaining -->
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@@ -730,23 +732,36 @@
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Row 2: Download Drivers Checkbox -->
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="5">
|
||||
<!-- Row 2: Drivers.json Path -->
|
||||
<StackPanel Grid.Row="2" Margin="5">
|
||||
<TextBlock Text="Drivers.json Path:" VerticalAlignment="Center" ToolTip="Path to the Drivers.json file. Default is $FFUDevelopmentPath\Drivers\Drivers.json." Margin="0,0,0,5"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="txtDriversJsonPath" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Stretch" ToolTip="Path to the Drivers.json file. Default is $FFUDevelopmentPath\Drivers\Drivers.json."/>
|
||||
<Button x:Name="btnBrowseDriversJsonPath" Grid.Column="1" Content="Browse..." Width="80" Margin="5,0,0,0" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Row 3: Download Drivers Checkbox -->
|
||||
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="5">
|
||||
<CheckBox x:Name="chkDownloadDrivers" Content="Download Drivers" Margin="0,0,5,0" ToolTip="Download the drivers and put them in the Drivers folder."/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Row 3: Make Section (Indented) -->
|
||||
<StackPanel x:Name="spMakeSection" Grid.Row="3" Visibility="Collapsed" Margin="25,5,5,0">
|
||||
<!-- Row 4: Make Section (Indented) -->
|
||||
<StackPanel x:Name="spMakeSection" Grid.Row="4" Visibility="Collapsed" Margin="25,5,5,0">
|
||||
<TextBlock Text="Make:" Margin="0,0,0,5" ToolTip="Make of the device to download drivers. Accepted values are: 'Microsoft', 'Dell', 'HP', 'Lenovo'."/>
|
||||
<ComboBox x:Name="cmbMake" Margin="0,0,0,5" HorizontalAlignment="Left" Width="200"/>
|
||||
<!-- Model TextBox is removed from here, filtering will be done below -->
|
||||
</StackPanel>
|
||||
|
||||
<!-- Row 4: Get Models Button (Indented) -->
|
||||
<Button x:Name="btnGetModels" Grid.Row="4" Content="Get Models" Width="150" Margin="25,5,5,10" HorizontalAlignment="Left" ToolTip="Retrieve available models for the selected Make." Visibility="Collapsed" Padding="10,5"/>
|
||||
<!-- Row 5: Get Models Button (Indented) -->
|
||||
<Button x:Name="btnGetModels" Grid.Row="5" Content="Get Models" Width="150" Margin="25,5,5,10" HorizontalAlignment="Left" ToolTip="Retrieve available models for the selected Make." Visibility="Collapsed" Padding="10,5"/>
|
||||
|
||||
<!-- Row 5: Model Filter Section (Indented) -->
|
||||
<StackPanel x:Name="spModelFilterSection" Grid.Row="5" Visibility="Collapsed" Margin="25,5,5,0">
|
||||
<!-- Row 6: Model Filter Section (Indented) -->
|
||||
<StackPanel x:Name="spModelFilterSection" Grid.Row="6" Visibility="Collapsed" Margin="25,5,5,0">
|
||||
<TextBlock Text="Model Filter" FontWeight="Bold" Margin="0,0,0,5"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -758,35 +773,35 @@
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Row 6: Driver Models ListView (Indented) -->
|
||||
<ListView x:Name="lstDriverModels" Grid.Row="6" Margin="25,0,5,5" Height="300" Visibility="Collapsed" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto">
|
||||
<!-- Row 7: Driver Models ListView (Indented) -->
|
||||
<ListView x:Name="lstDriverModels" Grid.Row="7" Margin="25,0,5,5" Height="300" Visibility="Collapsed" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto">
|
||||
</ListView>
|
||||
|
||||
<!-- Row 7: Driver Action Buttons (Indented) -->
|
||||
<StackPanel x:Name="spDriverActionButtons" Grid.Row="7" Orientation="Horizontal" HorizontalAlignment="Left" Margin="25,5,5,10" Visibility="Collapsed">
|
||||
<!-- Row 8: Driver Action Buttons (Indented) -->
|
||||
<StackPanel x:Name="spDriverActionButtons" Grid.Row="8" Orientation="Horizontal" HorizontalAlignment="Left" Margin="25,5,5,10" Visibility="Collapsed">
|
||||
<Button x:Name="btnSaveDriversJson" Content="Save Drivers.json" Padding="15,5" Margin="0,0,10,0" ToolTip="Save selected drivers to a JSON file (Not Implemented)"/>
|
||||
<Button x:Name="btnImportDriversJson" Content="Import Drivers.json" Padding="15,5" Margin="0,0,10,0" ToolTip="Import drivers from a JSON file (Not Implemented)"/>
|
||||
<Button x:Name="btnDownloadSelectedDrivers" Content="Download Selected" Padding="15,5" Margin="0,0,10,0" ToolTip="Download all selected drivers"/>
|
||||
<Button x:Name="btnClearDriverList" Content="Clear List" Padding="15,5" ToolTip="Clear all drivers from the list (Not Implemented)"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Row 8: Install Drivers to FFU -->
|
||||
<StackPanel Grid.Row="8" Orientation="Horizontal" Margin="5">
|
||||
<!-- Row 9: Install Drivers to FFU -->
|
||||
<StackPanel Grid.Row="9" Orientation="Horizontal" Margin="5">
|
||||
<CheckBox x:Name="chkInstallDrivers" Content="Install Drivers to FFU" Margin="0,0,5,0" ToolTip="Install device drivers from the specified $FFUDevelopmentPath\Drivers folder if set to $true. Download the drivers and put them in the Drivers folder. The script will recurse the drivers folder and add the drivers to the FFU."/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Row 9: Copy Drivers to USB -->
|
||||
<StackPanel Grid.Row="9" Orientation="Horizontal" Margin="5">
|
||||
<!-- Row 10: Copy Drivers to USB -->
|
||||
<StackPanel Grid.Row="10" Orientation="Horizontal" Margin="5">
|
||||
<CheckBox x:Name="chkCopyDrivers" Content="Copy Drivers to USB drive" Margin="0,0,5,0" ToolTip="When set to $true, will copy the drivers from the $FFUDevelopmentPath\Drivers folder to the Drivers folder on the deploy partition of the USB drive. Default is $false."/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Row 10: Compress Driver Model Folder to WIM -->
|
||||
<StackPanel Grid.Row="10" Orientation="Horizontal" Margin="5">
|
||||
<!-- Row 11: Compress Driver Model Folder to WIM -->
|
||||
<StackPanel Grid.Row="11" Orientation="Horizontal" Margin="5">
|
||||
<CheckBox x:Name="chkCompressDriversToWIM" Content="Compress Driver Model Folder to WIM" Margin="0,0,5,0" ToolTip="When set to $true, will compress each downloaded driver model folder into a separate WIM file within the Drivers folder. This is useful with Copy Drivers to USB drive."/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Row 11: Copy PE Drivers Checkbox -->
|
||||
<StackPanel Grid.Row="11" Orientation="Horizontal" Margin="5">
|
||||
<!-- Row 12: Copy PE Drivers Checkbox -->
|
||||
<StackPanel Grid.Row="12" Orientation="Horizontal" Margin="5">
|
||||
<CheckBox x:Name="chkCopyPEDrivers" Content="Copy PE Drivers" Margin="0,0,5,0" ToolTip="When set to $true, will copy the drivers from the $FFUDevelopmentPath\PEDrivers folder to the WinPE deployment media. Default is $false."/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -325,6 +325,7 @@ function Get-GeneralDefaults {
|
||||
# Drivers Tab Defaults
|
||||
DriversFolder = $driversPath
|
||||
PEDriversFolder = $peDriversPath
|
||||
DriversJsonPath = Join-Path -Path $driversPath -ChildPath "Drivers.json"
|
||||
DownloadDrivers = $false
|
||||
InstallDrivers = $false
|
||||
CopyDrivers = $false
|
||||
|
||||
Reference in New Issue
Block a user