Refactors CU checkbox initialization logic

Moves the initial state logic for the "Latest CU" and "Preview CU" checkboxes from the main UI script to the core initialization module.

This change centralizes UI default settings into the `Initialize-UIDefaults` function, improving code organization and maintainability.
This commit is contained in:
rbalsleyMSFT
2025-06-19 18:12:06 -07:00
parent cbc9ec4634
commit c946e56a41
2 changed files with 4 additions and 7 deletions
-6
View File
@@ -135,12 +135,6 @@ $window.Add_Loaded({
Register-EventHandlers -State $script:uiState Register-EventHandlers -State $script:uiState
# CU interplay (Keep existing logic)
# Set initial state based on defaults
$script:uiState.Controls.chkPreviewCU.IsEnabled = -not $script:uiState.Controls.chkLatestCU.IsChecked
$script:uiState.Controls.chkLatestCU.IsEnabled = -not $script:uiState.Controls.chkPreviewCU.IsChecked
# APPLICATIONS tab UI logic (Keep existing logic) # APPLICATIONS tab UI logic (Keep existing logic)
$script:uiState.Controls.chkInstallWingetApps.Visibility = if ($script:uiState.Controls.chkInstallApps.IsChecked) { 'Visible' } else { 'Collapsed' } $script:uiState.Controls.chkInstallWingetApps.Visibility = if ($script:uiState.Controls.chkInstallApps.IsChecked) { 'Visible' } else { 'Collapsed' }
$script:uiState.Controls.applicationPathPanel.Visibility = if ($script:uiState.Controls.chkInstallApps.IsChecked) { 'Visible' } else { 'Collapsed' } $script:uiState.Controls.applicationPathPanel.Visibility = if ($script:uiState.Controls.chkInstallApps.IsChecked) { 'Visible' } else { 'Collapsed' }
@@ -216,6 +216,9 @@ function Initialize-UIDefaults {
$State.Controls.chkUpdateLatestMSRT.IsChecked = $State.Defaults.generalDefaults.UpdateLatestMSRT $State.Controls.chkUpdateLatestMSRT.IsChecked = $State.Defaults.generalDefaults.UpdateLatestMSRT
$State.Controls.chkUpdateLatestMicrocode.IsChecked = $State.Defaults.generalDefaults.UpdateLatestMicrocode $State.Controls.chkUpdateLatestMicrocode.IsChecked = $State.Defaults.generalDefaults.UpdateLatestMicrocode
$State.Controls.chkUpdatePreviewCU.IsChecked = $State.Defaults.generalDefaults.UpdatePreviewCU $State.Controls.chkUpdatePreviewCU.IsChecked = $State.Defaults.generalDefaults.UpdatePreviewCU
# Set initial state for CU checkbox interplay
$State.Controls.chkPreviewCU.IsEnabled = -not $State.Controls.chkLatestCU.IsChecked
$State.Controls.chkLatestCU.IsEnabled = -not $State.Controls.chkPreviewCU.IsChecked
# Applications tab defaults from General Defaults # Applications tab defaults from General Defaults
$State.Controls.chkInstallApps.IsChecked = $State.Defaults.generalDefaults.InstallApps $State.Controls.chkInstallApps.IsChecked = $State.Defaults.generalDefaults.InstallApps
@@ -249,7 +252,7 @@ function Initialize-UIDefaults {
$State.Controls.cmbMake.SelectedIndex = 0 $State.Controls.cmbMake.SelectedIndex = 0
} }
Update-DriverDownloadPanelVisibility -State $State Update-DriverDownloadPanelVisibility -State $State
# Set initial state for driver checkbox interplay # Set initial state for driver checkbox interplay
Update-DriverCheckboxStates -State $State Update-DriverCheckboxStates -State $State