Files
winutil/functions/public/Invoke-WPFButton.ps1
T

89 lines
3.8 KiB
PowerShell
Raw Normal View History

+3
2023-03-07 12:28:00 -08:00
function Invoke-WPFButton {
<#
2023-10-19 17:12:55 -05:00
.SYNOPSIS
Invokes the function associated with the clicked button
.PARAMETER Button
The name of the button that was clicked
+3
2023-03-07 12:28:00 -08:00
#>
2023-10-19 17:12:55 -05:00
Param ([string]$Button)
# Use this to get the name of the button
+3
2023-03-07 12:28:00 -08:00
#[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info")
if (-not $sync.ProcessRunning) {
Set-WinUtilProgressBar -label "" -percent 0
}
2024-08-06 15:50:36 -05:00
2026-02-22 17:19:04 -06:00
# 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) {
+3
2023-03-07 12:28:00 -08:00
"WPFTab?BT" {Invoke-WPFTab $Button}
"WPFInstall" {Invoke-WPFInstall}
"WPFUninstall" {Invoke-WPFUnInstall}
+3
2023-03-07 12:28:00 -08:00
"WPFInstallUpgrade" {Invoke-WPFInstallUpgrade}
2026-02-06 10:26:29 -06:00
"WPFCollapseAllCategories" {Invoke-WPFToggleAllCategories -Action "Collapse"}
"WPFExpandAllCategories" {Invoke-WPFToggleAllCategories -Action "Expand"}
"WPFStandard" {Invoke-WPFPresets "Standard" -checkboxfilterpattern "WPFTweak*"}
"WPFMinimal" {Invoke-WPFPresets "Minimal" -checkboxfilterpattern "WPFTweak*"}
2026-05-26 13:21:12 -07:00
"WPFAdvanced" {Invoke-WPFPresets "Advanced" -checkboxfilterpattern "WPFTweak*"}
"WPFClearTweaksSelection" {Invoke-WPFPresets -imported $true -checkboxfilterpattern "WPFTweak*"}
2025-05-12 22:45:57 +02:00
"WPFClearInstallSelection" {Invoke-WPFPresets -imported $true -checkboxfilterpattern "WPFInstall*"}
+3
2023-03-07 12:28:00 -08:00
"WPFtweaksbutton" {Invoke-WPFtweaksbutton}
2024-06-25 21:37:34 +02:00
"WPFOOSUbutton" {Invoke-WPFOOSU}
2026-05-26 13:00:33 -07:00
"WPFAddUltPerf" {Invoke-WPFUltimatePerformance -Enable}
"WPFRemoveUltPerf" {Invoke-WPFUltimatePerformance}
+3
2023-03-07 12:28:00 -08:00
"WPFundoall" {Invoke-WPFundoall}
2025-09-05 09:52:20 -05:00
"WPFUpdatesdefault" {Invoke-WPFUpdatesdefault}
+3
2023-03-07 12:28:00 -08:00
"WPFUpdatesdisable" {Invoke-WPFUpdatesdisable}
"WPFUpdatessecurity" {Invoke-WPFUpdatessecurity}
+2
2023-05-09 13:14:27 -05:00
"WPFGetInstalled" {Invoke-WPFGetInstalled -CheckBox "winget"}
"WPFGetInstalledTweaks" {Invoke-WPFGetInstalled -CheckBox "tweaks"}
2026-07-01 20:13:32 +03:00
"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
}
}
}
2026-02-22 17:19:04 -06:00
"WPFCloseButton" {$sync.Form.Close(); Write-Host "Bye bye!"}
"WPFMinimizeButton" {$sync.Form.WindowState = [Windows.WindowState]::Minimized}
2025-05-12 22:45:57 +02:00
"WPFselectedAppsButton" {$sync.selectedAppsPopup.IsOpen = -not $sync.selectedAppsPopup.IsOpen}
+3
2023-03-07 12:28:00 -08:00
}
}