Adds Windows Media Source selection options

Introduces radio buttons to choose between downloading a Windows ESD or providing a custom Windows ISO file, enhancing flexibility for media source selection. Updates configuration handling and event listeners to toggle visibility and appropriately populate combo boxes based on the selected media source.
This commit is contained in:
rbalsleyMSFT
2026-03-20 15:25:23 -07:00
parent b28344d272
commit 80147ed61b
5 changed files with 69 additions and 18 deletions
+9 -1
View File
@@ -223,7 +223,14 @@
<!-- TAB: Windows Settings --> <!-- TAB: Windows Settings -->
<ScrollViewer x:Name="pageWindows" VerticalScrollBarVisibility="Auto" Visibility="Collapsed"> <ScrollViewer x:Name="pageWindows" VerticalScrollBarVisibility="Auto" Visibility="Collapsed">
<StackPanel Margin="16"> <StackPanel Margin="16">
<!-- Windows ISO Path --> <!-- Windows Media Source -->
<TextBlock Text="Windows Media Source" Margin="0,0,0,8" ToolTip="Choose whether to download Windows ESD from Microsoft or provide your own Windows ISO file."/>
<StackPanel x:Name="cmbWindowsMediaSource" Margin="0,0,0,24">
<RadioButton x:Name="rbDownloadESD" Content="Download Windows ESD" IsChecked="True" Margin="0,0,0,8" GroupName="WindowsMediaSource" ToolTip="Download the latest Windows ESD file from Microsoft."/>
<RadioButton x:Name="rbProvideISO" Content="Provide Windows ISO" Margin="0" GroupName="WindowsMediaSource" ToolTip="Use your own Windows ISO file."/>
</StackPanel>
<!-- Windows ISO Path (visible only when "Provide Windows ISO" is selected) -->
<StackPanel x:Name="isoPathPanel" Visibility="Collapsed">
<TextBlock Text="Windows ISO Path" Margin="0,0,0,4" ToolTip="Path to the Windows ISO file."/> <TextBlock Text="Windows ISO Path" Margin="0,0,0,4" ToolTip="Path to the Windows ISO file."/>
<Grid Margin="0,0,0,24"> <Grid Margin="0,0,0,24">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@@ -233,6 +240,7 @@
<TextBox x:Name="txtISOPath" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Stretch" ToolTip="Path to the Windows ISO file."/> <TextBox x:Name="txtISOPath" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Stretch" ToolTip="Path to the Windows ISO file."/>
<Button x:Name="btnBrowseISO" Grid.Column="1" Content="Browse..." Padding="12,4" Margin="8,0,0,0" VerticalAlignment="Center"/> <Button x:Name="btnBrowseISO" Grid.Column="1" Content="Browse..." Padding="12,4" Margin="8,0,0,0" VerticalAlignment="Center"/>
</Grid> </Grid>
</StackPanel>
<!-- Windows Release --> <!-- Windows Release -->
<TextBlock Text="Windows Release" Margin="0,0,0,4" ToolTip="Integer value of 10 or 11. This is used to identify which release of Windows to download. Default is 11."/> <TextBlock Text="Windows Release" Margin="0,0,0,4" ToolTip="Integer value of 10 or 11. This is used to identify which release of Windows to download. Default is 11."/>
<ComboBox x:Name="cmbWindowsRelease" HorizontalAlignment="Stretch" Margin="0,0,0,24" ToolTip="Integer value of 10 or 11. This is used to identify which release of Windows to download. Default is 11."/> <ComboBox x:Name="cmbWindowsRelease" HorizontalAlignment="Stretch" Margin="0,0,0,24" ToolTip="Integer value of 10 or 11. This is used to identify which release of Windows to download. Default is 11."/>
@@ -54,6 +54,7 @@ function Get-UIConfig {
InstallOffice = $State.Controls.chkInstallOffice.IsChecked InstallOffice = $State.Controls.chkInstallOffice.IsChecked
InstallWingetApps = $State.Controls.chkInstallWingetApps.IsChecked InstallWingetApps = $State.Controls.chkInstallWingetApps.IsChecked
ISOPath = $State.Controls.txtISOPath.Text ISOPath = $State.Controls.txtISOPath.Text
WindowsMediaSource = if ($null -ne $State.Controls.rbProvideISO -and $State.Controls.rbProvideISO.IsChecked) { "Provide Windows ISO" } else { "Download Windows ESD" }
LogicalSectorSizeBytes = [int]$State.Controls.cmbLogicalSectorSize.SelectedItem.Content LogicalSectorSizeBytes = [int]$State.Controls.cmbLogicalSectorSize.SelectedItem.Content
# Make = $null # Make = $null
MediaType = $State.Controls.cmbMediaType.SelectedItem MediaType = $State.Controls.cmbMediaType.SelectedItem
@@ -486,6 +487,15 @@ function Update-UIFromConfig {
# Windows Settings # Windows Settings
Set-UIValue -ControlName 'txtISOPath' -PropertyName 'Text' -ConfigObject $ConfigContent -ConfigKey 'ISOPath' -State $State Set-UIValue -ControlName 'txtISOPath' -PropertyName 'Text' -ConfigObject $ConfigContent -ConfigKey 'ISOPath' -State $State
# Load Windows Media Source setting
if ($null -ne $ConfigContent.PSObject.Properties.Item('WindowsMediaSource')) {
if ($ConfigContent.WindowsMediaSource -eq 'Provide Windows ISO') {
$State.Controls.rbProvideISO.IsChecked = $true
}
else {
$State.Controls.rbDownloadESD.IsChecked = $true
}
}
# Special handling for Windows Release and SKU due to value collision (e.g., 2019 for Server and LTSC) # Special handling for Windows Release and SKU due to value collision (e.g., 2019 for Server and LTSC)
if (($null -ne $ConfigContent.PSObject.Properties.Item('WindowsRelease')) -and ($null -ne $ConfigContent.PSObject.Properties.Item('WindowsSKU'))) { if (($null -ne $ConfigContent.PSObject.Properties.Item('WindowsRelease')) -and ($null -ne $ConfigContent.PSObject.Properties.Item('WindowsSKU'))) {
@@ -392,12 +392,31 @@ function Register-EventHandlers {
}) })
# Windows Settings tab Event Handlers # Windows Settings tab Event Handlers
$State.Controls.txtISOPath.Add_TextChanged({ # Windows Media Source radio buttons
param($eventSource, $textChangedEventArgs) if ($null -ne $State.Controls.rbProvideISO) {
$State.Controls.rbProvideISO.Add_Checked({
param($eventSource, $routedEventArgs)
$window = [System.Windows.Window]::GetWindow($eventSource) $window = [System.Windows.Window]::GetWindow($eventSource)
if ($null -eq $window -or $null -eq $window.Tag) { return }
$localState = $window.Tag $localState = $window.Tag
Get-WindowsSettingsCombos -isoPath $localState.Controls.txtISOPath.Text -State $localState $localState.Controls.isoPathPanel.Visibility = 'Visible'
# Use a placeholder .iso path to trigger ISO mode even before a real path is provided
$isoPath = $localState.Controls.txtISOPath.Text
if ([string]::IsNullOrWhiteSpace($isoPath)) {
$isoPath = 'placeholder.iso'
}
Get-WindowsSettingsCombos -isoPath $isoPath -State $localState
}) })
$State.Controls.rbProvideISO.Add_Unchecked({
param($eventSource, $routedEventArgs)
$window = [System.Windows.Window]::GetWindow($eventSource)
if ($null -eq $window -or $null -eq $window.Tag) { return }
$localState = $window.Tag
$localState.Controls.isoPathPanel.Visibility = 'Collapsed'
$localState.Controls.txtISOPath.Text = ''
Get-WindowsSettingsCombos -isoPath '' -State $localState
})
}
$State.Controls.cmbWindowsRelease.Add_SelectionChanged({ $State.Controls.cmbWindowsRelease.Add_SelectionChanged({
param($eventSource, $selectionChangedEventArgs) param($eventSource, $selectionChangedEventArgs)
@@ -407,7 +426,13 @@ function Register-EventHandlers {
if ($null -ne $localState.Controls.cmbWindowsRelease.SelectedItem) { if ($null -ne $localState.Controls.cmbWindowsRelease.SelectedItem) {
$selectedReleaseValue = $localState.Controls.cmbWindowsRelease.SelectedItem.Value $selectedReleaseValue = $localState.Controls.cmbWindowsRelease.SelectedItem.Value
} }
Update-WindowsVersionCombo -selectedRelease $selectedReleaseValue -isoPath $localState.Controls.txtISOPath.Text -State $localState # Determine ISO path based on radio button state
$isoPath = ''
if ($null -ne $localState.Controls.rbProvideISO -and $localState.Controls.rbProvideISO.IsChecked) {
$isoPath = $localState.Controls.txtISOPath.Text
if ([string]::IsNullOrWhiteSpace($isoPath)) { $isoPath = 'placeholder.iso' }
}
Update-WindowsVersionCombo -selectedRelease $selectedReleaseValue -isoPath $isoPath -State $localState
Update-WindowsSkuCombo -State $localState Update-WindowsSkuCombo -State $localState
Update-WindowsArchCombo -State $localState Update-WindowsArchCombo -State $localState
@@ -112,6 +112,9 @@ function Initialize-UIControls {
$State.Controls.cmbWindowsRelease = $window.FindName('cmbWindowsRelease') $State.Controls.cmbWindowsRelease = $window.FindName('cmbWindowsRelease')
$State.Controls.cmbWindowsVersion = $window.FindName('cmbWindowsVersion') $State.Controls.cmbWindowsVersion = $window.FindName('cmbWindowsVersion')
$State.Controls.txtISOPath = $window.FindName('txtISOPath') $State.Controls.txtISOPath = $window.FindName('txtISOPath')
$State.Controls.rbDownloadESD = $window.FindName('rbDownloadESD')
$State.Controls.rbProvideISO = $window.FindName('rbProvideISO')
$State.Controls.isoPathPanel = $window.FindName('isoPathPanel')
$State.Controls.btnBrowseISO = $window.FindName('btnBrowseISO') $State.Controls.btnBrowseISO = $window.FindName('btnBrowseISO')
$State.Controls.cmbWindowsArch = $window.FindName('cmbWindowsArch') $State.Controls.cmbWindowsArch = $window.FindName('cmbWindowsArch')
$State.Controls.cmbWindowsLang = $window.FindName('cmbWindowsLang') $State.Controls.cmbWindowsLang = $window.FindName('cmbWindowsLang')
@@ -389,7 +392,12 @@ function Initialize-UIDefaults {
$State.Controls.cmbLogicalSectorSize.SelectedItem = ($State.Controls.cmbLogicalSectorSize.Items | Where-Object { $_.Content -eq $State.Defaults.generalDefaults.LogicalSectorSize.ToString() }) $State.Controls.cmbLogicalSectorSize.SelectedItem = ($State.Controls.cmbLogicalSectorSize.Items | Where-Object { $_.Content -eq $State.Defaults.generalDefaults.LogicalSectorSize.ToString() })
# Populate Windows Release, Version, and SKU comboboxes # Populate Windows Release, Version, and SKU comboboxes
Get-WindowsSettingsCombos -isoPath $State.Defaults.windowsSettingsDefaults.DefaultISOPath -State $State # Initialize Windows settings combos based on media source mode
$initIsoPath = $State.Defaults.windowsSettingsDefaults.DefaultISOPath
if ($null -ne $State.Controls.rbProvideISO -and -not $State.Controls.rbProvideISO.IsChecked) {
$initIsoPath = ''
}
Get-WindowsSettingsCombos -isoPath $initIsoPath -State $State
# Windows Settings tab defaults # Windows Settings tab defaults
$State.Controls.cmbWindowsLang.ItemsSource = $State.Defaults.windowsSettingsDefaults.AllowedLanguages $State.Controls.cmbWindowsLang.ItemsSource = $State.Defaults.windowsSettingsDefaults.AllowedLanguages
Binary file not shown.