mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Refactor: Centralize driver checkbox event handling
Moves the interdependent state logic for the driver-related checkboxes from the main UI script into a new, centralized function within the core module. This change simplifies the event handling by using a single handler for all related checkboxes, which improves code readability and maintainability. The new function is also called during initialization to ensure the UI reflects the correct state on startup.
This commit is contained in:
@@ -581,8 +581,25 @@ function Register-EventHandlers {
|
||||
$localState.Controls.OfficeConfigurationXMLFileStackPanel.Visibility = 'Collapsed'
|
||||
$localState.Controls.OfficeConfigurationXMLFileGrid.Visibility = 'Collapsed'
|
||||
})
|
||||
|
||||
|
||||
# Drivers Tab Event Handlers
|
||||
# Define a single handler for interdependent driver checkboxes
|
||||
$driverCheckboxHandler = {
|
||||
param($eventSource, $routedEventArgs)
|
||||
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||
if ($null -ne $window) {
|
||||
Update-DriverCheckboxStates -State $window.Tag
|
||||
}
|
||||
}
|
||||
|
||||
# Attach the handler to all relevant checkboxes
|
||||
$State.Controls.chkInstallDrivers.Add_Checked($driverCheckboxHandler)
|
||||
$State.Controls.chkInstallDrivers.Add_Unchecked($driverCheckboxHandler)
|
||||
$State.Controls.chkCopyDrivers.Add_Checked($driverCheckboxHandler)
|
||||
$State.Controls.chkCopyDrivers.Add_Unchecked($driverCheckboxHandler)
|
||||
$State.Controls.chkCompressDriversToWIM.Add_Checked($driverCheckboxHandler)
|
||||
$State.Controls.chkCompressDriversToWIM.Add_Unchecked($driverCheckboxHandler)
|
||||
|
||||
$State.Controls.btnBrowseDriversFolder.Add_Click({
|
||||
param($eventSource, $routedEventArgs)
|
||||
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||
|
||||
Reference in New Issue
Block a user