The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Longhorn Animations and Timelines Part I

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jason Nadal

Posts: 184
Nickname: jnadal
Registered: Dec, 2003

Jason Nadal is an asp.net developer, dabbling in winforms from time to time.
Longhorn Animations and Timelines Part I Posted: Mar 6, 2004 5:42 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Jason Nadal.
Original Post: Longhorn Animations and Timelines Part I
Feed Title: Jason Nadal
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/jnadal/Rss.aspx
Feed Description: Restless C#ding
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Jason Nadal
Latest Posts From Jason Nadal

Advertisement

After a suggestion from DonXML, I left the world of manually starting up LengthAnimations bound to width and height properties of a Canvas control I had implemented via code, and took up the task of learning the Timeline object.

My goal was to have a Canvas, click on it, and zoom the width and height to the full size of the container Canvas, and stop when it reached the largest point. Let's check out some code (note, the SDK docs are a little unclear on how to do some of this, but the SDK team is on the right track with ease of how to find what is there...):

Timeline wTL = new Timeline();
wTL.StatusOfNextUse = UseStatus.ChangeableReference;
wTL.Enable(Timeline.Root);

LengthAnimationCollection w = GetAnimationCollection(MainPanel.Width.Value,wTL);
c.SetAnimations(
Canvas.WidthProperty, w);
w.SetDefaultParentTimeline(wTL);

wTL.RepeatCount = 0;
wTL.AutoReverse =
false;
wTL.Fill =
TimeFill.Hold;
wTL.FillDefault =
TimeFill.Hold;

wTL.Enable();
wTL.BeginIn(0);

...

private LengthAnimationCollection GetAnimationCollection(double size, Timeline t)
{

LengthAnimation la = new LengthAnimation();
la.To =
new Length(size);
la.Duration =
new Time(1000);
la.BeginIn(0);
la.AutoReverse =
false;
la.RepeatCount = 0;
la.ParentTimeline = t;
la.
InterpolationMethod = InterpolationMethod.Paced;
LengthAnimationCollection col = new LengthAnimationCollection();
col.Add(la);
return col;

}

The interesting thing about this (translated -- the thing that had me banging my head against the wall ready to scream) was that changing the Fill/FillDefault properties of the individual animations had no effect when they were added to the timeline.  You must change the Fill method to Hold/Freeze if you want your animated object to retain its final state when the animation is done, otherwise it'll either flash back to its original state, or if the wTL.AutoReverse property is set to true, it will animate back to its starting state. 

Also note, the LengthAnimation's InterpolationMethod property is set (in this case to Paced, but there are other options...linear, discrete, spline), in order to make the animation as smooth as possible.

So, with a minimal amount of code, this milestone of my image browser project has been met.

Read: Longhorn Animations and Timelines Part I

Topic: Default button - Cross browser solution Previous Topic   Next Topic Topic: Unhandled errors

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use