Refactor: Move Winget download logic to core module

Extracts the Winget app download logic from the main UI script into a new `Invoke-WingetDownload` function within the core Winget module.

This change decouples the UI event handling from the business logic, improving modularity and maintainability. It also introduces more robust error handling for the download process by wrapping the logic in a try/catch block.
This commit is contained in:
rbalsleyMSFT
2025-06-19 12:23:13 -07:00
parent 00ee79d33c
commit 12607cca44
3 changed files with 68 additions and 53 deletions
@@ -423,6 +423,13 @@ function Register-EventHandlers {
-PostClearAction $postClearScriptBlock
})
$State.Controls.btnDownloadSelected.Add_Click({
param($eventSource, $routedEventArgs)
$window = [System.Windows.Window]::GetWindow($eventSource)
$localState = $window.Tag
Invoke-WingetDownload -State $localState -Button $eventSource
})
# M365 Apps/Office tab Event
$State.Controls.chkInstallOffice.Add_Checked({
param($eventSource, $routedEventArgs)