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
@@ -54,6 +54,7 @@ function Get-UIConfig {
InstallOffice = $State.Controls.chkInstallOffice.IsChecked
InstallWingetApps = $State.Controls.chkInstallWingetApps.IsChecked
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
# Make = $null
MediaType = $State.Controls.cmbMediaType.SelectedItem
@@ -486,6 +487,15 @@ function Update-UIFromConfig {
# Windows Settings
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)
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
$State.Controls.txtISOPath.Add_TextChanged({
param($eventSource, $textChangedEventArgs)
$window = [System.Windows.Window]::GetWindow($eventSource)
$localState = $window.Tag
Get-WindowsSettingsCombos -isoPath $localState.Controls.txtISOPath.Text -State $localState
})
# Windows Media Source radio buttons
if ($null -ne $State.Controls.rbProvideISO) {
$State.Controls.rbProvideISO.Add_Checked({
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 = '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({
param($eventSource, $selectionChangedEventArgs)
@@ -407,7 +426,13 @@ function Register-EventHandlers {
if ($null -ne $localState.Controls.cmbWindowsRelease.SelectedItem) {
$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-WindowsArchCombo -State $localState
@@ -112,6 +112,9 @@ function Initialize-UIControls {
$State.Controls.cmbWindowsRelease = $window.FindName('cmbWindowsRelease')
$State.Controls.cmbWindowsVersion = $window.FindName('cmbWindowsVersion')
$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.cmbWindowsArch = $window.FindName('cmbWindowsArch')
$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() })
# 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
$State.Controls.cmbWindowsLang.ItemsSource = $State.Defaults.windowsSettingsDefaults.AllowedLanguages