finish new install GUI

This commit is contained in:
Chris Titus Tech
2026-02-05 15:50:15 -06:00
parent 17f92df25a
commit 53f837f1e9
5 changed files with 72 additions and 4 deletions

View File

@@ -44,6 +44,7 @@ function Initialize-InstallCategoryAppList {
$toggleButton.Tag = "CategoryToggleButton"
$toggleButton.SetResourceReference([Windows.Controls.Control]::FontSizeProperty, "HeaderFontSize")
$toggleButton.SetResourceReference([Windows.Controls.Control]::FontFamilyProperty, "HeaderFontFamily")
$toggleButton.SetResourceReference([Windows.Controls.Control]::ForegroundProperty, "LabelboxForegroundColor")
$toggleButton.Cursor = [System.Windows.Input.Cursors]::Hand
$toggleButton.HorizontalAlignment = [Windows.HorizontalAlignment]::Stretch
$sync.$Category = $toggleButton

View File

@@ -23,6 +23,8 @@ function Invoke-WPFButton {
"WPFInstall" {Invoke-WPFInstall}
"WPFUninstall" {Invoke-WPFUnInstall}
"WPFInstallUpgrade" {Invoke-WPFInstallUpgrade}
"WPFCollapseAllCategories" {Invoke-WPFToggleAllCategories -Action "Collapse"}
"WPFExpandAllCategories" {Invoke-WPFToggleAllCategories -Action "Expand"}
"WPFStandard" {Invoke-WPFPresets "Standard" -checkboxfilterpattern "WPFTweak*"}
"WPFMinimal" {Invoke-WPFPresets "Minimal" -checkboxfilterpattern "WPFTweak*"}
"WPFClearTweaksSelection" {Invoke-WPFPresets -imported $true -checkboxfilterpattern "WPFTweak*"}

View File

@@ -0,0 +1,51 @@
function Invoke-WPFToggleAllCategories {
<#
.SYNOPSIS
Expands or collapses all categories in the Install tab
.PARAMETER Action
The action to perform: "Expand" or "Collapse"
.DESCRIPTION
This function iterates through all category containers in the Install tab
and expands or collapses their WrapPanels while updating the toggle button labels
#>
param(
[Parameter(Mandatory=$true)]
[ValidateSet("Expand", "Collapse")]
[string]$Action
)
try {
if ($null -eq $sync.ItemsControl) {
Write-Warning "ItemsControl not initialized"
return
}
$targetVisibility = if ($Action -eq "Expand") { [Windows.Visibility]::Visible } else { [Windows.Visibility]::Collapsed }
$targetPrefix = if ($Action -eq "Expand") { "-" } else { "+" }
$sourcePrefix = if ($Action -eq "Expand") { "+" } else { "-" }
# Iterate through all items in the ItemsControl
$sync.ItemsControl.Items | ForEach-Object {
$categoryContainer = $_
# Check if this is a category container (StackPanel with children)
if ($categoryContainer -is [System.Windows.Controls.StackPanel] -and $categoryContainer.Children.Count -ge 2) {
# Get the WrapPanel (second child)
$wrapPanel = $categoryContainer.Children[1]
$wrapPanel.Visibility = $targetVisibility
# Update the label to show the correct state
$categoryLabel = $categoryContainer.Children[0]
if ($categoryLabel.Content -like "$sourcePrefix*") {
$categoryLabel.Content = $categoryLabel.Content -replace "^$sourcePrefix ", "$targetPrefix "
}
}
}
}
catch {
Write-Error "Error toggling categories: $_"
}
}