From f98d3be85e0d3ca40af07cfbe0fec426c02908b2 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Fri, 25 Oct 2024 13:11:53 +0300 Subject: [PATCH 1/3] Improve 'Invoke-WPFTab' Parameter by specifying its type (as expected by the function) and make it Mandatory --- functions/public/Invoke-WPFTab.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/public/Invoke-WPFTab.ps1 b/functions/public/Invoke-WPFTab.ps1 index 7333467f..8b3771b2 100644 --- a/functions/public/Invoke-WPFTab.ps1 +++ b/functions/public/Invoke-WPFTab.ps1 @@ -10,7 +10,10 @@ function Invoke-WPFTab { #> - Param ($ClickedTab) + Param ( + [Parameter(Mandatory,position=0)] + [string]$ClickedTab + ) $tabNav = Get-WinUtilVariables | Where-Object {$psitem -like "WPFTabNav"} $tabNumber = [int]($ClickedTab -replace "WPFTab","" -replace "BT","") - 1 From c0e8a14c8ee75b08a9d4bbedd3bdec18a2898dfb Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Fri, 25 Oct 2024 13:12:59 +0300 Subject: [PATCH 2/3] Simple performance increases in 'Invoke-WPFTab' function - Use where method instead of piping the result into Where-Object --- functions/public/Invoke-WPFTab.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/public/Invoke-WPFTab.ps1 b/functions/public/Invoke-WPFTab.ps1 index 8b3771b2..43727570 100644 --- a/functions/public/Invoke-WPFTab.ps1 +++ b/functions/public/Invoke-WPFTab.ps1 @@ -19,7 +19,7 @@ function Invoke-WPFTab { $tabNumber = [int]($ClickedTab -replace "WPFTab","" -replace "BT","") - 1 $filter = Get-WinUtilVariables -Type ToggleButton | Where-Object {$psitem -like "WPFTab?BT"} - $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} | ForEach-Object { + ($sync.GetEnumerator()).where{$psitem.Key -in $filter} | ForEach-Object { if ($ClickedTab -ne $PSItem.name) { $sync[$PSItem.Name].IsChecked = $false # $tabNumber = [int]($PSItem.Name -replace "WPFTab","" -replace "BT","") - 1 From 85d8db1c4e21ea9cd82e08db049db0626a125456 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Fri, 25 Oct 2024 13:13:25 +0300 Subject: [PATCH 3/3] Remove commented-out code in 'Invoke-WPFTab' function --- functions/public/Invoke-WPFTab.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/public/Invoke-WPFTab.ps1 b/functions/public/Invoke-WPFTab.ps1 index 43727570..15d64bbd 100644 --- a/functions/public/Invoke-WPFTab.ps1 +++ b/functions/public/Invoke-WPFTab.ps1 @@ -22,8 +22,6 @@ function Invoke-WPFTab { ($sync.GetEnumerator()).where{$psitem.Key -in $filter} | ForEach-Object { if ($ClickedTab -ne $PSItem.name) { $sync[$PSItem.Name].IsChecked = $false - # $tabNumber = [int]($PSItem.Name -replace "WPFTab","" -replace "BT","") - 1 - # $sync.$tabNav.Items[$tabNumber].IsSelected = $false } else { $sync["$ClickedTab"].IsChecked = $true $tabNumber = [int]($ClickedTab-replace "WPFTab","" -replace "BT","") - 1