|
2008-3-10
最酷的Analog时钟控件
Analog时钟控件是一个VB.net下开发的拥有所有功能的时钟控件,并且允许用户完全自定义。 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 热门文章
推荐信息
|