diff --git a/functions/private/Get-TabXaml.ps1 b/functions/private/Get-TabXaml.ps1
index a420e344..bda4d836 100644
--- a/functions/private/Get-TabXaml.ps1
+++ b/functions/private/Get-TabXaml.ps1
@@ -77,7 +77,10 @@ function Get-TabXaml {
$panelcount++
}
}
- $blockXml += "`n"
+ $categorycontent = $($category -replace '^.__', '')
+ # Remove all special Characters from the name because it will later be used as a Powershell Variable
+ $categoryname = "WPFLabel"+$($categorycontent -replace '[^a-zA-Z0-9]','')
+ $blockXml += "`n"
$sortedApps = $organizedData[$panel][$category].Keys | Sort-Object
foreach ($appName in $sortedApps) {
$count++
diff --git a/scripts/main.ps1 b/scripts/main.ps1
index 38007969..5c430b7b 100644
--- a/scripts/main.ps1
+++ b/scripts/main.ps1
@@ -363,6 +363,15 @@ Add-Type @"
})
+# Load Checkboxes and Labels outside of the Filter fuction only once on startup for performance reasons
+$filter = Get-WinUtilVariables -Type CheckBox
+$CheckBoxes = $sync.GetEnumerator() | Where-Object { $psitem.Key -in $filter }
+
+$filter = Get-WinUtilVariables -Type Label
+$labels = $sync.GetEnumerator() | Where-Object {$PSItem.Key -in $filter}
+
+$allCategories = $checkBoxes.Name | ForEach-Object {$sync.configs.applications.$_} | Select-Object -Unique -ExpandProperty category
+
$sync["CheckboxFilter"].Add_TextChanged({
if ($sync.CheckboxFilter.Text -ne "") {
@@ -372,8 +381,7 @@ $sync["CheckboxFilter"].Add_TextChanged({
$sync.CheckboxFilterClear.Visibility = "Collapsed"
}
- $filter = Get-WinUtilVariables -Type CheckBox
- $CheckBoxes = $sync.GetEnumerator() | Where-Object { $psitem.Key -in $filter }
+ $activeApplications = @()
foreach ($CheckBox in $CheckBoxes) {
# Check if the checkbox is null or if it doesn't have content
@@ -390,6 +398,7 @@ $sync["CheckboxFilter"].Add_TextChanged({
if ($CheckBox.Value.Content.ToLower().Contains($textToSearch)) {
$CheckBox.Value.Visibility = "Visible"
+ $activeApplications += $sync.configs.applications.$checkboxName
# Set the corresponding text block visibility
if ($textBlock -ne $null) {
$textBlock.Visibility = "Visible"
@@ -403,6 +412,18 @@ $sync["CheckboxFilter"].Add_TextChanged({
}
}
}
+ $activeCategories = $activeApplications | Select-Object -ExpandProperty category -Unique
+
+ foreach ($category in $activeCategories){
+ $label = $Labels | Where-Object {$_.Key -eq "WPFLabel"+$($category -replace '[^a-zA-Z0-9]','')}
+ $label.Value.Visibility = "Visible"
+ }
+ if ($activeCategories -ne $null){
+ $inactiveCategories = Compare-Object -ReferenceObject $allCategories -DifferenceObject $activeCategories -PassThru
+ foreach ($category in $inactiveCategories){
+ $label = $Labels | Where-Object {$_.Key -eq "WPFLabel"+$($category -replace '[^a-zA-Z0-9]','')}
+ $label.Value.Visibility = "Collapsed"}
+ }
})