winutil/functions/private/Get-WPFObjectName.ps1
Martin Wiethan 0ec64eaf74
Optimize Display Behaviour of Category Labels (#1979)
* Hide Category title if empty

* Changed labels to a hashtable for faster access

* Extract WPFNamecreation to function, fix hide all if none match
2024-06-03 21:05:28 -07:00

27 lines
902 B
PowerShell

function Get-WPFObjectName {
<#
.SYNOPSIS
This is a helper function that generates an objectname with the prefix WPF that can be used as a Powershell Variable after compilation.
To achieve this, all characters that are not a-z, A-Z or 0-9 are simply removed from the name.
.PARAMETER type
The type of object for which the name should be generated. (e.g. Label, Button, CheckBox...)
.PARAMETER name
The name or description to be used for the object. (invalid characters are removed)
.OUTPUTS
A string that can be used as a object/variable name in powershell.
For example: WPFLabelMicrosoftTools
.EXAMPLE
Get-WPFObjectName -type Label -name "Microsoft Tools"
#>
param( [Parameter(Mandatory=$true)]
$type,
$name
)
$Output = $("WPF"+$type+$name) -replace '[^a-zA-Z0-9]', ''
return $Output
}