diff --git a/winutil.ps1 b/winutil.ps1
index dd1e7ff6..7e78d26f 100644
--- a/winutil.ps1
+++ b/winutil.ps1
@@ -332,7 +332,13 @@ function Get-TabXaml {
$panelcount++
}
}
- $blockXml += "`n"
+
+ # Dot-source the Get-WPFObjectName function
+ . .\functions\private\Get-WPFObjectName
+
+ $categorycontent = $($category -replace '^.__', '')
+ $categoryname = Get-WPFObjectName -type "Label" -name $categorycontent
+ $blockXml += "`n"
$sortedApps = $organizedData[$panel][$category].Keys | Sort-Object
foreach ($appName in $sortedApps) {
$count++
@@ -691,6 +697,33 @@ function Get-WinUtilWingetPrerequisites {
Catch{
throw [WingetFailedInstall]::new('Failed to install prerequsites')
}
+}
+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
+
}
function Install-WinUtilChoco {
@@ -12764,7 +12797,7 @@ $inputXML = '
-
+
@@ -12813,7 +12846,7 @@ $inputXML = '
-
+
@@ -12883,7 +12916,7 @@ $inputXML = '
-
+
@@ -13036,7 +13069,7 @@ $inputXML = '
-
+
@@ -13115,7 +13148,7 @@ $inputXML = '
-
+
@@ -13182,7 +13215,7 @@ $inputXML = '
-
+
@@ -13248,7 +13281,7 @@ $inputXML = '
-
+
@@ -13405,7 +13438,7 @@ $inputXML = '
-
+
@@ -13462,11 +13495,11 @@ $inputXML = '
-
+
-
+
@@ -13862,7 +13895,7 @@ $inputXML = '
-
+
@@ -13880,7 +13913,7 @@ $inputXML = '
-
+
@@ -13915,7 +13948,7 @@ $inputXML = '
-
+
@@ -13960,10 +13993,10 @@ $inputXML = '
-
+
-
+
@@ -13998,7 +14031,7 @@ $inputXML = '
-
+
@@ -14011,7 +14044,7 @@ $inputXML = '
-
+
@@ -14023,7 +14056,7 @@ $inputXML = '
-
+
@@ -14621,6 +14654,16 @@ 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} | ForEach-Object {$labels[$_.Key] = $_.Value}
+
+$allCategories = $checkBoxes.Name | ForEach-Object {$sync.configs.applications.$_} | Select-Object -Unique -ExpandProperty category
+
$sync["CheckboxFilter"].Add_TextChanged({
if ($sync.CheckboxFilter.Text -ne "") {
@@ -14630,8 +14673,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
@@ -14648,6 +14690,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"
@@ -14661,7 +14704,21 @@ $sync["CheckboxFilter"].Add_TextChanged({
}
}
}
+ $activeCategories = $activeApplications | Select-Object -ExpandProperty category -Unique
+ foreach ($category in $activeCategories){
+ $label = $labels[$(Get-WPFObjectName -type "Label" -name $category)]
+ $label.Visibility = "Visible"
+ }
+ if ($activeCategories){
+ $inactiveCategories = Compare-Object -ReferenceObject $allCategories -DifferenceObject $activeCategories -PassThru
+ }
+ else{
+ $inactiveCategories = $allCategories
+ }
+ foreach ($category in $inactiveCategories){
+ $label = $labels[$(Get-WPFObjectName -type "Label" -name $category)]
+ $label.Visibility = "Collapsed"}
})
# Define event handler for button click
diff --git a/xaml/inputApp.xaml b/xaml/inputApp.xaml
index aff16257..b94f1462 100644
--- a/xaml/inputApp.xaml
+++ b/xaml/inputApp.xaml
@@ -7,7 +7,7 @@
-
+
@@ -56,7 +56,7 @@
-
+
@@ -126,7 +126,7 @@
-
+
@@ -279,7 +279,7 @@
-
+
@@ -358,7 +358,7 @@
-
+
@@ -425,7 +425,7 @@
-
+
@@ -491,7 +491,7 @@
-
+
@@ -648,7 +648,7 @@
-
+
@@ -705,11 +705,11 @@
-
+
-
+
diff --git a/xaml/inputFeatures.xaml b/xaml/inputFeatures.xaml
index c57704c6..197fa096 100644
--- a/xaml/inputFeatures.xaml
+++ b/xaml/inputFeatures.xaml
@@ -4,7 +4,7 @@
-
+
@@ -17,7 +17,7 @@
-
+
@@ -29,7 +29,7 @@
-
+
diff --git a/xaml/inputTweaks.xaml b/xaml/inputTweaks.xaml
index df989e3b..8bae8e92 100644
--- a/xaml/inputTweaks.xaml
+++ b/xaml/inputTweaks.xaml
@@ -4,7 +4,7 @@
-
+
@@ -22,7 +22,7 @@
-
+
@@ -57,7 +57,7 @@
-
+
@@ -102,10 +102,10 @@
-
+
-
+