Skip to content

Commit

Permalink
Re-Add Choco Preference
Browse files Browse the repository at this point in the history
  • Loading branch information
Marterich committed Oct 13, 2024
1 parent cf664bd commit f05fece
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions functions/public/Invoke-WPFGetInstalled.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion functions/public/Invoke-WPFInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion functions/public/Invoke-WPFInstallUpgrade.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion functions/public/Invoke-WPFUIApps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion functions/public/Invoke-WPFUnInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f05fece

Please sign in to comment.