From 4c6990b515bb7623dcc22180590e0f152d6cadff Mon Sep 17 00:00:00 2001 From: MyDrift Date: Thu, 15 Aug 2024 22:30:57 +0200 Subject: [PATCH] filter out unneeded categories --- functions/public/Invoke-WPFUIElements.ps1 | 2 -- scripts/main.ps1 | 13 +++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/functions/public/Invoke-WPFUIElements.ps1 b/functions/public/Invoke-WPFUIElements.ps1 index 1fe5e462..f92e6f3d 100644 --- a/functions/public/Invoke-WPFUIElements.ps1 +++ b/functions/public/Invoke-WPFUIElements.ps1 @@ -87,7 +87,6 @@ function Invoke-WPFUIElements { # Only apply the logic for distributing entries across columns if the targetGridName is "appspanel" if ($targetGridName -eq "appspanel") { $panelcount = 0 - $paneltotal = $columncount # Use columncount for even distribution $entrycount = $configHashtable.Keys.Count + $organizedData["0"].Keys.Count $maxcount = [Math]::Round($entrycount / $columncount + 0.5) } @@ -139,7 +138,6 @@ function Invoke-WPFUIElements { $stackPanel.Children.Add($label) | Out-Null $sync[$category] = $label - write-host $sync[$category] # Sort entries by Order and then by Name, but only display Name $entries = $organizedData[$panelKey][$category] | Sort-Object Order, Name diff --git a/scripts/main.ps1 b/scripts/main.ps1 index fb30af7d..63ad6006 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -410,6 +410,19 @@ $sync["SearchBar"].Add_TextChanged({ } } } + + $activeCategories = $activeApplications | Select-Object -ExpandProperty category -Unique + + foreach ($category in $activeCategories) { + $sync[$category].Visibility = "Visible" + } + if ($activeCategories) { + $inactiveCategories = Compare-Object -ReferenceObject $allCategories -DifferenceObject $activeCategories -PassThru + } else { + $inactiveCategories = $allCategories + } + foreach ($category in $inactiveCategories) { + $sync[$category].Visibility = "Collapsed"} }) # Initialize the hashtable