Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Event fired when an animation ends?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-31-2006   #1 (permalink)
Jason Dolinger
Guest


 

Event fired when an animation ends?

Hi all,

Is there any event that gets fired when an animation ends that we can
take advantage of? I have a simple animation that I'm creating in C#
code (I'm not doing it in XAML as it must be applied to any number of
elements in a collection at the click of a button, and I don't know how
one can do that in XAML).

It is meant to animate a property called ScaleFactor that I've declared
as a DP on a window, and it looks something like this (assume that w is
the window on which I want to animate the ScaleFactor DP):



DoubleAnimation scaleAnimationParams = new DoubleAnimation();

scaleAnimationParams.From = 1;
scaleAnimationParams.To = .25;
scaleAnimationParams.Duration = new Duration(new TimeSpan(0, 0, 0, 0,
500));
w.BeginAnimation(ManagedWindow.ScaleFactorProperty,scaleAnimationParams);


Now, is there a way to get notified when the animation is finished? The
only events that are available through the animation classes are:

- Changed
- CurrentGlobalSpeedInvalidated
- CurrentGlobalStateInvalidated
- CurrentTimeInvalidated

Thanks!
Jason

My System SpecsSystem Spec
Old 01-31-2006   #2 (permalink)
Jason Dolinger
Guest


 

Re: Event fired when an animation ends?

Jason Dolinger wrote:
> Hi all,
>
> Is there any event that gets fired when an animation ends that we can
> take advantage of? I have a simple animation that I'm creating in C#
> code (I'm not doing it in XAML as it must be applied to any number of
> elements in a collection at the click of a button, and I don't know how
> one can do that in XAML).
>
> It is meant to animate a property called ScaleFactor that I've declared
> as a DP on a window, and it looks something like this (assume that w is
> the window on which I want to animate the ScaleFactor DP):
>
>
>
> DoubleAnimation scaleAnimationParams = new DoubleAnimation();
>
> scaleAnimationParams.From = 1;
> scaleAnimationParams.To = .25;
> scaleAnimationParams.Duration = new Duration(new TimeSpan(0, 0, 0,
> 0, 500));
> w.BeginAnimation(ManagedWindow.ScaleFactorProperty,scaleAnimationParams);
>
>
> Now, is there a way to get notified when the animation is finished? The
> only events that are available through the animation classes are:
>
> - Changed
> - CurrentGlobalSpeedInvalidated
> - CurrentGlobalStateInvalidated
> - CurrentTimeInvalidated
>
> Thanks!
> Jason


Taking this even further, it would be nice to have events fired when an
animation starts as well (given that you can specify a start time for an
animation which is not exactly now...)

Thanks,
Jason
My System SpecsSystem Spec
Old 01-31-2006   #3 (permalink)
viliescu
Guest


 

Re: Event fired when an animation ends?

scaleAnimationParams.CurrentStateInvalidated += delegate(object sender,
EventArgs e)
{
Clock clock = (Clock)sender;

if (clock.CurrentState == ClockState.Stopped)
{
// the animation has ended
....
}
};
--
Valentin Iliescu [MVP C#]


"Jason Dolinger" wrote:

> Jason Dolinger wrote:
> > Hi all,
> >
> > Is there any event that gets fired when an animation ends that we can
> > take advantage of? I have a simple animation that I'm creating in C#
> > code (I'm not doing it in XAML as it must be applied to any number of
> > elements in a collection at the click of a button, and I don't know how
> > one can do that in XAML).
> >
> > It is meant to animate a property called ScaleFactor that I've declared
> > as a DP on a window, and it looks something like this (assume that w is
> > the window on which I want to animate the ScaleFactor DP):
> >
> >
> >
> > DoubleAnimation scaleAnimationParams = new DoubleAnimation();
> >
> > scaleAnimationParams.From = 1;
> > scaleAnimationParams.To = .25;
> > scaleAnimationParams.Duration = new Duration(new TimeSpan(0, 0, 0,
> > 0, 500));
> > w.BeginAnimation(ManagedWindow.ScaleFactorProperty,scaleAnimationParams);
> >
> >
> > Now, is there a way to get notified when the animation is finished? The
> > only events that are available through the animation classes are:
> >
> > - Changed
> > - CurrentGlobalSpeedInvalidated
> > - CurrentGlobalStateInvalidated
> > - CurrentTimeInvalidated
> >
> > Thanks!
> > Jason

>
> Taking this even further, it would be nice to have events fired when an
> animation starts as well (given that you can specify a start time for an
> animation which is not exactly now...)
>
> Thanks,
> Jason
>

My System SpecsSystem Spec
Old 01-31-2006   #4 (permalink)
viliescu
Guest


 

Re: Event fired when an animation ends?

if (clock.CurrentState == ClockState.Stopped)
should be
if (clock.CurrentState != ClockState.Active)
--
Valentin Iliescu [MVP C#]


"Jason Dolinger" wrote:

> Jason Dolinger wrote:
> > Hi all,
> >
> > Is there any event that gets fired when an animation ends that we can
> > take advantage of? I have a simple animation that I'm creating in C#
> > code (I'm not doing it in XAML as it must be applied to any number of
> > elements in a collection at the click of a button, and I don't know how
> > one can do that in XAML).
> >
> > It is meant to animate a property called ScaleFactor that I've declared
> > as a DP on a window, and it looks something like this (assume that w is
> > the window on which I want to animate the ScaleFactor DP):
> >
> >
> >
> > DoubleAnimation scaleAnimationParams = new DoubleAnimation();
> >
> > scaleAnimationParams.From = 1;
> > scaleAnimationParams.To = .25;
> > scaleAnimationParams.Duration = new Duration(new TimeSpan(0, 0, 0,
> > 0, 500));
> > w.BeginAnimation(ManagedWindow.ScaleFactorProperty,scaleAnimationParams);
> >
> >
> > Now, is there a way to get notified when the animation is finished? The
> > only events that are available through the animation classes are:
> >
> > - Changed
> > - CurrentGlobalSpeedInvalidated
> > - CurrentGlobalStateInvalidated
> > - CurrentTimeInvalidated
> >
> > Thanks!
> > Jason

>
> Taking this even further, it would be nice to have events fired when an
> animation starts as well (given that you can specify a start time for an
> animation which is not exactly now...)
>
> Thanks,
> Jason
>

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista on HP ends up inqueue. Judy LaRock Vista print fax & scan 1 10-14-2007 08:08 PM
Vista may get me fired Keith Vista music pictures video 4 04-30-2007 09:50 AM
Re: Roy Gets Fired From His Job For Being Transgendered!! spike1@freenet.co.uk Vista General 0 03-03-2007 02:18 AM
Installation ends after 1st reboot Paul Barkholz Vista installation & setup 0 02-20-2007 03:26 PM
Associating an Animation::Completed event with an object John Dunn Avalon 8 12-08-2006 12:45 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51