加入收藏  广告服务  关于我们
 2008-3-10

最酷的Analog时钟控件

发表:gongjie852   阅读:次  关键字:vb.net 控件   字体:[ ]

Analog时钟控件是一个VB.net下开发的拥有所有功能的时钟控件,并且允许用户完全自定义。
该控件引用于VB.NET控件库,你可以在C++, C#, J# 及VB.Net 等任何.net环境中调用。

最初设想是应用于VB的论坛下,不过在加入很多属性,事件之后,变得更加通用,更加高级了。


VB 源码时钟


[添加组件]
如果要使用这个控件,你只需要把它加载到Visual Studio 的工具箱中就可以了。鼠标右键工具箱,在弹出的菜

单中选择“choose items”,在弹出的对话框中加载这个“AnalogClockLib.dll”就可以了。

最后,拖拽这个控件到你的Form中,就OK了。当然,为了你能够看到这个控件的所有属性及方法的描述信息

,你也可以将AnalogClockLib.xml文件拷贝到你的项目目录。

[代码使用]

怎样让时钟指针有渐变色?

Code:
Private Sub AnalogClock1_HourHandPaint(ByVal sender As Object, _

ByVal e As AnalogClockLib.ClockPaintEventArgs) Handles AnalogClock1.HourHandPaint

    'Make the hour-hand gradient

    'Create gradient brush

    Dim br As New Drawing2D.PathGradientBrush( _

    Me.AnalogClock1.HourHandPath.PathPoints, Drawing2D.WrapMode.Tile)

    br.CenterColor = Color.White

    br.SurroundColors = New Color() {Me.AnalogClock1.HourHandColor}

    'Assing it to the property

    e.Brush = br

    'Dispose the brush

    br.Dispose()

End Sub




如何添加名字和数字时钟到时钟的背景?

Code:
Private Sub AnalogClock1_BackgroundPaint(ByVal sender As Object, _

ByVal e As System.Windows.Forms.PaintEventArgs) Handles AnalogClock1.BackgroundPaint

    Dim x, y As Double

    Dim sz As SizeF

    'Set the graphics object's smoothingMode to high quality (this is optional)

    'Note if you don't want to set this property for all elements than you

    'need to chang it in the elements' event handlers.

    e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality

    'Draw digital time on the bottom, clock's background

    sz = e.Graphics.MeasureString(Me.AnalogClock1.DateTime.ToShortTimeString, Me.Font, _

    New PointF(0, 0), StringFormat.GenericDefault)

    x = Me.AnalogClock1.ClockCenter.X - sz.Width / 2

    y = Me.AnalogClock1.ClockCenter.Y + 60

    e.Graphics.DrawString(Me.AnalogClock1.DateTime.ToShortTimeString, Me.Font, _

    Brushes.Black, x, y)

    'Draw your name on the top, clock's background

    sz = e.Graphics.MeasureString("ARMAN", New Font("Palace Script MT", 12, _

    FontStyle.Italic), New PointF(0, 0), StringFormat.GenericDefault)

    x = Me.AnalogClock1.ClockCenter.X - sz.Width / 2

    y = Me.AnalogClock1.ClockCenter.Y - 80

    e.Graphics.DrawString("ARMAN", New Font("Palace Script MT", 12, _

    FontStyle.Italic), Brushes.Black, x, y)

End Sub

 热门文章
 推荐信息