diff --git a/functions/public/Invoke-WPFUIElements.ps1 b/functions/public/Invoke-WPFUIElements.ps1 index abc5740b..1fe5e462 100644 --- a/functions/public/Invoke-WPFUIElements.ps1 +++ b/functions/public/Invoke-WPFUIElements.ps1 @@ -138,6 +138,9 @@ function Invoke-WPFUIElements { $label.FontFamily = $theme.HeaderFontFamily $stackPanel.Children.Add($label) | Out-Null + $sync[$category] = $label + write-host $sync[$category] + # Sort entries by Order and then by Name, but only display Name $entries = $organizedData[$panelKey][$category] | Sort-Object Order, Name foreach ($entryInfo in $entries) { @@ -176,7 +179,6 @@ function Invoke-WPFUIElements { $label.ToolTip = $entryInfo.Description $label.HorizontalAlignment = "Left" $label.FontSize = $theme.FontSize - # Implement for consistent theming later on $label.Style = $window.FindResource("labelfortweaks") $dockPanel.Children.Add($label) | Out-Null $stackPanel.Children.Add($dockPanel) | Out-Null @@ -290,6 +292,9 @@ function Invoke-WPFUIElements { } default { + $horizontalStackPanel = New-Object Windows.Controls.StackPanel + $horizontalStackPanel.Orientation = "Horizontal" + $checkBox = New-Object Windows.Controls.CheckBox $checkBox.Name = $entryInfo.Name $checkBox.Content = $entryInfo.Content @@ -299,12 +304,11 @@ function Invoke-WPFUIElements { if ($entryInfo.Checked -ne $null) { $checkBox.IsChecked = $entryInfo.Checked } - if ($entryInfo.Link -ne $null) { - $horizontalStackPanel = New-Object Windows.Controls.StackPanel - $horizontalStackPanel.Orientation = "Horizontal" - $horizontalStackPanel.Children.Add($checkBox) | Out-Null + $horizontalStackPanel.Children.Add($checkBox) | Out-Null + if ($entryInfo.Link -ne $null) { $textBlock = New-Object Windows.Controls.TextBlock + $textBlock.Name = $checkBox.Name + "Link" $textBlock.Text = "(?)" $textBlock.ToolTip = $entryInfo.Link $textBlock.Style = $window.FindResource("HoverTextBlockStyle") @@ -318,11 +322,10 @@ function Invoke-WPFUIElements { $horizontalStackPanel.Children.Add($textBlock) | Out-Null - $stackPanel.Children.Add($horizontalStackPanel) | Out-Null - } else { - $stackPanel.Children.Add($checkBox) | Out-Null + $sync[$textBlock.Name] = $textBlock } + $stackPanel.Children.Add($horizontalStackPanel) | Out-Null $sync[$entryInfo.Name] = $checkBox } } diff --git a/scripts/main.ps1 b/scripts/main.ps1 index a7c100a6..fb30af7d 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -372,7 +372,6 @@ $labels = @{} $allCategories = $checkBoxes.Name | ForEach-Object {$sync.configs.applications.$_} | Select-Object -Unique -ExpandProperty category $sync["SearchBar"].Add_TextChanged({ - if ($sync.SearchBar.Text -ne "") { $sync.SearchBarClearButton.Visibility = "Visible" } @@ -398,34 +397,19 @@ $sync["SearchBar"].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) { + # Set the corresponding text block visibility + if ($textBlock -ne $null -and $textBlock -is [System.Windows.Controls.TextBlock]) { $textBlock.Visibility = "Visible" } } else { - $CheckBox.Value.Visibility = "Collapsed" + $CheckBox.Value.Visibility = "Collapsed" # Set the corresponding text block visibility - if ($textBlock -ne $null) { + if ($textBlock -ne $null -and $textBlock -is [System.Windows.Controls.TextBlock]) { $textBlock.Visibility = "Collapsed" } } } - $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"} }) # Initialize the hashtable