diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Handlers.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Handlers.psm1 index bc0792e..bc7c0aa 100644 --- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Handlers.psm1 +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Handlers.psm1 @@ -151,10 +151,29 @@ function Register-EventHandlers { if ($null -ne $localState.Controls.cmbWindowsRelease.SelectedItem) { $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 - # Also update the SKU combo (now derives values internally) 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({ diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Initialize.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Initialize.psm1 index 6e6ea19..887de8b 100644 --- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Initialize.psm1 +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Initialize.psm1 @@ -234,11 +234,8 @@ function Initialize-UIDefaults { Get-WindowsSettingsCombos -isoPath $State.Defaults.windowsSettingsDefaults.DefaultISOPath -State $State # 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.SelectedItem = $State.Defaults.windowsSettingsDefaults.DefaultWindowsLang - $State.Controls.cmbWindowsSKU.SelectedItem = $State.Defaults.windowsSettingsDefaults.DefaultWindowsSKU $State.Controls.cmbMediaType.ItemsSource = $State.Defaults.windowsSettingsDefaults.AllowedMediaTypes $State.Controls.cmbMediaType.SelectedItem = $State.Defaults.windowsSettingsDefaults.DefaultMediaType $State.Controls.txtOptionalFeatures.Text = $State.Defaults.windowsSettingsDefaults.DefaultOptionalFeatures diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.WindowsSettings.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.WindowsSettings.psm1 index fcaceb4..dbcd8ae 100644 --- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.WindowsSettings.psm1 +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.WindowsSettings.psm1 @@ -461,7 +461,99 @@ function Update-WindowsSkuCombo { WriteLog "Update-WindowsSkuCombo: No SKUs available for Release '$selectedReleaseValue' (Display: '$selectedReleaseDisplayName')." } } - + +# 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 function Get-WindowsSettingsCombos { param( @@ -484,6 +576,9 @@ function Get-WindowsSettingsCombos { # Update SKU combo based on the selected release (now derives values internally) 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