All you really need to do is fill your items control with objects containing each ForgeTypeId from
SpecUtils.GetAllSpecs
ParameterUtils.GetAllBuiltInGroups
Then for each such object you can override ToString with the following:
LabelUtils.GetLabelForGroup(ForgeTypeId)
LabelUtils.GetLabelForSpec(ForgeTypeId)
Pointing to the ForgeTypeId stored on that object
Or instead of using ToString you could create a property for the above which is used for the DisplayMember or Binding path.
In the end because your items control contains these objects with ForgeTypeIds you can get the selected item and feed it's ForgeTypeId property into the new function.
You would have to check if the specs/groups are suitable for creating parameters, that may not be the case. Some are perhaps used in internal parameters only.
'UNTESTED!!!
Public Class ForgeTypeIdDisplayItem
'Reassign Document property at moment required
'Only required for getting readable name of category
Public Shared Document As Document = Nothing
Public Property Id As ForgeTypeId = Nothing
Public Sub New()
End Sub
Public Sub New(BIP As BuiltInParameter)
Id = ParameterUtils.GetParameterTypeId(BIP)
End Sub
Public Sub New(BIPG As BuiltInParameterGroup)
Id = ParameterUtils.GetParameterGroupTypeId(BIPG)
End Sub
Private Function IntGetDisplayValue() As String
If Id Is Nothing Then
Return Nothing
End If
If SpecUtils.IsSpec(Id) Then
Return LabelUtils.GetLabelForSpec(Id)
ElseIf UnitUtils.IsUnit(Id) Then
Return LabelUtils.GetLabelForUnit(Id)
ElseIf Category.IsBuiltInCategory(Id) Then
Dim C = Category.GetBuiltInCategory(Id)
If Document IsNot Nothing Then
Return Category.GetCategory(Document, C)?.Name
Else
Return [Enum].GetName(GetType(BuiltInCategory), C)
End If
ElseIf ParameterUtils.IsBuiltInGroup(Id) Then
Return LabelUtils.GetLabelForGroup(Id)
ElseIf ParameterUtils.IsBuiltInParameter(Id) Then
Return LabelUtils.GetLabelForBuiltInParameter(Id)
Else
Throw New Exception("Unknown ForgeTypeId")
End If
End Function
Public Overrides Function ToString() As String
Return IntGetDisplayValue()
End Function
Public Shared Function GetAllDisplaySpecs() As ForgeTypeIdDisplayItem()
Dim Items = SpecUtils.GetAllSpecs()
Dim Out = From x As ForgeTypeId In Items
Select New ForgeTypeIdDisplayItem With {.Id = x}
Return Out.OrderBy(Function(j) j.ToString).ToArray
End Function
Public Shared Function GetAllBuiltInParameters() As ForgeTypeIdDisplayItem()
Dim Items = ParameterUtils.GetAllBuiltInParameters
Dim Out = From x As ForgeTypeId In Items
Select New ForgeTypeIdDisplayItem With {.Id = x}
Return Out.OrderBy(Function(j) j.ToString).ToArray
End Function
Public Shared Function GetAllBuiltInParametersGroups() As ForgeTypeIdDisplayItem()
Dim Items = ParameterUtils.GetAllBuiltInGroups
Dim Out = From x As ForgeTypeId In Items
Select New ForgeTypeIdDisplayItem With {.Id = x}
Return Out.OrderBy(Function(j) j.ToString).ToArray
End Function
Public Shared Operator =(Left As ForgeTypeIdDisplayItem, Right As ForgeTypeIdDisplayItem) As Boolean
Return Left.Id = Right.Id
End Operator
Public Shared Operator <>(Left As ForgeTypeIdDisplayItem, Right As ForgeTypeIdDisplayItem) As Boolean
Return Left.Id <> Right.Id
End Operator
End Class