Files
winutil/functions/public/Invoke-WPFGetInstalled.ps1
T

54 lines
2.0 KiB
PowerShell
Raw Normal View History

+2
2023-05-09 13:14:27 -05:00
function Invoke-WPFGetInstalled {
<#
TODO: Add the Option to use Chocolatey as Engine
2023-10-19 17:12:55 -05:00
.SYNOPSIS
Invokes the function that gets the checkboxes to check in a new runspace
.PARAMETER checkbox
Indicates whether to check for installed 'winget' programs or applied 'tweaks'
+2
2023-05-09 13:14:27 -05:00
#>
param($checkbox)
2025-03-01 20:50:12 +01:00
if ($sync.ProcessRunning) {
2024-01-15 11:32:19 -06:00
$msg = "[Invoke-WPFGetInstalled] Install process is currently running."
+2
2023-05-09 13:14:27 -05:00
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
return
}
2025-03-01 20:50:12 +01:00
if (($sync.ChocoRadioButton.IsChecked -eq $false) -and ((Test-WinUtilPackageManager -winget) -eq "not-installed") -and $checkbox -eq "winget") {
+2
2023-05-09 13:14:27 -05:00
return
}
$managerPreference = $sync["ManagerPreference"]
2025-05-12 22:45:57 +02:00
Invoke-WPFRunspace -ParameterList @(("managerPreference", $managerPreference),("checkbox", $checkbox)) -DebugPreference $DebugPreference -ScriptBlock {
2025-03-01 20:50:12 +01:00
param (
[string]$checkbox,
2025-05-12 22:45:57 +02:00
[PackageManagers]$managerPreference
2025-03-01 20:50:12 +01:00
)
+2
2023-05-09 13:14:27 -05:00
$sync.ProcessRunning = $true
2025-03-01 20:50:12 +01:00
$sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "Indeterminate" })
+2
2023-05-09 13:14:27 -05:00
2025-03-01 20:50:12 +01:00
if ($checkbox -eq "winget") {
+2
2023-05-09 13:14:27 -05:00
Write-Host "Getting Installed Programs..."
switch ($managerPreference) {
"Choco"{$Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox "choco"; break}
"Winget"{$Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox; break}
}
+2
2023-05-09 13:14:27 -05:00
}
2025-03-01 20:50:12 +01:00
elseif ($checkbox -eq "tweaks") {
+2
2023-05-09 13:14:27 -05:00
Write-Host "Getting Installed Tweaks..."
$Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox
}
2023-10-19 17:12:55 -05:00
+2
2023-05-09 13:14:27 -05:00
$sync.form.Dispatcher.invoke({
2025-03-01 20:50:12 +01:00
foreach ($checkbox in $Checkboxes) {
+2
2023-05-09 13:14:27 -05:00
$sync.$checkbox.ischecked = $True
}
})
2025-05-12 22:45:57 +02:00
+2
2023-05-09 13:14:27 -05:00
Write-Host "Done..."
$sync.ProcessRunning = $false
$sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "None" })
+2
2023-05-09 13:14:27 -05:00
}
}