mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-16 01:40:35 -06:00
Improve 'Invoke-WPFPresets.ps1' Public Function as well as Simple Optimizations
This commit is contained in:
parent
bcfbce66fd
commit
039b5aa10c
@ -26,8 +26,8 @@ function Invoke-WPFButton {
|
|||||||
"WPFInstallUpgrade" {Invoke-WPFInstallUpgrade}
|
"WPFInstallUpgrade" {Invoke-WPFInstallUpgrade}
|
||||||
"WPFstandard" {Invoke-WPFPresets "Standard"}
|
"WPFstandard" {Invoke-WPFPresets "Standard"}
|
||||||
"WPFminimal" {Invoke-WPFPresets "Minimal"}
|
"WPFminimal" {Invoke-WPFPresets "Minimal"}
|
||||||
"WPFclear" {Invoke-WPFPresets -preset $null -imported $true}
|
"WPFclear" {Invoke-WPFPresets -imported $true -checkboxfilterpattern "WPFTweak*"}
|
||||||
"WPFclearWinget" {Invoke-WPFPresets -preset $null -imported $true -CheckBox "WPFInstall"}
|
"WPFclearWinget" {Invoke-WPFPresets -imported $true -checkboxfilterpattern "WPFInstall*"}
|
||||||
"WPFtweaksbutton" {Invoke-WPFtweaksbutton}
|
"WPFtweaksbutton" {Invoke-WPFtweaksbutton}
|
||||||
"WPFOOSUbutton" {Invoke-WPFOOSU}
|
"WPFOOSUbutton" {Invoke-WPFOOSU}
|
||||||
"WPFAddUltPerf" {Invoke-WPFUltimatePerformance -State "Enable"}
|
"WPFAddUltPerf" {Invoke-WPFUltimatePerformance -State "Enable"}
|
||||||
|
@ -10,29 +10,36 @@ function Invoke-WPFPresets {
|
|||||||
.PARAMETER imported
|
.PARAMETER imported
|
||||||
If the preset is imported from a file, defaults to false
|
If the preset is imported from a file, defaults to false
|
||||||
|
|
||||||
.PARAMETER checkbox
|
.PARAMETER checkboxfilterpattern
|
||||||
The checkbox to set the options to, defaults to 'WPFTweaks'
|
The Pattern to use when filtering through CheckBoxes, defaults to "**"
|
||||||
|
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param(
|
param (
|
||||||
$preset,
|
[Parameter(position=0)]
|
||||||
[bool]$imported = $false
|
[string]$preset,
|
||||||
|
|
||||||
|
[Parameter(position=1)]
|
||||||
|
[bool]$imported = $false,
|
||||||
|
|
||||||
|
[Parameter(position=2)]
|
||||||
|
[string]$checkboxfilterpattern = "**"
|
||||||
)
|
)
|
||||||
|
|
||||||
if($imported -eq $true) {
|
if ($imported -eq $true) {
|
||||||
$CheckBoxesToCheck = $preset
|
$CheckBoxesToCheck = $preset
|
||||||
} else {
|
} else {
|
||||||
$CheckBoxesToCheck = $sync.configs.preset.$preset
|
$CheckBoxesToCheck = $sync.configs.preset.$preset
|
||||||
}
|
}
|
||||||
|
|
||||||
$CheckBoxes = $sync.GetEnumerator() | Where-Object { $_.Value -is [System.Windows.Controls.CheckBox] -and $_.Name -notlike "WPFToggle*" }
|
$CheckBoxes = ($sync.GetEnumerator()).where{ $_.Value -is [System.Windows.Controls.CheckBox] -and $_.Name -notlike "WPFToggle*" -and $_.Name -like "$checkboxfilterpattern"}
|
||||||
Write-Debug "Getting checkboxes to set $($CheckBoxes.Count)"
|
Write-Debug "Getting checkboxes to set, number of checkboxes: $($CheckBoxes.Count)"
|
||||||
|
|
||||||
$CheckBoxesToCheck | ForEach-Object {
|
if ($CheckBoxesToCheck -ne $null) {
|
||||||
if ($_ -ne $null) {
|
$debugMsg = "CheckBoxes to Check are: "
|
||||||
Write-Debug $_
|
$CheckBoxesToCheck | ForEach-Object { $debugMsg += "$_, " }
|
||||||
}
|
$debugMsg = $debugMsg -replace (',\s*$', '')
|
||||||
|
Write-Debug "$debugMsg"
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($CheckBox in $CheckBoxes) {
|
foreach ($CheckBox in $CheckBoxes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user