Path Animation with DoubleAnimation Using Path, AutoReverse : DoubleAnimation « Windows Presentation Foundation « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Windows Presentation Foundation » DoubleAnimationScreenshots 
Path Animation with DoubleAnimation Using Path, AutoReverse
Path Animation with DoubleAnimation Using Path, AutoReverse
   

<Window x:Class="WpfApplication1.PathAnimationExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Path Animation" Height="500" Width="518">
    <Canvas Margin="5">

        <Polyline Points="0,345,96,345,320,432,500,432" Stroke="Gray"
      StrokeThickness="5" />
        <Path>
            <Path.Data>
                <PathGeometry x:Name="path2" Figures="M0,292 L75,292 300,380,449,380" />
            </Path.Data>
        </Path>
        <Ellipse Name="circle2" Stroke="DarkGoldenrod" Canvas.Left="0"
      Canvas.Top="293" Width="50" Height="50">
            <Ellipse.Fill>
                <LinearGradientBrush>
                    <GradientStop Color="DarkGoldenrod" Offset="0.5" />
                    <GradientStop Color="Gold" Offset="0.5" />
                </LinearGradientBrush>
            </Ellipse.Fill>
            <Ellipse.RenderTransform>
                <RotateTransform x:Name="circle2Rotate" CenterX="25" CenterY="25" />
            </Ellipse.RenderTransform>
        </Ellipse>
    </Canvas>
</Window>

//File:Window.xaml.vb

Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes

Namespace WpfApplication1
  Public Partial Class PathAnimationExample
    Inherits Window
    Public Sub New()
      InitializeComponent()

      path2.Freeze()
      ' For performance benefits. 
      Dim daPath As New DoubleAnimationUsingPath()
      daPath.Duration = TimeSpan.FromSeconds(5)
      daPath.RepeatBehavior = RepeatBehavior.Forever
      daPath.AccelerationRatio = 0.6
      daPath.DecelerationRatio = 0.4
      daPath.AutoReverse = True
      daPath.PathGeometry = path2
      daPath.Source = PathAnimationSource.X
      circle2.BeginAnimation(Canvas.LeftProperty, daPath)

      daPath = New DoubleAnimationUsingPath()
      daPath.Duration = TimeSpan.FromSeconds(5)
      daPath.RepeatBehavior = RepeatBehavior.Forever
      daPath.AccelerationRatio = 0.6
      daPath.DecelerationRatio = 0.4
      daPath.AutoReverse = True
      daPath.PathGeometry = path2
      daPath.Source = PathAnimationSource.Y

      circle2.BeginAnimation(Canvas.TopProperty, daPath)
    End Sub
  End Class
End Namespace

   
    
    
  
Related examples in the same category
1.DoubleAnimation Loop foreverDoubleAnimation Loop forever
2.DoubleAnimation Loop three timesDoubleAnimation Loop three times
3.DoubleAnimation Loop for 30 secondsDoubleAnimation Loop for 30 seconds
4.Use DoubleAnimation to animate Gradient OffsetUse DoubleAnimation to animate Gradient Offset
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.