mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-18 02:37:43 -06:00
Hide Category title if empty
This commit is contained in:
parent
2354645b47
commit
f453534f74
@ -77,7 +77,10 @@ function Get-TabXaml {
|
|||||||
$panelcount++
|
$panelcount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$blockXml += "<Label Content=""$($category -replace '^.__', '')"" FontSize=""16""/>`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 += "<Label Name=""$categoryname"" Content=""$categorycontent"" FontSize=""16""/>`n"
|
||||||
$sortedApps = $organizedData[$panel][$category].Keys | Sort-Object
|
$sortedApps = $organizedData[$panel][$category].Keys | Sort-Object
|
||||||
foreach ($appName in $sortedApps) {
|
foreach ($appName in $sortedApps) {
|
||||||
$count++
|
$count++
|
||||||
|
@ -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({
|
$sync["CheckboxFilter"].Add_TextChanged({
|
||||||
|
|
||||||
if ($sync.CheckboxFilter.Text -ne "") {
|
if ($sync.CheckboxFilter.Text -ne "") {
|
||||||
@ -372,8 +381,7 @@ $sync["CheckboxFilter"].Add_TextChanged({
|
|||||||
$sync.CheckboxFilterClear.Visibility = "Collapsed"
|
$sync.CheckboxFilterClear.Visibility = "Collapsed"
|
||||||
}
|
}
|
||||||
|
|
||||||
$filter = Get-WinUtilVariables -Type CheckBox
|
$activeApplications = @()
|
||||||
$CheckBoxes = $sync.GetEnumerator() | Where-Object { $psitem.Key -in $filter }
|
|
||||||
|
|
||||||
foreach ($CheckBox in $CheckBoxes) {
|
foreach ($CheckBox in $CheckBoxes) {
|
||||||
# Check if the checkbox is null or if it doesn't have content
|
# 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)) {
|
if ($CheckBox.Value.Content.ToLower().Contains($textToSearch)) {
|
||||||
$CheckBox.Value.Visibility = "Visible"
|
$CheckBox.Value.Visibility = "Visible"
|
||||||
|
$activeApplications += $sync.configs.applications.$checkboxName
|
||||||
# Set the corresponding text block visibility
|
# Set the corresponding text block visibility
|
||||||
if ($textBlock -ne $null) {
|
if ($textBlock -ne $null) {
|
||||||
$textBlock.Visibility = "Visible"
|
$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"}
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user