Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 13 additions & 23 deletions functions/public/Invoke-WPFUIElements.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down