From b3a12d1390a16e49d5334e31830a242196620587 Mon Sep 17 00:00:00 2001 From: vyas-devgna Date: Wed, 29 Jul 2026 18:00:24 +0530 Subject: [PATCH] Streamline WPF application grid generation --- functions/public/Invoke-WPFUIElements.ps1 | 36 ++++++++--------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/functions/public/Invoke-WPFUIElements.ps1 b/functions/public/Invoke-WPFUIElements.ps1 index 82b5c14a3d..1af1d30ba9 100644 --- a/functions/public/Invoke-WPFUIElements.ps1 +++ b/functions/public/Invoke-WPFUIElements.ps1 @@ -53,25 +53,19 @@ function Invoke-WPFUIElements { $targetGrid.ColumnDefinitions.Add($colDef) | Out-Null } - # Convert PSCustomObject to Hashtable - $configHashtable = @{} - $configVariable.PSObject.Properties.Name | ForEach-Object { - $configHashtable[$_] = $configVariable.$_ - } - $radioButtonGroups = @{} - $organizedData = @{} - # Iterate through JSON data and organize by panel and category - foreach ($entry in $configHashtable.Keys) { - $entryInfo = $configHashtable[$entry] - # Create an object for the application + foreach ($prop in $configVariable.PSObject.Properties) { + $entryInfo = $prop.Value + $panel = if ($entryInfo.Panel) { $entryInfo.Panel } else { "0" } + $category = $entryInfo.Category + $entryObject = [PSCustomObject]@{ - Name = $entry - Category = $entryInfo.Category + Name = $prop.Name + Category = $category Content = $entryInfo.Content - Panel = if ($entryInfo.Panel) { $entryInfo.Panel } else { "0" } + Panel = $panel Link = $entryInfo.link Description = $entryInfo.description Type = $entryInfo.type @@ -81,17 +75,13 @@ function Invoke-WPFUIElements { GroupName = $entryInfo.GroupName # Added for RadioButton groupings } - if (-not $organizedData.ContainsKey($entryObject.Panel)) { - $organizedData[$entryObject.Panel] = @{} + if (-not $organizedData.ContainsKey($panel)) { + $organizedData[$panel] = @{} } - - if (-not $organizedData[$entryObject.Panel].ContainsKey($entryObject.Category)) { - $organizedData[$entryObject.Panel][$entryObject.Category] = @() + if (-not $organizedData[$panel].ContainsKey($category)) { + $organizedData[$panel][$category] = [System.Collections.Generic.List[object]]::new() } - - # Store application data in an array under the category - $organizedData[$entryObject.Panel][$entryObject.Category] += $entryObject - + $organizedData[$panel][$category].Add($entryObject) | Out-Null } # Initialize panel count