Files
winutil/functions/public/Invoke-WPFButton.ps1
Gabi 7c71a39f7a Feature/appx removal tab (#4729)
* feat: add config-driven AppX package removal tab

- Add config/appx.json with curated list of removable AppX packages

- Add AppX Removal tab (WPFTab6) with Select All, Clear, and Remove buttons

- Reuse existing Invoke-WPFUIElements engine for minimal code footprint

- Add Invoke-WPFAppxRemoval.ps1 for background runspace package removal

- Add theme colors for the new tab button in light and dark modes

* yep

* yep

* yep

* yep

* Update inputXML.xaml

* Update Invoke-WPFButton.ps1

* Update Invoke-WPFButton.ps1

* Update Invoke-WPFSelectedCheckboxesUpdate.ps1

* Update appx.json

* Update appx.json

* Update appx.json

* Update tweaks.json

* Update appx.json

* Update appx.json

* Update appx.json

* Update Invoke-WPFAppxRemoval.ps1

* Update Invoke-WPFButton.ps1

* Delete functions/public/Invoke-WPFAppxRemoval.ps1

* Revert "Update Invoke-WPFButton.ps1"

This reverts commit d8705cc08e.

* Revert "Delete functions/public/Invoke-WPFAppxRemoval.ps1"

This reverts commit 9e45d1ad99.

* Update Invoke-WPFAppxRemoval.ps1

* Update Invoke-WPFAppxRemoval.ps1

* Update Invoke-WPFAppxRemoval.ps1

* Update Invoke-WPFButton.ps1

* yep

* Update appx.json

* Update appx.json

* Update tweaks.json

* Update start.ps1

* Update preset.json

* Update tweaks.json

* yep

* yep

* yep

* yep

* yep

* yep

* Update Invoke-WPFAppxRemoval.ps1

* Update Update-WinUtilSelections.ps1

* Update Update-WinUtilSelections.ps1

* yep

* Update Invoke-WPFAppxRemoval.ps1

* yep

* yep

* Update Invoke-WPFAppxRemoval.ps1

* Update appx.json

* Update Invoke-WPFAppxRemoval.ps1

* Update Invoke-WPFAppxRemoval.ps1

* Update appx.json

* Update Invoke-WPFGetInstalled.ps1

* Update Invoke-WPFAppxRemoval.ps1

* yep

* yep

* Update Invoke-WPFSelectedCheckboxesUpdate.ps1

* yep

* yep

* Update Invoke-WPFAppxRemoval.ps1

* Update Invoke-WPFAppxRemoval.ps1

* yep

* Update Invoke-WPFAppxRemoval.ps1

* Update Invoke-WPFAppxRemoval.ps1

* Update appx.json

* Update Invoke-WPFImpex.ps1

* Update Invoke-WPFImpex.ps1

* Update Invoke-WPFAppxRemoval.ps1

* Update preset.json

* Update preset.json

* Update Invoke-WPFSelectedCheckboxesUpdate.ps1

* Update Invoke-WPFAppxRemoval.ps1

* Update tweaks.json

* Update Invoke-WPFAppxRemoval.ps1

* Update Invoke-WPFAppxRemoval.ps1

* Update Invoke-WPFAppxRemoval.ps1

* Update Invoke-WPFAppxRemoval.ps1

* yep

* yep

* Update Invoke-WPFAppxRemoval.ps1

* yep

* Delete functions/private/Find-AppxByNameOrDescription.ps1

* yep

* Update Invoke-WPFButton.ps1

* Update main.ps1

* Update Invoke-WPFTab.ps1

* yep

* yep

* Update themes.json
2026-07-01 12:13:32 -05:00

89 lines
3.8 KiB
PowerShell

function Invoke-WPFButton {
<#
.SYNOPSIS
Invokes the function associated with the clicked button
.PARAMETER Button
The name of the button that was clicked
#>
Param ([string]$Button)
# Use this to get the name of the button
#[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info")
if (-not $sync.ProcessRunning) {
Set-WinUtilProgressBar -label "" -percent 0
}
# Check if button is defined in feature config with function or InvokeScript
if ($sync.configs.feature.$Button) {
$buttonConfig = $sync.configs.feature.$Button
# If button has a function defined, call it
if ($buttonConfig.function) {
$functionName = $buttonConfig.function
if (Get-Command $functionName -ErrorAction SilentlyContinue) {
& $functionName
return
}
}
# If button has InvokeScript defined, execute the scripts
if ($buttonConfig.InvokeScript -and $buttonConfig.InvokeScript.Count -gt 0) {
foreach ($script in $buttonConfig.InvokeScript) {
if (-not [string]::IsNullOrWhiteSpace($script)) {
Invoke-Expression $script
}
}
return
}
}
# Fallback to hard-coded switch for buttons not in feature.json
Switch -Wildcard ($Button) {
"WPFTab?BT" {Invoke-WPFTab $Button}
"WPFInstall" {Invoke-WPFInstall}
"WPFUninstall" {Invoke-WPFUnInstall}
"WPFInstallUpgrade" {Invoke-WPFInstallUpgrade}
"WPFCollapseAllCategories" {Invoke-WPFToggleAllCategories -Action "Collapse"}
"WPFExpandAllCategories" {Invoke-WPFToggleAllCategories -Action "Expand"}
"WPFStandard" {Invoke-WPFPresets "Standard" -checkboxfilterpattern "WPFTweak*"}
"WPFMinimal" {Invoke-WPFPresets "Minimal" -checkboxfilterpattern "WPFTweak*"}
"WPFAdvanced" {Invoke-WPFPresets "Advanced" -checkboxfilterpattern "WPFTweak*"}
"WPFClearTweaksSelection" {Invoke-WPFPresets -imported $true -checkboxfilterpattern "WPFTweak*"}
"WPFClearInstallSelection" {Invoke-WPFPresets -imported $true -checkboxfilterpattern "WPFInstall*"}
"WPFtweaksbutton" {Invoke-WPFtweaksbutton}
"WPFOOSUbutton" {Invoke-WPFOOSU}
"WPFAddUltPerf" {Invoke-WPFUltimatePerformance -Enable}
"WPFRemoveUltPerf" {Invoke-WPFUltimatePerformance}
"WPFundoall" {Invoke-WPFundoall}
"WPFUpdatesdefault" {Invoke-WPFUpdatesdefault}
"WPFUpdatesdisable" {Invoke-WPFUpdatesdisable}
"WPFUpdatessecurity" {Invoke-WPFUpdatessecurity}
"WPFGetInstalled" {Invoke-WPFGetInstalled -CheckBox "winget"}
"WPFGetInstalledTweaks" {Invoke-WPFGetInstalled -CheckBox "tweaks"}
"WPFRemoveSelectedAppx" {Invoke-WPFAppxRemoval}
"WPFDefaultAppxSelection" {Invoke-WPFPresets "AppxDefault" -checkboxfilterpattern "WPFAppx*"}
"WPFSelectAllAppx" {
$sync.configs.appxHashtable.Keys | ForEach-Object {$sync.$_.IsChecked = $true}
}
"WPFClearAppxSelection" {
$sync.configs.appxHashtable.Keys | ForEach-Object {$sync.$_.IsChecked = $false}
}
"WPFGetInstalledAppx" {
$installedAppxPackages = Get-AppxPackage -AllUsers | Select-Object -ExpandProperty Name
foreach ($appx in $sync.configs.appxHashtable.GetEnumerator()) {
if ($appx.Value.PackageId -in $installedAppxPackages) {
$sync.$($appx.Key).IsChecked = $true
}
}
}
"WPFCloseButton" {$sync.Form.Close(); Write-Host "Bye bye!"}
"WPFMinimizeButton" {$sync.Form.WindowState = [Windows.WindowState]::Minimized}
"WPFselectedAppsButton" {$sync.selectedAppsPopup.IsOpen = -not $sync.selectedAppsPopup.IsOpen}
}
}