2551/08/16

The Visual Basic Language on Silverlight

The Visual Basic Language on Silverlight


' Anonymous delegates, Handles--isn't it pretty?
Public Sub Canvas_Loaded() Handles Me.Loaded
InitializeComponent()
' Type inference; DateTime functions
Dim currentTime = Now
' Conversions, type inference
Dim hourAngle = ((currentTime.Hour / 12) * 360 + currentTime.Minute / 2) + 180
Dim minAngle = ((currentTime.Minute / 60) * 360) + 180
Dim secAngle = ((currentTime.Second / 60) * 360) + 180
' hourAnimation is a generated variable that makes use of WithEvents and Conversions
' Protected WithEvents hourAnimation As DoubleAnimation
' Me.hourAnimation = CType(Me.FindName("hourAnimation"),DoubleAnimation)
hourAnimation.From = hourAngle
hourAnimation.To = hourAngle + 360
minuteAnimation.From = minAngle
minuteAnimation.To = minAngle + 360
secondAnimation.From = secAngle
secondAnimation.To = secAngle + 360
End Sub

Powered By Blogger