mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Refactor USB drive detection event handler
Moves the click event handler for detecting USB drives from the main UI script to the dedicated core handlers module. This change centralizes UI logic, improving code organization and maintainability.
This commit is contained in:
@@ -2,6 +2,22 @@ function Register-EventHandlers {
|
||||
param([PSCustomObject]$State)
|
||||
WriteLog "Registering UI event handlers..."
|
||||
|
||||
# Build Tab Event Handlers
|
||||
$State.Controls.btnCheckUSBDrives.Add_Click({
|
||||
param($eventSource, $routedEventArgs)
|
||||
$window = [System.Windows.Window]::GetWindow($eventSource)
|
||||
$localState = $window.Tag
|
||||
|
||||
$localState.Controls.lstUSBDrives.Items.Clear()
|
||||
$usbDrives = Get-USBDrives
|
||||
foreach ($drive in $usbDrives) {
|
||||
$localState.Controls.lstUSBDrives.Items.Add([PSCustomObject]$drive)
|
||||
}
|
||||
if ($localState.Controls.lstUSBDrives.Items.Count -gt 0) {
|
||||
$localState.Controls.lstUSBDrives.SelectedIndex = 0
|
||||
}
|
||||
})
|
||||
|
||||
# Hyper-V tab event handlers
|
||||
$State.Controls.cmbVMSwitchName.Add_SelectionChanged({
|
||||
param($eventSource, $selectionChangedEventArgs)
|
||||
|
||||
Reference in New Issue
Block a user