Re-Add Choco Preference

This commit is contained in:
Marterich 2024-10-13 20:45:26 +02:00
parent cf664bd1d3
commit f05fece2e5
6 changed files with 12 additions and 12 deletions

View File

@ -16,10 +16,10 @@ function Invoke-WPFGetInstalled {
return
}
if(($sync.WPFpreferChocolatey.IsChecked -eq $false) -and ((Test-WinUtilPackageManager -winget) -eq "not-installed") -and $checkbox -eq "winget") {
if(($sync.ChocoRadioButton.IsChecked -eq $false) -and ((Test-WinUtilPackageManager -winget) -eq "not-installed") -and $checkbox -eq "winget") {
return
}
$preferChoco = $sync.WPFpreferChocolatey.IsChecked
$preferChoco = $sync.ChocoRadioButton.IsChecked
$sync.ItemsControl.Dispatcher.Invoke([action]{
$sync.ItemsControl.Items | ForEach-Object { $_.Visibility = [Windows.Visibility]::Collapsed}
$null = $sync.itemsControl.Items.Add($sync.LoadingLabel)

View File

@ -21,7 +21,7 @@ function Invoke-WPFInstall {
[System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
return
}
$ChocoPreference = $($sync.WPFpreferChocolatey.IsChecked)
$ChocoPreference = $($sync.ChocoRadioButton.IsChecked)
$installHandle = Invoke-WPFRunspace -ParameterList @(("PackagesToInstall", $PackagesToInstall),("ChocoPreference", $ChocoPreference)) -DebugPreference $DebugPreference -ScriptBlock {
param($PackagesToInstall, $ChocoPreference, $DebugPreference)
if ($PackagesToInstall.count -eq 1) {

View File

@ -5,7 +5,7 @@ function Invoke-WPFInstallUpgrade {
Invokes the function that upgrades all installed programs
#>
if ($sync.WPFpreferChocolatey.IsChecked) {
if ($sync.ChocoRadioButton.IsChecked) {
Install-WinUtilChoco
$chocoUpgradeStatus = (Start-Process "choco" -ArgumentList "upgrade all -y" -Wait -PassThru -NoNewWindow).ExitCode
if ($chocoUpgradeStatus -eq 0) {

View File

@ -229,7 +229,7 @@ function Invoke-WPFUIApps {
$loadingLabel.SetResourceReference([Windows.Controls.Control]::FontSizeProperty, "FontSizeHeading")
$loadingLabel.FontWeight = [Windows.FontWeights]::Bold
$loadingLabel.Foreground = [Windows.Media.Brushes]::Gray
$sync.LoadingLabel = $
$sync.LoadingLabel = $loadingLabel
$itemsControl.Items.Clear()
$null = $itemsControl.Items.Add($sync.LoadingLabel)

View File

@ -29,7 +29,7 @@ function Invoke-WPFUnInstall {
$confirm = [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
if($confirm -eq "No") {return}
$ChocoPreference = $($sync.WPFpreferChocolatey.IsChecked)
$ChocoPreference = $($sync.ChocoRadioButton.IsChecked)
Invoke-WPFRunspace -ArgumentList @(("PackagesToUninstall", $PackagesToUninstall),("ChocoPreference", $ChocoPreference)) -DebugPreference $DebugPreference -ScriptBlock {
param($PackagesToUninstall, $ChocoPreference, $DebugPreference)

View File

@ -149,12 +149,12 @@ $sync.SortbyAlphabet.Add_Checked({
$xaml.SelectNodes("//*[@Name]") | ForEach-Object {$sync["$("$($psitem.Name)")"] = $sync["Form"].FindName($psitem.Name)}
#Persist the Chocolatey preference across winutil restarts
#$ChocoPreferencePath = "$env:LOCALAPPDATA\winutil\preferChocolatey.ini"
#$sync.WPFpreferChocolatey.Add_Checked({New-Item -Path $ChocoPreferencePath -Force })
#$sync.WPFpreferChocolatey.Add_Unchecked({Remove-Item $ChocoPreferencePath -Force})
#if (Test-Path $ChocoPreferencePath) {
# $sync.WPFpreferChocolatey.IsChecked = $true
#}
$ChocoPreferencePath = "$env:LOCALAPPDATA\winutil\preferChocolatey.ini"
$sync.ChocoRadioButton.Add_Checked({New-Item -Path $ChocoPreferencePath -Force })
$sync.ChocoRadioButton.Add_Unchecked({Remove-Item $ChocoPreferencePath -Force})
if (Test-Path $ChocoPreferencePath) {
$sync.ChocoRadioButton.IsChecked = $true
}
$sync.keys | ForEach-Object {
if($sync.$psitem) {