mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Implement conditional autoscroll in log monitor
Improves the user experience in the monitor tab by making the log output autoscroll conditional. Autoscrolling is now disabled when the user selects a log entry other than the last one, allowing them to inspect previous output without interruption. Selecting the last item in the list re-enables autoscrolling.
This commit is contained in:
@@ -778,5 +778,30 @@ function Register-EventHandlers {
|
||||
$keyEventArgs.Handled = $true
|
||||
}
|
||||
})
|
||||
|
||||
$State.Controls.lstLogOutput.Add_SelectionChanged({
|
||||
param($eventSource, $selectionChangedEventArgs)
|
||||
$listBox = $eventSource
|
||||
$window = [System.Windows.Window]::GetWindow($listBox)
|
||||
if ($null -eq $window) { return }
|
||||
$localState = $window.Tag
|
||||
|
||||
# If nothing is selected or the list is empty, do nothing.
|
||||
if ($listBox.SelectedIndex -eq -1 -or $listBox.Items.Count -eq 0) {
|
||||
return
|
||||
}
|
||||
|
||||
# Check if the last item is selected
|
||||
$isLastItemSelected = ($listBox.SelectedIndex -eq ($listBox.Items.Count - 1))
|
||||
|
||||
# Update the flag
|
||||
$localState.Flags.autoScrollLog = $isLastItemSelected
|
||||
if ($isLastItemSelected) {
|
||||
WriteLog "Monitor tab autoscroll enabled (last item selected)."
|
||||
}
|
||||
else {
|
||||
WriteLog "Monitor tab autoscroll disabled (user selected item #$($listBox.SelectedIndex))."
|
||||
}
|
||||
})
|
||||
}
|
||||
Export-ModuleMember -Function *
|
||||
Reference in New Issue
Block a user