mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Refactor USB drive UI logic into core modules
Moves event handlers and initial state configuration for the USB drive creation settings from the main UI script into the core handler and initialization modules. This change centralizes the UI logic, improving code organization and maintainability.
This commit is contained in:
@@ -4,6 +4,49 @@ function Register-EventHandlers {
|
||||
|
||||
# Build Tab Event Handlers
|
||||
# Build USB Drive Settings Event Handlers
|
||||
$State.Controls.chkBuildUSBDriveEnable.Add_Checked({
|
||||
param($eventSource, $routedEventArgs)
|
||||
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||
$localState = $window.Tag
|
||||
$localState.Controls.usbSection.Visibility = 'Visible'
|
||||
$localState.Controls.chkSelectSpecificUSBDrives.IsEnabled = $true
|
||||
})
|
||||
$State.Controls.chkBuildUSBDriveEnable.Add_Unchecked({
|
||||
param($eventSource, $routedEventArgs)
|
||||
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||
$localState = $window.Tag
|
||||
$localState.Controls.usbSection.Visibility = 'Collapsed'
|
||||
$localState.Controls.chkSelectSpecificUSBDrives.IsEnabled = $false
|
||||
$localState.Controls.chkSelectSpecificUSBDrives.IsChecked = $false
|
||||
$localState.Controls.lstUSBDrives.Items.Clear()
|
||||
})
|
||||
$State.Controls.chkSelectSpecificUSBDrives.Add_Checked({
|
||||
param($eventSource, $routedEventArgs)
|
||||
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||
$localState = $window.Tag
|
||||
$localState.Controls.usbSelectionPanel.Visibility = 'Visible'
|
||||
})
|
||||
$State.Controls.chkSelectSpecificUSBDrives.Add_Unchecked({
|
||||
param($eventSource, $routedEventArgs)
|
||||
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||
$localState = $window.Tag
|
||||
$localState.Controls.usbSelectionPanel.Visibility = 'Collapsed'
|
||||
$localState.Controls.lstUSBDrives.Items.Clear()
|
||||
})
|
||||
$State.Controls.chkAllowExternalHardDiskMedia.Add_Checked({
|
||||
param($eventSource, $routedEventArgs)
|
||||
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||
$localState = $window.Tag
|
||||
$localState.Controls.chkPromptExternalHardDiskMedia.IsEnabled = $true
|
||||
})
|
||||
$State.Controls.chkAllowExternalHardDiskMedia.Add_Unchecked({
|
||||
param($eventSource, $routedEventArgs)
|
||||
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||
$localState = $window.Tag
|
||||
$localState.Controls.chkPromptExternalHardDiskMedia.IsEnabled = $false
|
||||
$localState.Controls.chkPromptExternalHardDiskMedia.IsChecked = $false
|
||||
})
|
||||
|
||||
$State.Controls.btnCheckUSBDrives.Add_Click({
|
||||
param($eventSource, $routedEventArgs)
|
||||
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||
|
||||
@@ -180,6 +180,10 @@ function Initialize-UIDefaults {
|
||||
$State.Controls.chkRemoveFFU.IsChecked = $State.Defaults.generalDefaults.RemoveFFU
|
||||
$State.Controls.chkRemoveApps.IsChecked = $State.Defaults.generalDefaults.RemoveApps
|
||||
$State.Controls.chkRemoveUpdates.IsChecked = $State.Defaults.generalDefaults.RemoveUpdates
|
||||
$State.Controls.usbSection.Visibility = if ($State.Controls.chkBuildUSBDriveEnable.IsChecked) { 'Visible' } else { 'Collapsed' }
|
||||
$State.Controls.usbSelectionPanel.Visibility = if ($State.Controls.chkSelectSpecificUSBDrives.IsChecked) { 'Visible' } else { 'Collapsed' }
|
||||
$State.Controls.chkSelectSpecificUSBDrives.IsEnabled = $State.Controls.chkBuildUSBDriveEnable.IsChecked
|
||||
$State.Controls.chkPromptExternalHardDiskMedia.IsEnabled = $State.Controls.chkAllowExternalHardDiskMedia.IsChecked
|
||||
|
||||
# Hyper-V Settings defaults from General Defaults
|
||||
$State.Controls.txtDiskSize.Text = $State.Defaults.generalDefaults.DiskSizeGB
|
||||
@@ -237,6 +241,7 @@ function Initialize-UIDefaults {
|
||||
|
||||
# Set initial state for InstallApps checkbox based on updates
|
||||
Update-InstallAppsState -State $State
|
||||
|
||||
}
|
||||
|
||||
function Initialize-DynamicUIElements {
|
||||
|
||||
Reference in New Issue
Block a user