Choco Logic Refactor and Add Checkbox to prefer Chocolatey over Winget (#2596)

* First Selector and Logic

* Extend Functionality

* Switch to PreferChocolatey Checkbox

* Persist Choco Preference across program restarts

* Change Logging, Fix interactivity and optimize uninstall

* Implement "Get-Installed" (quick-and-dirty)

* Code Formatting

* Rename File/Function, Refactor Choco Install, Add Status Indicator

* Add documentation

---------

Co-authored-by: Chris Titus <contact@christitus.com>
This commit is contained in:
Martin Wiethan
2024-09-10 20:02:22 +02:00
committed by GitHub
parent 2b9b1b026c
commit 14d20cd161
15 changed files with 356 additions and 134 deletions

View File

@ -1,6 +1,6 @@
function Invoke-WPFGetInstalled {
<#
TODO: Add the Option to use Chocolatey as Engine
.SYNOPSIS
Invokes the function that gets the checkboxes to check in a new runspace
@ -16,12 +16,12 @@ function Invoke-WPFGetInstalled {
return
}
if(((Test-WinUtilPackageManager -winget) -eq "not-installed") -and $checkbox -eq "winget") {
if(($sync.WPFpreferChocolatey.IsChecked -eq $false) -and ((Test-WinUtilPackageManager -winget) -eq "not-installed") -and $checkbox -eq "winget") {
return
}
Invoke-WPFRunspace -ArgumentList $checkbox -DebugPreference $DebugPreference -ScriptBlock {
param($checkbox, $DebugPreference)
$preferChoco = $sync.WPFpreferChocolatey.IsChecked
Invoke-WPFRunspace -ArgumentList $checkbox, $preferChoco -DebugPreference $DebugPreference -ScriptBlock {
param($checkbox, $preferChoco, $DebugPreference)
$sync.ProcessRunning = $true
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" })
@ -32,8 +32,12 @@ function Invoke-WPFGetInstalled {
if($checkbox -eq "tweaks") {
Write-Host "Getting Installed Tweaks..."
}
$Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox
if ($preferChoco -and $checkbox -eq "winget") {
$Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox "choco"
}
else{
$Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox
}
$sync.form.Dispatcher.invoke({
foreach($checkbox in $Checkboxes) {