Public Class ParameterPropertyDescriptor
Inherits PropertyDescriptor
Private _SubPD As PropertyDescriptor
Private _ParentPD As PropertyDescriptor
Public Sub New(parentPD As PropertyDescriptor, subPD As PropertyDescriptor, pdName As String)
MyBase.New(pdName, Nothing)
_SubPD = subPD
_ParentPD = parentPD
End Sub
Public Overrides Function CanResetValue(component As Object) As Boolean
Return False
End Function
Public Overrides ReadOnly Property ComponentType As System.Type
Get
Return _ParentPD.ComponentType
End Get
End Property
Public Overrides Function GetValue(component As Object) As Object
Return _SubPD.GetValue(_ParentPD.GetValue(component))
End Function
Public Overrides ReadOnly Property IsReadOnly As Boolean
Get
Return False
End Get
End Property
Public Overrides ReadOnly Property PropertyType As System.Type
Get
Return _SubPD.PropertyType
End Get
End Property
Public Overrides Sub ResetValue(component As Object)
' TODO: Code for this sub?
End Sub
Public Overrides Sub SetValue(component As Object, value As Object)
_SubPD.SetValue(_ParentPD.GetValue(component), value)
OnValueChanged(component, EventArgs.Empty)
End Sub
Public Overrides Function ShouldSerializeValue(component As Object) As Boolean
Return True
End Function
End Class
Public Class ParameterTypeDescriptor
Inherits CustomTypeDescriptor
Public Sub New(parent As ICustomTypeDescriptor)
MyBase.New(parent)
End Sub
Public Overrides Function GetProperties() As System.ComponentModel.PropertyDescriptorCollection
Dim Cols As PropertyDescriptorCollection = MyBase.GetProperties()
Dim UpperLimitPD As PropertyDescriptor = Cols("UpperLimit")
Dim UpperLimitChild As PropertyDescriptorCollection = UpperLimitPD.GetChildProperties()
Dim DefaultValuePD As PropertyDescriptor = Cols("DefaultValue")
Dim DefaultValueChild As PropertyDescriptorCollection = DefaultValuePD.GetChildProperties()
Dim LowerLimitPD As PropertyDescriptor = Cols("LowerLimit")
Dim LowerLimitChild As PropertyDescriptorCollection = LowerLimitPD.GetChildProperties()
Dim array(Cols.Count + 2) As PropertyDescriptor
Cols.CopyTo(array, 0)
array(Cols.Count) = New ParameterPropertyDescriptor(UpperLimitPD, UpperLimitChild("Value"), "UpperLimit.Value")
array(Cols.Count + 1) = New ParameterPropertyDescriptor(DefaultValuePD, DefaultValueChild("Value"), "DefaultValue.Value")
array(Cols.Count + 2) = New ParameterPropertyDescriptor(LowerLimitPD, LowerLimitChild("Value"), "LowerLimit.Value")
Dim NewCols As PropertyDescriptorCollection = New PropertyDescriptorCollection(array)
Return NewCols
End Function
Public Overrides Function GetProperties(attributes() As Attribute) As System.ComponentModel.PropertyDescriptorCollection
Return Me.GetProperties()
End Function
End Class
Public Class ParameterDescriptionProvider
Inherits TypeDescriptionProvider
Private td As ICustomTypeDescriptor
Public Sub New()
Me.New(TypeDescriptor.GetProvider(GetType(Parameter)))
End Sub
Public Sub New(parent As TypeDescriptionProvider)
MyBase.New(parent)
End Sub
Public Overrides Function GetTypeDescriptor(objectType As Type, instance As Object) As ICustomTypeDescriptor
If td Is Nothing Then
td = MyBase.GetTypeDescriptor(objectType, instance)
td = New ParameterTypeDescriptor(td)
End If
Return td
End Function
End Class