PageRenderTime 70ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Visual Basic | 51 lines | 19 code | 8 blank | 24 comment | 0 complexity | 8524b9b74fc3717c3cfade78047ce02e MD5 | raw file
  1. '***************************** Module Header ******************************\
  2. '* Module Name: AnimateDependencyProperty.xaml.vb
  3. '* Project: VBSL3Animation
  4. '* Copyright (c) Microsoft Corporation.
  5. '*
  6. '* This module shows how to catch custom event of MyEllipse object and in the
  7. '* relevant event handler, it creates animation effect for the Line object by
  8. '* syncronizing its endpoints with the latest mouse click point and current position
  9. '* of MyEllipse object.
  10. '*
  11. '* This source is subject to the Microsoft Public License.
  12. '* See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
  13. '* All other rights reserved.
  14. '*
  15. '* History:
  16. '* * 9/8/2009 05:00 PM Allen Chen Created
  17. '\**************************************************************************
  18. Partial Public Class AnimateDependencyProperty
  19. Inherits UserControl
  20. Private _currenttargetpoint As Point
  21. Public Sub New()
  22. InitializeComponent()
  23. End Sub
  24. Private Sub MyStackPanel_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
  25. _currenttargetpoint = e.GetPosition(Me.MyStackPanel)
  26. Me.MyAnimation.To = _currenttargetpoint
  27. Me.MyAnimationStoryboard.Begin()
  28. End Sub
  29. ''' <summary>
  30. ''' The following method syncronize MyLine's endpoints with the latest mouse
  31. ''' click point and current position of MyEllipse object. Therefore, an animation
  32. ''' is created for MyLine.
  33. ''' </summary>
  34. ''' <param name="sender"></param>
  35. ''' <param name="e"></param>
  36. Private Sub MyAnimatedEllipseGeometry_EllipseCenterChanged(ByVal sender As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
  37. Me.MyLine.Visibility = Visibility.Visible
  38. Me.MyLine.X1 = Me.MyAnimatedEllipseGeometry.EllipseCenter.X
  39. Me.MyLine.Y1 = Me.MyAnimatedEllipseGeometry.EllipseCenter.Y
  40. Me.MyLine.X2 = Me._currenttargetpoint.X
  41. Me.MyLine.Y2 = Me._currenttargetpoint.Y
  42. End Sub
  43. End Class