From f05fece2e544dfb06ecc9ffaeb2f6485ea924b07 Mon Sep 17 00:00:00 2001 From: Marterich <47688561+Marterich@users.noreply.github.com> Date: Sun, 13 Oct 2024 20:45:26 +0200 Subject: [PATCH] Re-Add Choco Preference --- functions/public/Invoke-WPFGetInstalled.ps1 | 4 ++-- functions/public/Invoke-WPFInstall.ps1 | 2 +- functions/public/Invoke-WPFInstallUpgrade.ps1 | 2 +- functions/public/Invoke-WPFUIApps.ps1 | 2 +- functions/public/Invoke-WPFUnInstall.ps1 | 2 +- scripts/main.ps1 | 12 ++++++------ 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/functions/public/Invoke-WPFGetInstalled.ps1 b/functions/public/Invoke-WPFGetInstalled.ps1 index 7b72f95ea2..f90f3affc7 100644 --- a/functions/public/Invoke-WPFGetInstalled.ps1 +++ b/functions/public/Invoke-WPFGetInstalled.ps1 @@ -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) diff --git a/functions/public/Invoke-WPFInstall.ps1 b/functions/public/Invoke-WPFInstall.ps1 index dd361b1578..f51bb5900a 100644 --- a/functions/public/Invoke-WPFInstall.ps1 +++ b/functions/public/Invoke-WPFInstall.ps1 @@ -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) { diff --git a/functions/public/Invoke-WPFInstallUpgrade.ps1 b/functions/public/Invoke-WPFInstallUpgrade.ps1 index c86ee12327..c914d02358 100644 --- a/functions/public/Invoke-WPFInstallUpgrade.ps1 +++ b/functions/public/Invoke-WPFInstallUpgrade.ps1 @@ -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) { diff --git a/functions/public/Invoke-WPFUIApps.ps1 b/functions/public/Invoke-WPFUIApps.ps1 index f5f4d6e0a7..f1fcc7a0d0 100644 --- a/functions/public/Invoke-WPFUIApps.ps1 +++ b/functions/public/Invoke-WPFUIApps.ps1 @@ -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) diff --git a/functions/public/Invoke-WPFUnInstall.ps1 b/functions/public/Invoke-WPFUnInstall.ps1 index 41796df325..45bf1b21be 100644 --- a/functions/public/Invoke-WPFUnInstall.ps1 +++ b/functions/public/Invoke-WPFUnInstall.ps1 @@ -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) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 58bb93e4a5..8e473ad230 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -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) {