Click here to Skip to main content
15,895,746 members
Articles / Multimedia / GDI+

Analog Clock Control

Rate me:
Please Sign up or sign in to vote.
4.58/5 (66 votes)
23 Jan 2010CPOL4 min read 320K   30.7K   138  
The analog clock control is a control that has almost all the functionality that a clock control can have, and it is fully modifiable.
''' <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

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) ZipEdTech
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions