mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
feat: Dynamically update Windows architecture options
Implements logic to filter the available Windows architectures based on the selected OS Release, Version, and SKU. This ensures that only valid architecture options are presented to the user. - Adds a new function to determine the correct architectures for different Windows versions (e.g., Server, Windows 10/11, LTSC editions). - Wires up event handlers to the Release, Version, and SKU dropdowns to refresh the architecture list when their selection changes. - Refactors initialization to use this new dynamic logic.
This commit is contained in:
@@ -151,10 +151,29 @@ 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
|
||||||
}
|
}
|
||||||
# Only need to update the Version combo when Release changes
|
|
||||||
Update-WindowsVersionCombo -selectedRelease $selectedReleaseValue -isoPath $localState.Controls.txtISOPath.Text -State $localState
|
Update-WindowsVersionCombo -selectedRelease $selectedReleaseValue -isoPath $localState.Controls.txtISOPath.Text -State $localState
|
||||||
# Also update the SKU combo (now derives values internally)
|
|
||||||
Update-WindowsSkuCombo -State $localState
|
Update-WindowsSkuCombo -State $localState
|
||||||
|
Update-WindowsArchCombo -State $localState
|
||||||
|
})
|
||||||
|
|
||||||
|
$State.Controls.cmbWindowsVersion.Add_SelectionChanged({
|
||||||
|
param($eventSource, $selectionChangedEventArgs)
|
||||||
|
# This event should only fire on user interaction or after Update-WindowsVersionCombo runs.
|
||||||
|
# We only need to update the architecture, as SKU is dependent only on Release.
|
||||||
|
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||||
|
if ($null -eq $window) { return } # Window might be closing
|
||||||
|
$localState = $window.Tag
|
||||||
|
Update-WindowsArchCombo -State $localState
|
||||||
|
})
|
||||||
|
|
||||||
|
$State.Controls.cmbWindowsSKU.Add_SelectionChanged({
|
||||||
|
param($eventSource, $selectionChangedEventArgs)
|
||||||
|
# This event should only fire on user interaction or after Update-WindowsSkuCombo runs.
|
||||||
|
# We only need to update the architecture.
|
||||||
|
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||||
|
if ($null -eq $window) { return } # Window might be closing
|
||||||
|
$localState = $window.Tag
|
||||||
|
Update-WindowsArchCombo -State $localState
|
||||||
})
|
})
|
||||||
|
|
||||||
$State.Controls.btnBrowseISO.Add_Click({
|
$State.Controls.btnBrowseISO.Add_Click({
|
||||||
|
|||||||
@@ -234,11 +234,8 @@ function Initialize-UIDefaults {
|
|||||||
Get-WindowsSettingsCombos -isoPath $State.Defaults.windowsSettingsDefaults.DefaultISOPath -State $State
|
Get-WindowsSettingsCombos -isoPath $State.Defaults.windowsSettingsDefaults.DefaultISOPath -State $State
|
||||||
|
|
||||||
# Windows Settings tab defaults
|
# Windows Settings tab defaults
|
||||||
$State.Controls.cmbWindowsArch.ItemsSource = $State.Defaults.windowsSettingsDefaults.AllowedArchitectures
|
|
||||||
$State.Controls.cmbWindowsArch.SelectedItem = $State.Defaults.windowsSettingsDefaults.DefaultWindowsArch
|
|
||||||
$State.Controls.cmbWindowsLang.ItemsSource = $State.Defaults.windowsSettingsDefaults.AllowedLanguages
|
$State.Controls.cmbWindowsLang.ItemsSource = $State.Defaults.windowsSettingsDefaults.AllowedLanguages
|
||||||
$State.Controls.cmbWindowsLang.SelectedItem = $State.Defaults.windowsSettingsDefaults.DefaultWindowsLang
|
$State.Controls.cmbWindowsLang.SelectedItem = $State.Defaults.windowsSettingsDefaults.DefaultWindowsLang
|
||||||
$State.Controls.cmbWindowsSKU.SelectedItem = $State.Defaults.windowsSettingsDefaults.DefaultWindowsSKU
|
|
||||||
$State.Controls.cmbMediaType.ItemsSource = $State.Defaults.windowsSettingsDefaults.AllowedMediaTypes
|
$State.Controls.cmbMediaType.ItemsSource = $State.Defaults.windowsSettingsDefaults.AllowedMediaTypes
|
||||||
$State.Controls.cmbMediaType.SelectedItem = $State.Defaults.windowsSettingsDefaults.DefaultMediaType
|
$State.Controls.cmbMediaType.SelectedItem = $State.Defaults.windowsSettingsDefaults.DefaultMediaType
|
||||||
$State.Controls.txtOptionalFeatures.Text = $State.Defaults.windowsSettingsDefaults.DefaultOptionalFeatures
|
$State.Controls.txtOptionalFeatures.Text = $State.Defaults.windowsSettingsDefaults.DefaultOptionalFeatures
|
||||||
|
|||||||
@@ -462,6 +462,98 @@ function Update-WindowsSkuCombo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to refresh the Windows Architecture ComboBox based on selected release, version, and SKU
|
||||||
|
function Update-WindowsArchCombo {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[psobject]$State
|
||||||
|
)
|
||||||
|
|
||||||
|
$archCombo = $State.Controls.cmbWindowsArch
|
||||||
|
if (-not $archCombo) {
|
||||||
|
WriteLog "Update-WindowsArchCombo: Architecture ComboBox not found."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
$previousSelectedArch = $archCombo.SelectedItem
|
||||||
|
|
||||||
|
# Start with a safe, common default
|
||||||
|
$availableArchitectures = @('x64')
|
||||||
|
|
||||||
|
$releaseItem = $State.Controls.cmbWindowsRelease.SelectedItem
|
||||||
|
$versionItem = $State.Controls.cmbWindowsVersion.SelectedItem
|
||||||
|
$skuItem = $State.Controls.cmbWindowsSKU.SelectedItem
|
||||||
|
|
||||||
|
if ($null -eq $releaseItem) {
|
||||||
|
WriteLog "Update-WindowsArchCombo: No release selected. Defaulting to x64."
|
||||||
|
$archCombo.ItemsSource = $availableArchitectures
|
||||||
|
$archCombo.SelectedItem = 'x64'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
$releaseDisplay = $releaseItem.Display
|
||||||
|
$versionValue = if ($null -ne $versionItem) { $versionItem } else { "" }
|
||||||
|
$skuValue = if ($null -ne $skuItem) { $skuItem } else { "" }
|
||||||
|
|
||||||
|
if ($releaseDisplay -like 'Windows Server*') {
|
||||||
|
# All servers are x64 only
|
||||||
|
$availableArchitectures = @('x64')
|
||||||
|
}
|
||||||
|
elseif ($releaseDisplay -like 'Windows 11*') {
|
||||||
|
if ($releaseDisplay -like '*LTSC*') {
|
||||||
|
# Windows 11 LTSC 2024
|
||||||
|
if ($skuValue -like 'IoT*') {
|
||||||
|
$availableArchitectures = @('x64', 'arm64')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$availableArchitectures = @('x64')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Standard Windows 11
|
||||||
|
if ($versionValue -eq '24H2') {
|
||||||
|
$availableArchitectures = @('x64', 'arm64')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# 22H2, 23H2
|
||||||
|
$availableArchitectures = @('x64')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($releaseDisplay -like 'Windows 10*') {
|
||||||
|
if ($releaseDisplay -like '*LTSB*' -or $releaseDisplay -like '*LTSC*') {
|
||||||
|
# Windows 10 LTSB 2016, LTSC 2019, LTSC 2021
|
||||||
|
if ($releaseDisplay -like '*2021*' -and $skuValue -like 'IoT*') {
|
||||||
|
$availableArchitectures = @('x64', 'arm64')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# LTSB 2016, LTSC 2019, LTSC 2021 (non-IoT)
|
||||||
|
$availableArchitectures = @('x86', 'x64')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Standard Windows 10 (22H2)
|
||||||
|
$availableArchitectures = @('x86', 'x64')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$archCombo.ItemsSource = $availableArchitectures
|
||||||
|
|
||||||
|
if ($availableArchitectures -contains $previousSelectedArch) {
|
||||||
|
$archCombo.SelectedItem = $previousSelectedArch
|
||||||
|
}
|
||||||
|
elseif ($availableArchitectures -contains 'x64') {
|
||||||
|
$archCombo.SelectedItem = 'x64'
|
||||||
|
}
|
||||||
|
elseif ($availableArchitectures.Count -gt 0) {
|
||||||
|
$archCombo.SelectedIndex = 0
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$archCombo.SelectedIndex = -1
|
||||||
|
}
|
||||||
|
WriteLog "Update-WindowsArchCombo: Updated available architectures to ($($availableArchitectures -join ', ')). Selected: $($archCombo.SelectedItem)"
|
||||||
|
}
|
||||||
|
|
||||||
# Combined function to initialize the Release, Version, and SKU combos
|
# Combined function to initialize the Release, Version, and SKU combos
|
||||||
function Get-WindowsSettingsCombos {
|
function Get-WindowsSettingsCombos {
|
||||||
param(
|
param(
|
||||||
@@ -484,6 +576,9 @@ function Get-WindowsSettingsCombos {
|
|||||||
|
|
||||||
# Update SKU combo based on the selected release (now derives values internally)
|
# Update SKU combo based on the selected release (now derives values internally)
|
||||||
Update-WindowsSkuCombo -State $State
|
Update-WindowsSkuCombo -State $State
|
||||||
|
|
||||||
|
# Finally, update the Architecture combo to match the initial state
|
||||||
|
Update-WindowsArchCombo -State $State
|
||||||
}
|
}
|
||||||
|
|
||||||
# Dynamic checkboxes for optional features in Windows Settings tab
|
# Dynamic checkboxes for optional features in Windows Settings tab
|
||||||
|
|||||||
Reference in New Issue
Block a user