''' <summary>
''' Provides a type converter for the AnalogClock.Symbol.
''' </summary>
<DebuggerNonUserCode()> _
Public Class SymbolConverter
Inherits System.ComponentModel.ExpandableObjectConverter
#Region " Methods "
Public Overrides Function CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal destinationType As System.Type) As Boolean
Return ((destinationType Is GetType(System.ComponentModel.Design.Serialization.InstanceDescriptor)) _
OrElse MyBase.CanConvertTo(context, destinationType))
End Function
Public Overrides Function ConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object, ByVal destinationType As System.Type) As Object
If (destinationType Is Nothing) Then
Throw New ArgumentNullException("destinationType")
End If
If value.GetType Is GetType(Symbol) Then
Dim s As Symbol = DirectCast(value, Symbol)
If destinationType Is GetType(System.ComponentModel.Design.Serialization.InstanceDescriptor) Then
Dim descriptor As System.ComponentModel.Design.Serialization.InstanceDescriptor = Nothing
Dim constructor As Reflection.ConstructorInfo
constructor = GetType(Symbol).GetConstructor( _
New Type() {GetType(String), _
GetType(Single), _
GetType(String), _
GetType(System.Drawing.Font), _
GetType(System.Drawing.Color), _
GetType(Point), _
GetType(Integer), _
GetType(Boolean), _
GetType(Boolean), _
GetType(SymbolStyle), _
GetType(Single), _
GetType(Single), _
GetType(Drawing.Text.TextRenderingHint), _
GetType(Object)})
If (Not constructor Is Nothing) Then
descriptor = _
New System.ComponentModel.Design.Serialization.InstanceDescriptor( _
constructor, _
New Object() { _
s.Name, _
s.Angle, _
s.Text, _
s.Font, _
s.Color, _
s.Offset, _
s.Index, _
s.Visible, _
s.Upright, _
s.Style, _
s.ClockRadius, _
s.RelativeRadius, _
s.Rendering, _
s.Tag}, True)
End If
If (Not descriptor Is Nothing) Then
Return descriptor
End If
End If
If destinationType Is GetType(String) Then
Return ("Symbol: {" & s.Text & "}")
End If
End If
Return MyBase.ConvertTo(context, culture, value, destinationType)
End Function
#End Region
End Class