mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-22 05:51:30 -06:00
e2b9586b0d
* Improve 'Invoke-WPFTab' Parameter by specifying its type (as expected by the function) and make it Mandatory * Simple performance increases in 'Invoke-WPFTab' function - Use where method instead of piping the result into Where-Object * Remove commented-out code in 'Invoke-WPFTab' function
32 lines
937 B
PowerShell
32 lines
937 B
PowerShell
function Invoke-WPFTab {
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Sets the selected tab to the tab that was clicked
|
|
|
|
.PARAMETER ClickedTab
|
|
The name of the tab that was clicked
|
|
|
|
#>
|
|
|
|
Param (
|
|
[Parameter(Mandatory,position=0)]
|
|
[string]$ClickedTab
|
|
)
|
|
|
|
$tabNav = Get-WinUtilVariables | Where-Object {$psitem -like "WPFTabNav"}
|
|
$tabNumber = [int]($ClickedTab -replace "WPFTab","" -replace "BT","") - 1
|
|
|
|
$filter = Get-WinUtilVariables -Type ToggleButton | Where-Object {$psitem -like "WPFTab?BT"}
|
|
($sync.GetEnumerator()).where{$psitem.Key -in $filter} | ForEach-Object {
|
|
if ($ClickedTab -ne $PSItem.name) {
|
|
$sync[$PSItem.Name].IsChecked = $false
|
|
} else {
|
|
$sync["$ClickedTab"].IsChecked = $true
|
|
$tabNumber = [int]($ClickedTab-replace "WPFTab","" -replace "BT","") - 1
|
|
$sync.$tabNav.Items[$tabNumber].IsSelected = $true
|
|
}
|
|
}
|
|
}
|