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 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 return
} }
$preferChoco = $sync.WPFpreferChocolatey.IsChecked $preferChoco = $sync.ChocoRadioButton.IsChecked
$sync.ItemsControl.Dispatcher.Invoke([action]{ $sync.ItemsControl.Dispatcher.Invoke([action]{
$sync.ItemsControl.Items | ForEach-Object { $_.Visibility = [Windows.Visibility]::Collapsed} $sync.ItemsControl.Items | ForEach-Object { $_.Visibility = [Windows.Visibility]::Collapsed}
$null = $sync.itemsControl.Items.Add($sync.LoadingLabel) $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) [System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
return return
} }
$ChocoPreference = $($sync.WPFpreferChocolatey.IsChecked) $ChocoPreference = $($sync.ChocoRadioButton.IsChecked)
$installHandle = Invoke-WPFRunspace -ParameterList @(("PackagesToInstall", $PackagesToInstall),("ChocoPreference", $ChocoPreference)) -DebugPreference $DebugPreference -ScriptBlock { $installHandle = Invoke-WPFRunspace -ParameterList @(("PackagesToInstall", $PackagesToInstall),("ChocoPreference", $ChocoPreference)) -DebugPreference $DebugPreference -ScriptBlock {
param($PackagesToInstall, $ChocoPreference, $DebugPreference) param($PackagesToInstall, $ChocoPreference, $DebugPreference)
if ($PackagesToInstall.count -eq 1) { if ($PackagesToInstall.count -eq 1) {

View File

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

View File

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

View File

@ -29,7 +29,7 @@ function Invoke-WPFUnInstall {
$confirm = [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) $confirm = [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
if($confirm -eq "No") {return} if($confirm -eq "No") {return}
$ChocoPreference = $($sync.WPFpreferChocolatey.IsChecked) $ChocoPreference = $($sync.ChocoRadioButton.IsChecked)
Invoke-WPFRunspace -ArgumentList @(("PackagesToUninstall", $PackagesToUninstall),("ChocoPreference", $ChocoPreference)) -DebugPreference $DebugPreference -ScriptBlock { Invoke-WPFRunspace -ArgumentList @(("PackagesToUninstall", $PackagesToUninstall),("ChocoPreference", $ChocoPreference)) -DebugPreference $DebugPreference -ScriptBlock {
param($PackagesToUninstall, $ChocoPreference, $DebugPreference) 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)} $xaml.SelectNodes("//*[@Name]") | ForEach-Object {$sync["$("$($psitem.Name)")"] = $sync["Form"].FindName($psitem.Name)}
#Persist the Chocolatey preference across winutil restarts #Persist the Chocolatey preference across winutil restarts
#$ChocoPreferencePath = "$env:LOCALAPPDATA\winutil\preferChocolatey.ini" $ChocoPreferencePath = "$env:LOCALAPPDATA\winutil\preferChocolatey.ini"
#$sync.WPFpreferChocolatey.Add_Checked({New-Item -Path $ChocoPreferencePath -Force }) $sync.ChocoRadioButton.Add_Checked({New-Item -Path $ChocoPreferencePath -Force })
#$sync.WPFpreferChocolatey.Add_Unchecked({Remove-Item $ChocoPreferencePath -Force}) $sync.ChocoRadioButton.Add_Unchecked({Remove-Item $ChocoPreferencePath -Force})
#if (Test-Path $ChocoPreferencePath) { if (Test-Path $ChocoPreferencePath) {
# $sync.WPFpreferChocolatey.IsChecked = $true $sync.ChocoRadioButton.IsChecked = $true
#} }
$sync.keys | ForEach-Object { $sync.keys | ForEach-Object {
if($sync.$psitem) { if($sync.$psitem) {