mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-10 18:11:16 +10:00
* Turn the Install category filters into toggle chips - Replace the filter buttons with toggles that show which ones are active - Add ctrl click to select more than one category - Keep the search box and the category filter independent of each other - Expand matching categories while a filter is active * Fix the filter interactions the category chips missed - Pass the selected categories to the lazy rendering batches, the old call used a parameter that no longer exists and threw while typing - Keep the category filter when switching tabs, the chips stayed checked while the filter itself was dropped - Put a category back to collapsed once the filter that expanded it is gone * Document the Install category filters - Add a guide section for the chips, ctrl click and clearing the filter - Note that search and the category chips apply together * Correct the category filter guide wording - Clearing by clicking the chip only applies when it is the only one selected - Only categories with matches expand, and only auto expanded ones re-collapse
63 lines
2.4 KiB
PowerShell
63 lines
2.4 KiB
PowerShell
function Invoke-WPFTab {
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Sets the selected tab to the tab that was clicked
|
|
|
|
.PARAMETER ClickedTab
|
|
The name of the tab that was clicked
|
|
|
|
#>
|
|
|
|
Param (
|
|
[Parameter(Mandatory,position=0)]
|
|
[string]$ClickedTab
|
|
)
|
|
|
|
$tabNav = Get-WinUtilVariables | Where-Object {$psitem -like "WPFTabNav"}
|
|
$tabNumber = [int]($ClickedTab -replace "WPFTab","" -replace "BT","") - 1
|
|
|
|
$filter = Get-WinUtilVariables -Type ToggleButton | Where-Object {$psitem -like "WPFTab?BT"}
|
|
$sync.$tabNav.Items[$tabNumber].IsSelected = $true
|
|
($sync.GetEnumerator()).where{$psitem.Key -in $filter} | ForEach-Object {
|
|
if ($ClickedTab -ne $PSItem.name) {
|
|
$sync[$PSItem.Name].IsChecked = $false
|
|
} else {
|
|
$sync["$ClickedTab"].IsChecked = $true
|
|
}
|
|
}
|
|
$sync.currentTab = $sync.$tabNav.Items[$tabNumber].Header
|
|
Initialize-WinUtilTabContent -TabName $sync.currentTab
|
|
|
|
# Always reset the filter for the current tab
|
|
if ($sync.currentTab -eq "Install") {
|
|
# Reset the search text, but keep the categories the chips are still showing as selected
|
|
$selectedCategories = if ($sync.SelectedAppCategories) { $sync.SelectedAppCategories.ToArray() } else { @() }
|
|
Find-AppsByNameOrDescription -SearchString "" -Categories $selectedCategories
|
|
} elseif ($sync.currentTab -eq "Tweaks") {
|
|
# Reset Tweaks tab filter
|
|
Find-TweaksByNameOrDescription -SearchString ""
|
|
} elseif ($sync.currentTab -eq "AppX") {
|
|
# Reset AppX tab filter
|
|
Find-TweaksByNameOrDescription -SearchString ""
|
|
}
|
|
|
|
# Show search bar in Install, Tweaks, and AppX tabs
|
|
if ($tabNumber -eq 0 -or $tabNumber -eq 1 -or $tabNumber -eq 5) {
|
|
$sync.SearchBar.Visibility = "Visible"
|
|
$searchIcon = ($sync.Form.FindName("SearchBar").Parent.Children | Where-Object { $_ -is [System.Windows.Controls.TextBlock] -and $_.Text -eq [char]0xE721 })[0]
|
|
if ($searchIcon) {
|
|
$searchIcon.Visibility = "Visible"
|
|
}
|
|
} else {
|
|
$sync.SearchBar.Visibility = "Collapsed"
|
|
$searchIcon = ($sync.Form.FindName("SearchBar").Parent.Children | Where-Object { $_ -is [System.Windows.Controls.TextBlock] -and $_.Text -eq [char]0xE721 })[0]
|
|
if ($searchIcon) {
|
|
$searchIcon.Visibility = "Collapsed"
|
|
}
|
|
# Hide the clear button if it's visible
|
|
$sync.SearchBarClearButton.Visibility = "Collapsed"
|
|
}
|
|
}
|