mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-06-04 14:17:27 +00:00
8034e85521
* Update Invoke-WinUtilCurrentSystem.ps1 * Update Invoke-WinUtilFontScaling.ps1 * Update Invoke-WinUtilTweaks.ps1 * Update Reset-WPFCheckBoxes.ps1 * Update Set-Preferences.ps1 * Update Update-WinUtilSelections.ps1 * Update Invoke-WPFSelectedCheckboxesUpdate.ps1 * Update Invoke-WPFtweaksbutton.ps1 * Update main.ps1 * Update main.ps1 * Update main.ps1 * Update main.ps1 * Update main.ps1 * Merge branch 'main' into Remove-Write-Debug
53 lines
1.8 KiB
PowerShell
53 lines
1.8 KiB
PowerShell
function Update-WinUtilSelections {
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Updates the $sync.selected variables with a given preset.
|
|
|
|
.PARAMETER flatJson
|
|
The flattened json list of $sync values to select.
|
|
#>
|
|
|
|
param (
|
|
$flatJson
|
|
)
|
|
|
|
foreach ($item in $flatJson) {
|
|
# Ensure each item is treated as a string to handle PSCustomObject from JSON deserialization
|
|
$cbkey = [string]$item
|
|
$group = if ($cbkey.StartsWith("WPFInstall")) { "Install" }
|
|
elseif ($cbkey.StartsWith("WPFTweaks")) { "Tweaks" }
|
|
elseif ($cbkey.StartsWith("WPFToggle")) { "Toggle" }
|
|
elseif ($cbkey.StartsWith("WPFFeature")) { "Feature" }
|
|
else { "na" }
|
|
|
|
switch ($group) {
|
|
"Install" {
|
|
if (!$sync.selectedApps.Contains($cbkey)) {
|
|
$sync.selectedApps.Add($cbkey)
|
|
# 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
|
|
}
|
|
}
|
|
"Tweaks" {
|
|
if (!$sync.selectedTweaks.Contains($cbkey)) {
|
|
$sync.selectedTweaks.Add($cbkey)
|
|
}
|
|
}
|
|
"Toggle" {
|
|
if (!$sync.selectedToggles.Contains($cbkey)) {
|
|
$sync.selectedToggles.Add($cbkey)
|
|
}
|
|
}
|
|
"Feature" {
|
|
if (!$sync.selectedFeatures.Contains($cbkey)) {
|
|
$sync.selectedFeatures.Add($cbkey)
|
|
}
|
|
}
|
|
default {
|
|
Write-Host "Unknown group for checkbox: $($cbkey)"
|
|
}
|
|
}
|
|
}
|
|
}
|