Click here to Skip to main content
15,896,063 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 320.1K   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.
Imports System.ComponentModel

<DebuggerNonUserCode()> _
Public Class ToStringConverter
    Inherits ExpandableObjectConverter

#Region " Methods "

    Public Overrides Function CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal destinationType As System.Type) As Boolean
        Return ((destinationType Is GetType(String)))
    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 (destinationType Is GetType(String)) Then

            'BigMarkers converter.
            If TypeOf value Is BigMarkers Then
                Dim obj As BigMarkers = DirectCast(value, BigMarkers)
                Return "{" & obj.Items.Length & "}"
            End If
            'SmallMarkers converter.
            If TypeOf value Is SmallMarkers Then
                Dim obj As SmallMarkers = DirectCast(value, SmallMarkers)
                Return "{" & obj.Items.Length & "}"
            End If
            'Symbols converter.
            If TypeOf value Is Symbols Then
                Dim obj As Symbols = DirectCast(value, Symbols)
                Return "{" & obj.Items.Length & "}"
            End If
            'Hand converter.
            If TypeOf value Is Hand Then
                Dim obj As Hand = DirectCast(value, Hand)
                Return "{" & obj.Style.ToString & "}"
            End If
            'Center converter.
            If TypeOf value Is Center Then
                Dim obj As Center = DirectCast(value, Center)
                Return obj.PivotalPoint.ToString
            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