本文整理汇总了VB.NET中System.Windows.Media.Animation.Animatable.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Animatable.BeginAnimation方法的具体用法?VB.NET Animatable.BeginAnimation怎么用?VB.NET Animatable.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了Animatable.BeginAnimation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: New
'
'
' This sample animates the position of an ellipse when
' the user clicks within the main border. If the user
' left-clicks, the SnapshotAndReplace HandoffBehavior
' is used when applying the animations. If the user
' right-clicks, the Compose HandoffBehavior is used
' instead.
'
'
Imports System.Windows
Imports System.Windows.Navigation
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports System.Windows.Controls
Imports System.Windows.Input
Namespace Microsoft.Samples.Animation.LocalAnimations
' Create the demonstration.
Public Class InteractiveAnimationExample
Inherits Page
Private Dim interactiveTranslateTransform As TranslateTransform
Private Dim WithEvents containerBorder As Border
Private Dim interactiveEllipse As Ellipse
Public Sub New()
WindowTitle = "Interactive Animation Example"
Dim myPanel As New DockPanel()
myPanel.Margin = New Thickness(20.0)
containerBorder = new Border()
containerBorder.Background = Brushes.White
containerBorder.BorderBrush = Brushes.Black
containerBorder.BorderThickness = new Thickness(2.0)
containerBorder.VerticalAlignment = VerticalAlignment.Stretch
interactiveEllipse = new Ellipse()
interactiveEllipse.Fill = Brushes.Lime
interactiveEllipse.Stroke = Brushes.Black
interactiveEllipse.StrokeThickness = 2.0
interactiveEllipse.Width = 25
interactiveEllipse.Height = 25
interactiveEllipse.HorizontalAlignment = HorizontalAlignment.Left
interactiveEllipse.VerticalAlignment = VerticalAlignment.Top
interactiveTranslateTransform = new TranslateTransform()
interactiveEllipse.RenderTransform = _
interactiveTranslateTransform
containerBorder.Child = interactiveEllipse
myPanel.Children.Add(containerBorder)
Me.Content = myPanel
End Sub
' When the user left-clicks, use the
' SnapshotAndReplace HandoffBehavior when applying the animation.
Private Sub border_mouseLeftButtonDown( _
ByVal sender As Object, ByVal e As MouseButtonEventArgs) _
Handles containerBorder.MouseLeftButtonDown
Dim clickPoint = Mouse.GetPosition(containerBorder)
' Set the target point so the center of the ellipse
' ends up at the clicked point.
Dim targetPoint As New System.Windows.Point()
targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2
targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2
' Animate to the target point.
Dim xAnimation As _
New DoubleAnimation(targetPoint.X, _
New Duration(TimeSpan.FromSeconds(4)))
interactiveTranslateTransform.BeginAnimation( _
TranslateTransform.XProperty, xAnimation, HandoffBehavior.SnapshotAndReplace)
Dim yAnimation As _
New DoubleAnimation(targetPoint.Y, _
New Duration(TimeSpan.FromSeconds(4)))
interactiveTranslateTransform.BeginAnimation( _
TranslateTransform.YProperty, yAnimation, HandoffBehavior.SnapshotAndReplace)
' Change the color of the ellipse.
interactiveEllipse.Fill = Brushes.Lime
End Sub
' When the user right-clicks, use the
' Compose HandoffBehavior when applying the animation.
Private Sub border_mouseRightButtonDown( _
ByVal sender As Object, ByVal e As MouseButtonEventArgs) _
Handles containerBorder.MouseRightButtonDown
' Find the point where the use clicked.
Dim clickPoint = Mouse.GetPosition(containerBorder)
' Set the target point so the center of the ellipse
' ends up at the clicked point.
Dim targetPoint As New System.Windows.Point()
targetPoint.X = clickPoint.X - interactiveEllipse.Width / 2
targetPoint.Y = clickPoint.Y - interactiveEllipse.Height / 2
' Animate to the target point.
Dim xAnimation As _
New DoubleAnimation(targetPoint.X, _
New Duration(TimeSpan.FromSeconds(4)))
interactiveTranslateTransform.BeginAnimation( _
TranslateTransform.XProperty, xAnimation, HandoffBehavior.Compose)
Dim yAnimation As _
New DoubleAnimation(targetPoint.Y, _
New Duration(TimeSpan.FromSeconds(4)))
interactiveTranslateTransform.BeginAnimation( _
TranslateTransform.YProperty, yAnimation, HandoffBehavior.Compose)
' Change the color of the ellipse.
interactiveEllipse.Fill = Brushes.Orange
End Sub
End Class
End Namespace
开发者ID:VB.NET开发者,项目名称:System.Windows.Media.Animation,代码行数:133,代码来源:Animatable.BeginAnimation
注:本文中的System.Windows.Media.Animation.Animatable.BeginAnimation方法示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论