PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms 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
19Partial Public Class AnimateDependencyProperty
20    Inherits UserControl
21
22    Private _currenttargetpoint As Point
23
24    Public Sub New()
25        InitializeComponent()
26
27    End Sub
28
29    Private Sub MyStackPanel_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
30        _currenttargetpoint = e.GetPosition(Me.MyStackPanel)
31        Me.MyAnimation.To = _currenttargetpoint
32        Me.MyAnimationStoryboard.Begin()
33
34    End Sub
35
36    ''' <summary>
37    ''' The following method syncronize MyLine's endpoints with the latest mouse
38    ''' click point and current position of MyEllipse object. Therefore, an animation
39    ''' is created for MyLine.
40    ''' </summary>
41    ''' <param name="sender"></param>
42    ''' <param name="e"></param>
43    Private Sub MyAnimatedEllipseGeometry_EllipseCenterChanged(ByVal sender As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
44        Me.MyLine.Visibility = Visibility.Visible
45        Me.MyLine.X1 = Me.MyAnimatedEllipseGeometry.EllipseCenter.X
46        Me.MyLine.Y1 = Me.MyAnimatedEllipseGeometry.EllipseCenter.Y
47        Me.MyLine.X2 = Me._currenttargetpoint.X
48        Me.MyLine.Y2 = Me._currenttargetpoint.Y
49
50    End Sub
51End Class