PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/VBSL3Animation/CodeBehindCreation.xaml.vb

#
Visual Basic | 50 lines | 17 code | 7 blank | 26 comment | 0 complexity | fd8ffc080129c587d7f10a18ca027f7d MD5 | raw file
  1. '***************************** Module Header ******************************\
  2. '* Module Name: CodeBehindCreation.xaml.vb
  3. '* Project: VBSL3Animation
  4. '* Copyright (c) Microsoft Corporation.
  5. '*
  6. '* This module shows how to initialize a Storyboard in code behind. The final effect
  7. '* is the same as BasicPointAnimation.xaml, which uses XAML to add Storyboard.
  8. '*
  9. '* This source is subject to the Microsoft Public License.
  10. '* See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
  11. '* All other rights reserved.
  12. '*
  13. '* History:
  14. '* * 9/10/2009 03:00 PM Allen Chen Created
  15. '\**************************************************************************
  16. Partial Public Class CodeBehindCreation
  17. Inherits UserControl
  18. Private _myAnimation As PointAnimation = New PointAnimation()
  19. Private _myAnimationStoryboard As Storyboard = New Storyboard()
  20. ''' <summary>
  21. ''' In the following constructor, the PointAnimation is added to Storyboard.
  22. ''' They are initialized for animation.
  23. ''' </summary>
  24. Public Sub New()
  25. InitializeComponent()
  26. _myAnimation.Duration = New Duration(TimeSpan.FromSeconds(2))
  27. _myAnimation.SetValue(Storyboard.TargetPropertyProperty, New PropertyPath("Center"))
  28. Storyboard.SetTarget(_myAnimation, MyAnimatedEllipseGeometry)
  29. _myAnimationStoryboard.Children.Add(_myAnimation)
  30. End Sub
  31. ''' <summary>
  32. ''' Tbe following event handler change the To property of PointAnimation object,
  33. ''' then begin the Storyboard to play the animation. Please note we can change
  34. ''' To property even when the animation is playing.
  35. ''' </summary>
  36. ''' <param name="sender"></param>
  37. ''' <param name="e"></param>
  38. Private Sub MyStackPanel_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
  39. Dim targetpoint = e.GetPosition(Me.MyStackPanel)
  40. Me._myAnimation.To = targetpoint
  41. Me._myAnimationStoryboard.Begin()
  42. End Sub
  43. End Class