mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-09 17:41:14 +10:00
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 commitd8705cc08e. * Revert "Delete functions/public/Invoke-WPFAppxRemoval.ps1" This reverts commit9e45d1ad99. * 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
This commit is contained in:
@@ -1,88 +1,17 @@
|
||||
function Invoke-WPFSelectedCheckboxesUpdate{
|
||||
<#
|
||||
.SYNOPSIS
|
||||
This is a helper function that is called by the Checked and Unchecked events of the Checkboxes.
|
||||
It also Updates the "Selected Apps" selectedAppLabel on the Install Tab to represent the current collection
|
||||
.PARAMETER type
|
||||
Either: Add | Remove
|
||||
.PARAMETER checkboxName
|
||||
should contain the name of the current instance of the checkbox that triggered the Event.
|
||||
Most of the time will be the automatic variable $this.Parent.Tag
|
||||
.EXAMPLE
|
||||
$checkbox.Add_Unchecked({Invoke-WPFSelectedCheckboxesUpdate -type "Remove" -checkboxName $this.Parent.Tag})
|
||||
OR
|
||||
Invoke-WPFSelectedCheckboxesUpdate -type "Add" -checkboxName $specificCheckbox.Parent.Tag
|
||||
#>
|
||||
param (
|
||||
$type,
|
||||
$checkboxName
|
||||
)
|
||||
|
||||
if (($type -ne "Add") -and ($type -ne "Remove"))
|
||||
{
|
||||
Write-Error "Type: $type not implemented"
|
||||
return
|
||||
function Invoke-WPFSelectedCheckboxesUpdate ($type, $checkboxName) {
|
||||
$listName = switch -Regex ($checkboxName) {
|
||||
'^WPFInstall' { 'selectedApps' }
|
||||
'^WPFTweaks' { 'selectedTweaks' }
|
||||
'^WPFToggle' { 'selectedToggles' }
|
||||
'^WPFFeature' { 'selectedFeatures' }
|
||||
'^WPFAppx' { 'selectedAppx' }
|
||||
}
|
||||
|
||||
# Get the actual Name from the selectedAppLabel inside the Checkbox
|
||||
$appKey = $checkboxName
|
||||
$group = if ($appKey.StartsWith("WPFInstall")) { "Install" }
|
||||
elseif ($appKey.StartsWith("WPFTweaks")) { "Tweaks" }
|
||||
elseif ($appKey.StartsWith("WPFToggle")) { "Toggle" }
|
||||
elseif ($appKey.StartsWith("WPFFeature")) { "Feature" }
|
||||
else { "na" }
|
||||
|
||||
switch ($group) {
|
||||
"Install" {
|
||||
if ($type -eq "Add") {
|
||||
if (!$sync.selectedApps.Contains($appKey)) {
|
||||
$sync.selectedApps.Add($appKey)
|
||||
# The List type needs to be specified again, because otherwise Sort-Object will convert the list to a string if there is only a single entry
|
||||
[System.Collections.Generic.List[string]]$sync.selectedApps = $sync.SelectedApps | Sort-Object
|
||||
}
|
||||
}
|
||||
else{
|
||||
$sync.selectedApps.Remove($appKey)
|
||||
}
|
||||
|
||||
$count = $sync.SelectedApps.Count
|
||||
$sync.WPFselectedAppsButton.Content = "Selected Apps: $count"
|
||||
# On every change, remove all entries inside the Popup Menu. This is done, so we can keep the alphabetical order even if elements are selected in a random way
|
||||
$sync.selectedAppsstackPanel.Children.Clear()
|
||||
$sync.selectedApps | Foreach-Object { Add-SelectedAppsMenuItem -name $($sync.configs.applicationsHashtable.$_.Content) -key $_ }
|
||||
}
|
||||
"Tweaks" {
|
||||
if ($type -eq "Add") {
|
||||
if (!$sync.selectedTweaks.Contains($appKey)) {
|
||||
$sync.selectedTweaks.Add($appKey)
|
||||
}
|
||||
}
|
||||
else{
|
||||
$sync.selectedTweaks.Remove($appKey)
|
||||
}
|
||||
}
|
||||
"Toggle" {
|
||||
if ($type -eq "Add") {
|
||||
if (!$sync.selectedToggles.Contains($appKey)) {
|
||||
$sync.selectedToggles.Add($appKey)
|
||||
}
|
||||
}
|
||||
else{
|
||||
$sync.selectedToggles.Remove($appKey)
|
||||
}
|
||||
}
|
||||
"Feature" {
|
||||
if ($type -eq "Add") {
|
||||
if (!$sync.selectedFeatures.Contains($appKey)) {
|
||||
$sync.selectedFeatures.Add($appKey)
|
||||
}
|
||||
}
|
||||
else{
|
||||
$sync.selectedFeatures.Remove($appKey)
|
||||
}
|
||||
}
|
||||
default {
|
||||
Write-Host "Unknown group for checkbox: $($appKey)"
|
||||
if ($type -eq "Add") {
|
||||
if (-not $sync.$listName.Contains($checkboxName)) {
|
||||
$sync.$listName.Add($checkboxName)
|
||||
}
|
||||
} else {
|
||||
$sync.$listName.Remove($checkboxName)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user