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
This commit is contained in:
GabiNun2
2026-06-21 17:57:41 +03:00
parent 58a81b106c
commit e8c1401cce
9 changed files with 300 additions and 0 deletions
@@ -0,0 +1,50 @@
function Invoke-WPFAppxRemoval {
<#
.SYNOPSIS
Removes the selected AppX packages in a background runspace.
#>
if ($sync.ProcessRunning) {
$msg = "A process is currently running. Please wait for it to finish."
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
return
}
$selected = @($sync.selectedAppx)
if ($selected.Count -eq 0) {
$msg = "Please select the AppX packages you wish to remove."
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
return
}
$totalSteps = $selected.Count
$completedSteps = 0
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" }
$handle = Invoke-WPFRunspace -ParameterList @(("selected", $selected), ("completedSteps", $completedSteps), ("totalSteps", $totalSteps)) -ScriptBlock {
param($selected, $completedSteps, $totalSteps)
$sync.ProcessRunning = $true
for ($i = 0; $i -lt $selected.Count; $i++) {
$key = $selected[$i]
$appInfo = $sync.configs.appxHashtable.$key
$packageId = $appInfo.PackageId
$friendlyName = $appInfo.content
Set-WinUtilProgressBar -Label "Removing $friendlyName" -Percent ($completedSteps / $totalSteps * 100)
Remove-WinUtilAPPX -Name $packageId
$completedSteps++
$progress = $completedSteps / $totalSteps
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -value $progress }
}
Set-WinUtilProgressBar -Label "AppX Removal finished" -Percent 100
$sync.ProcessRunning = $false
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" }
Write-Host "================================="
Write-Host "-- AppX Removal Finished ---"
Write-Host "================================="
}
}
+17
View File
@@ -65,6 +65,23 @@ function Invoke-WPFButton {
"WPFUpdatessecurity" {Invoke-WPFUpdatessecurity}
"WPFGetInstalled" {Invoke-WPFGetInstalled -CheckBox "winget"}
"WPFGetInstalledTweaks" {Invoke-WPFGetInstalled -CheckBox "tweaks"}
"WPFSelectAllAppx" {
$sync.configs.appxHashtable.Keys | ForEach-Object {
if ($sync.$_) {
$sync.$_.IsChecked = $true
}
}
}
"WPFClearAppxSelection" {
$sync.configs.appxHashtable.Keys | ForEach-Object {
if ($sync.$_) {
$sync.$_.IsChecked = $false
}
}
}
"WPFRemoveSelectedAppx" {
Invoke-WPFAppxRemoval
}
"WPFCloseButton" {$sync.Form.Close(); Write-Host "Bye bye!"}
"WPFMinimizeButton" {$sync.Form.WindowState = [Windows.WindowState]::Minimized}
"WPFselectedAppsButton" {$sync.selectedAppsPopup.IsOpen = -not $sync.selectedAppsPopup.IsOpen}
@@ -30,6 +30,7 @@ function Invoke-WPFSelectedCheckboxesUpdate{
elseif ($appKey.StartsWith("WPFTweaks")) { "Tweaks" }
elseif ($appKey.StartsWith("WPFToggle")) { "Toggle" }
elseif ($appKey.StartsWith("WPFFeature")) { "Feature" }
elseif ($appKey.StartsWith("WPFAppx")) { "Appx" }
else { "na" }
switch ($group) {
@@ -81,6 +82,16 @@ function Invoke-WPFSelectedCheckboxesUpdate{
$sync.selectedFeatures.Remove($appKey)
}
}
"Appx" {
if ($type -eq "Add") {
if (!$sync.selectedAppx.Contains($appKey)) {
$sync.selectedAppx.Add($appKey)
}
}
else{
$sync.selectedAppx.Remove($appKey)
}
}
default {
Write-Host "Unknown group for checkbox: $($appKey)"
}