Updates to the UI

This commit is contained in:
rbalsleyMSFT
2024-12-30 23:30:44 -08:00
committed by rbalsleyMSFT
parent e209251d0b
commit eb3212ee2d
2 changed files with 95 additions and 47 deletions
+35 -8
View File
@@ -2,10 +2,8 @@
[System.STAThread()] [System.STAThread()]
param() param()
# Define FFUDevelopmentPath early # Define FFUDevelopmentPath using $PSScriptRoot
if (-not $FFUDevelopmentPath) { $FFUDevelopmentPath = $PSScriptRoot
$FFUDevelopmentPath = "C:\FFUDevelopment"
}
Add-Type -AssemblyName WindowsBase Add-Type -AssemblyName WindowsBase
Add-Type -AssemblyName PresentationCore,PresentationFramework Add-Type -AssemblyName PresentationCore,PresentationFramework
@@ -84,15 +82,14 @@ $imageNames = @(
"imgInstallOfficeInfo", "imgInstallOfficeInfo",
"imgInstallAppsInfo", "imgInstallAppsInfo",
"imgInstallDriversInfo", "imgInstallDriversInfo",
"imgCopyDriversInfo" # Added Image control for Copy Drivers "imgCopyDriversInfo",
# Add any other Image control names here "imgFFUDevPathInfo"
) )
# Set the Source for each Image control # Set the Source for each Image control
foreach ($imgName in $imageNames) { foreach ($imgName in $imageNames) {
Set-ImageSource -window $window -imageName $imgName -sourcePath $infoImagePath Set-ImageSource -window $window -imageName $imgName -sourcePath $infoImagePath
} }
# Optional: Add logging for debugging purposes # Optional: Add logging for debugging purposes
# Uncomment the following lines to enable debug output # Uncomment the following lines to enable debug output
# Write-Host "Extracted SKU List: $skuList" # Write-Host "Extracted SKU List: $skuList"
@@ -108,6 +105,7 @@ $runScriptHandler = {
$txtStatus.Text = "Starting FFU build..." $txtStatus.Text = "Starting FFU build..."
# Gather user inputs from controls # Gather user inputs from controls
$ffuDevPath = $window.FindName('txtFFUDevPath').Text
$customFFUNameTemplate = $window.FindName('txtFFUName').Text $customFFUNameTemplate = $window.FindName('txtFFUName').Text
$isoPath = $window.FindName('txtISOPath').Text $isoPath = $window.FindName('txtISOPath').Text
$windowsSKU = $cmbWindowsSKU.SelectedItem $windowsSKU = $cmbWindowsSKU.SelectedItem
@@ -142,9 +140,13 @@ $runScriptHandler = {
if ($downloadDrivers -and (-not $model)) { if ($downloadDrivers -and (-not $model)) {
throw "Model is required when Download Drivers is checked." throw "Model is required when Download Drivers is checked."
} }
if (-not $ffuDevPath) {
throw "FFU Development Path is required."
}
# Create config object # Create config object
$config = @{ $config = @{
FFUDevelopmentPath = $ffuDevPath
CustomFFUNameTemplate = $customFFUNameTemplate CustomFFUNameTemplate = $customFFUNameTemplate
ISOPath = $isoPath ISOPath = $isoPath
WindowsSKU = $windowsSKU WindowsSKU = $windowsSKU
@@ -209,6 +211,19 @@ $btnBrowseISO.Add_Click({
} }
}) })
$btnBrowseFFUDevPath = $window.FindName('btnBrowseFFUDevPath')
$btnBrowseFFUDevPath.Add_Click({
$folderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
$folderBrowser.Description = "Select FFU Development Folder"
$folderBrowser.SelectedPath = $window.FindName('txtFFUDevPath').Text # Set initial path
if ($folderBrowser.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
$window.FindName('txtFFUDevPath').Text = $folderBrowser.SelectedPath
}
})
# Assign FFUDevelopmentPath to the TextBox
$window.FindName('txtFFUDevPath').Text = $FFUDevelopmentPath
# Bind the Browse buttons for Drivers folders # Bind the Browse buttons for Drivers folders
$btnBrowseDriversFolder = $window.FindName('btnBrowseDriversFolder') $btnBrowseDriversFolder = $window.FindName('btnBrowseDriversFolder')
$btnBrowseDriversFolder.Add_Click({ $btnBrowseDriversFolder.Add_Click({
@@ -252,6 +267,7 @@ $btnBuildConfig.Add_Click({
$savePath = $saveFileDialog.FileName $savePath = $saveFileDialog.FileName
# Gather current configuration from UI controls using $window.FindName # Gather current configuration from UI controls using $window.FindName
$ffuDevPath = ($window.FindName('txtFFUDevPath')).Text
$windowsSKU = ($window.FindName('cmbWindowsSKU')).SelectedItem $windowsSKU = ($window.FindName('cmbWindowsSKU')).SelectedItem
if (-not $windowsSKU) { if (-not $windowsSKU) {
throw "Windows SKU is not selected." throw "Windows SKU is not selected."
@@ -276,7 +292,7 @@ $btnBuildConfig.Add_Click({
$copyDrivers = ($window.FindName('chkCopyDrivers')).IsChecked $copyDrivers = ($window.FindName('chkCopyDrivers')).IsChecked
$downloadDrivers = ($window.FindName('chkDownloadDrivers')).IsChecked $downloadDrivers = ($window.FindName('chkDownloadDrivers')).IsChecked
$make = ($window.FindName('cmbMake')).SelectedItem $make = ($window.FindName('cmbMake')).SelectedItem
$model = ($window.FindName('cmbModel')).Text # Changed from SelectedItem $model = ($window.FindName('txtModel')).Text # Changed from SelectedItem
$driversFolder = ($window.FindName('txtDriversFolder')).Text $driversFolder = ($window.FindName('txtDriversFolder')).Text
$peDriversFolder = ($window.FindName('txtPEDriversFolder')).Text $peDriversFolder = ($window.FindName('txtPEDriversFolder')).Text
@@ -296,8 +312,12 @@ $btnBuildConfig.Add_Click({
if ($downloadDrivers -and (-not $model)) { if ($downloadDrivers -and (-not $model)) {
throw "Model is required when Download Drivers is checked." throw "Model is required when Download Drivers is checked."
} }
if (-not $ffuDevPath) {
throw "FFU Development Path is required."
}
$config = @{ $config = @{
FFUDevelopmentPath = $ffuDevPath
CustomFFUNameTemplate = ($window.FindName('txtFFUName')).Text CustomFFUNameTemplate = ($window.FindName('txtFFUName')).Text
ISOPath = ($window.FindName('txtISOPath')).Text ISOPath = ($window.FindName('txtISOPath')).Text
WindowsSKU = $windowsSKU WindowsSKU = $windowsSKU
@@ -530,6 +550,13 @@ $window.Add_Loaded({
$script:chkCopyDrivers.Add_Unchecked({ $script:chkCopyDrivers.Add_Unchecked({
$script:chkInstallDrivers.IsEnabled = $true $script:chkInstallDrivers.IsEnabled = $true
}) })
# Assign FFUDevelopmentPath to the TextBox
$window.FindName('txtFFUDevPath').Text = $FFUDevelopmentPath
# Set default values for Drivers Folder and PE Drivers Folder
$window.FindName('txtDriversFolder').Text = Join-Path -Path $FFUDevelopmentPath -ChildPath "Drivers"
$window.FindName('txtPEDriversFolder').Text = Join-Path -Path $FFUDevelopmentPath -ChildPath "PEDrivers"
}) })
# Show the window # Show the window
+60 -39
View File
@@ -26,14 +26,15 @@
<Grid Margin="10"> <Grid Margin="10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <!-- Row 0: FFU Name --> <RowDefinition Height="Auto"/> <!-- Row 0: FFU Name -->
<RowDefinition Height="Auto"/> <!-- Row 1: ISO Path --> <RowDefinition Height="Auto"/> <!-- Row 1: FFU Development Path -->
<RowDefinition Height="Auto"/> <!-- Row 2: Windows SKU --> <RowDefinition Height="Auto"/> <!-- Row 2: ISO Path -->
<RowDefinition Height="Auto"/> <!-- Row 3: VM Switch Name --> <RowDefinition Height="Auto"/> <!-- Row 3: Windows SKU -->
<RowDefinition Height="Auto"/> <!-- Row 4: Custom VM Switch Name --> <RowDefinition Height="Auto"/> <!-- Row 4: VM Switch Name -->
<RowDefinition Height="Auto"/> <!-- Row 5: VM Host IP Address --> <RowDefinition Height="Auto"/> <!-- Row 5: Custom VM Switch Name -->
<RowDefinition Height="Auto"/> <!-- Row 6: VM Host IP Address -->
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/> <ColumnDefinition Width="200"/> <!-- Increased from 150 to 200 for longer TextBlock -->
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@@ -46,15 +47,35 @@
</StackPanel> </StackPanel>
<TextBox x:Name="txtFFUName" Grid.Row="0" Grid.Column="1" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Stretch"/> <TextBox x:Name="txtFFUName" Grid.Row="0" Grid.Column="1" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>
<!-- ISO Path --> <!-- FFU Development Path -->
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5"> <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5">
<TextBlock Text="FFU Development Path:"/>
<Image x:Name="imgFFUDevPathInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow"
Focusable="True"
ToolTip="Defaults to the location the script is run from. It's unlikely this will need to be changed." />
</StackPanel>
<Grid Grid.Row="1" Grid.Column="1" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/> <!-- Reduced width for TextBox -->
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <!-- Added Column for info image -->
</Grid.ColumnDefinitions>
<TextBox x:Name="txtFFUDevPath" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Stretch" />
<Button x:Name="btnBrowseFFUDevPath" Grid.Column="1" Content="Browse..." Width="80" Margin="5,0,0,0" VerticalAlignment="Center" ToolTip="Browse for FFU Development folder."/>
<Image x:Name="imgFFUDevPathInfoExtra" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow"
Focusable="True"
ToolTip="Defaults to the location the script is run from. It's unlikely this will need to be changed." />
</Grid>
<!-- ISO Path -->
<StackPanel Grid.Row="2" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5">
<TextBlock Text="ISO Path:"/> <TextBlock Text="ISO Path:"/>
<Image x:Name="imgISOPathInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow" <Image x:Name="imgISOPathInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow"
Focusable="True" Focusable="True"
ToolTip="Specify the full path to the Windows ISO file you wish to use." /> ToolTip="Specify the full path to the Windows ISO file you wish to use." />
</StackPanel> </StackPanel>
<!-- Replace StackPanel with Grid for better alignment --> <!-- Replace StackPanel with Grid for better alignment -->
<Grid Grid.Row="1" Grid.Column="1" Margin="5"> <Grid Grid.Row="2" Grid.Column="1" Margin="5">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@@ -64,38 +85,38 @@
</Grid> </Grid>
<!-- Windows SKU --> <!-- Windows SKU -->
<StackPanel Grid.Row="2" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5"> <StackPanel Grid.Row="3" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5">
<TextBlock Text="Windows SKU:"/> <TextBlock Text="Windows SKU:"/>
<Image x:Name="imgWindowsSKUInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow" <Image x:Name="imgWindowsSKUInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow"
Focusable="True" Focusable="True"
ToolTip="Select the edition of Windows you want to install (e.g., Pro, Enterprise)." /> ToolTip="Select the edition of Windows you want to install (e.g., Pro, Enterprise)." />
</StackPanel> </StackPanel>
<ComboBox x:Name="cmbWindowsSKU" Grid.Row="2" Grid.Column="1" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Stretch"/> <ComboBox x:Name="cmbWindowsSKU" Grid.Row="3" Grid.Column="1" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>
<!-- VM Switch Name --> <!-- VM Switch Name -->
<StackPanel Grid.Row="3" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5"> <StackPanel Grid.Row="4" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5">
<TextBlock Text="VM Switch Name:"/> <TextBlock Text="VM Switch Name:"/>
<Image x:Name="imgVMSwitchNameInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow" <Image x:Name="imgVMSwitchNameInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow"
Focusable="True" Focusable="True"
ToolTip="Enter the name of the Hyper-V virtual switch to be used for the VM." /> ToolTip="Enter the name of the Hyper-V virtual switch to be used for the VM." />
</StackPanel> </StackPanel>
<!-- Replace TextBox with ComboBox for listing VM Switches --> <!-- Replace TextBox with ComboBox for listing VM Switches -->
<ComboBox x:Name="cmbVMSwitchName" Grid.Row="3" Grid.Column="1" Margin="5" <ComboBox x:Name="cmbVMSwitchName" Grid.Row="4" Grid.Column="1" Margin="5"
VerticalAlignment="Center" HorizontalAlignment="Stretch" /> VerticalAlignment="Center" HorizontalAlignment="Stretch" />
<!-- Add a new TextBox for custom VM Switch Name, initially hidden --> <!-- Add a new TextBox for custom VM Switch Name, initially hidden -->
<TextBox x:Name="txtCustomVMSwitchName" Grid.Row="4" Grid.Column="1" Margin="5" <TextBox x:Name="txtCustomVMSwitchName" Grid.Row="5" Grid.Column="1" Margin="5"
VerticalAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Center" HorizontalAlignment="Stretch"
Visibility="Collapsed" Visibility="Collapsed"
ToolTip="Enter your custom VM Switch Name." /> ToolTip="Enter your custom VM Switch Name." />
<!-- VM Host IP Address --> <!-- VM Host IP Address -->
<StackPanel Grid.Row="5" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5"> <StackPanel Grid.Row="6" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5">
<TextBlock Text="VM Host IP Address:"/> <TextBlock Text="VM Host IP Address:"/>
<Image x:Name="imgVMHostIPAddressInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow" <Image x:Name="imgVMHostIPAddressInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow"
Focusable="True" Focusable="True"
ToolTip="Provide the IP address of the Hyper-V host machine." /> ToolTip="Provide the IP address of the Hyper-V host machine." />
</StackPanel> </StackPanel>
<TextBox x:Name="txtVMHostIPAddress" Grid.Row="5" Grid.Column="1" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Stretch"/> <TextBox x:Name="txtVMHostIPAddress" Grid.Row="6" Grid.Column="1" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="Applications" Padding="20"> <TabItem Header="Applications" Padding="20">
@@ -134,9 +155,9 @@
<RowDefinition Height="Auto"/> <!-- Row 1: Copy Drivers --> <RowDefinition Height="Auto"/> <!-- Row 1: Copy Drivers -->
<RowDefinition Height="Auto"/> <!-- Row 2: Download Drivers --> <RowDefinition Height="Auto"/> <!-- Row 2: Download Drivers -->
<RowDefinition Height="Auto"/> <!-- Row 3: Make/Model --> <RowDefinition Height="Auto"/> <!-- Row 3: Make/Model -->
<RowDefinition Height="Auto"/> <!-- Row 4: PEDrivers Folder --> <RowDefinition Height="Auto"/> <!-- Row 4: Drivers Folder -->
<RowDefinition Height="Auto"/> <!-- Row 5: Drivers Folder --> <RowDefinition Height="Auto"/> <!-- Row 5: Copy PE Drivers -->
<RowDefinition Height="Auto"/> <!-- Row 6: Copy PE Drivers --> <RowDefinition Height="Auto"/> <!-- Row 6: PE Drivers Folder -->
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/> <ColumnDefinition Width="150"/>
@@ -167,7 +188,7 @@
ToolTip="Check to download drivers automatically." /> ToolTip="Check to download drivers automatically." />
</StackPanel> </StackPanel>
<!-- New container for Make & Model fields --> <!-- Make & Model Section -->
<StackPanel Grid.Row="3" Grid.ColumnSpan="2" x:Name="spMakeModelSection" Visibility="Collapsed" Margin="0"> <StackPanel Grid.Row="3" Grid.ColumnSpan="2" x:Name="spMakeModelSection" Visibility="Collapsed" Margin="0">
<Grid Margin="0"> <Grid Margin="0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -199,30 +220,14 @@
</Grid> </Grid>
</StackPanel> </StackPanel>
<!-- PE Drivers Folder (Row 4) --> <!-- Drivers Folder -->
<StackPanel Grid.Row="4" Grid.Column="0" Orientation="Horizontal" Margin="5"> <StackPanel Grid.Row="4" Grid.Column="0" Orientation="Horizontal" Margin="5">
<TextBlock Text="PE Drivers Folder:" VerticalAlignment="Center"/>
<Image x:Name="imgPEDriversFolderInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow"
Focusable="True"
ToolTip="Specify the path to the PE Drivers folder." />
</StackPanel>
<Grid Grid.Row="4" Grid.Column="1" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox x:Name="txtPEDriversFolder" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Stretch" />
<Button x:Name="btnBrowsePEDrivers" Grid.Column="1" Content="Browse..." Width="80" Margin="5,0,0,0" VerticalAlignment="Center" ToolTip="Browse for PE Drivers folder."/>
</Grid>
<!-- Drivers Folder (Row 5) -->
<StackPanel Grid.Row="5" Grid.Column="0" Orientation="Horizontal" Margin="5">
<TextBlock Text="Drivers Folder:" VerticalAlignment="Center"/> <TextBlock Text="Drivers Folder:" VerticalAlignment="Center"/>
<Image x:Name="imgDriversFolderInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow" <Image x:Name="imgDriversFolderInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow"
Focusable="True" Focusable="True"
ToolTip="Specify the path to the Drivers folder." /> ToolTip="Specify the path to the Drivers folder." />
</StackPanel> </StackPanel>
<Grid Grid.Row="5" Grid.Column="1" Margin="5"> <Grid Grid.Row="4" Grid.Column="1" Margin="5">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@@ -231,12 +236,28 @@
<Button x:Name="btnBrowseDriversFolder" Grid.Column="1" Content="Browse..." Width="80" Margin="5,0,0,0" VerticalAlignment="Center" ToolTip="Browse for Drivers folder."/> <Button x:Name="btnBrowseDriversFolder" Grid.Column="1" Content="Browse..." Width="80" Margin="5,0,0,0" VerticalAlignment="Center" ToolTip="Browse for Drivers folder."/>
</Grid> </Grid>
<!-- Copy PE Drivers (Row 6) --> <!-- Copy PE Drivers moved to Row 5 -->
<StackPanel Grid.Row="6" Grid.Column="0" Orientation="Horizontal" Margin="5"> <StackPanel Grid.Row="5" Grid.Column="0" Orientation="Horizontal" Margin="5">
<CheckBox x:Name="chkCopyPEDrivers" Content="Copy PE Drivers" Margin="0,0,5,0"/> <CheckBox x:Name="chkCopyPEDrivers" Content="Copy PE Drivers" Margin="0,0,5,0"/>
<Image x:Name="imgCopyPEDriversInfo" Source="$infoImagePath" Width="16" Height="16" Cursor="Arrow" <Image x:Name="imgCopyPEDriversInfo" Source="$infoImagePath" Width="16" Height="16" Cursor="Arrow"
Focusable="True" ToolTip="Check to copy local PE Drivers folder to the build." /> Focusable="True" ToolTip="Check to copy local PE Drivers folder to the build." />
</StackPanel> </StackPanel>
<!-- PE Drivers Folder moved to Row 6 -->
<StackPanel Grid.Row="6" Grid.Column="0" Orientation="Horizontal" Margin="5">
<TextBlock Text="PE Drivers Folder:" VerticalAlignment="Center"/>
<Image x:Name="imgPEDriversFolderInfo" Source="$infoImagePath" Width="16" Height="16" Margin="5,0,0,0" Cursor="Arrow"
Focusable="True"
ToolTip="Specify the path to the PE Drivers folder." />
</StackPanel>
<Grid Grid.Row="6" Grid.Column="1" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox x:Name="txtPEDriversFolder" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Stretch" />
<Button x:Name="btnBrowsePEDrivers" Grid.Column="1" Content="Browse..." Width="80" Margin="5,0,0,0" VerticalAlignment="Center" ToolTip="Browse for PE Drivers folder."/>
</Grid>
</Grid> </Grid>
</TabItem> </TabItem>
</TabControl> </TabControl>