Events

Types

  • Complete
  • Update
  • Stopped
  • Begin

Usage

// create ease
EaseObject easeObject = ArtefactAnimator.AddEase(element, AnimationTypes.Alpha, 0, time, ease, delay);

// add callback
easeObject.Complete += new EaseObjectHandler(CompleteHandler);

// handle callback
void CompleteHandler(EaseObject easeObject, double percent)
{
    Debug.WriteLine("Complete");
}

Event Extensions

Instead of the += way of attaching an event, Extensions can help add multiple listeners while keeping code on the same line.

easeObject.OnComplete(EaseComplete).OnUpdate(EaseUpdated).OnBegin(EaseBegin);

Events using Lambda Expressions

The easiest and fastest way of adding callbacks is by using lambda expressions combined with the extensions.

element.AutoAlphaTo(0, time, ease, delay)
.OnBegin((eo, p) => Debug.WriteLine("Begin Percent=" + p))
.OnUpdate((eo, p) => Debug.WriteLine("Updated Percent=" + p))
.OnComplete((eo, p) => Debug.WriteLine("Complete Percent=" + p));

Callbacks

Standard EventHandlers can be wrapped in the Callback Extension.

void RunAnimation(UIElement element, EventHandler callback)
{
    double time = .8;
    double delay = 0;
    PercentHandler ease = AnimationTransitions.CubicEaseOut;

    element.AutoAlphaTo(0, time, ease, delay).Callback(callback);
}

void AnimationsComplete(object sender, EventArgs args)
{
    Debug.WriteLine("Animations Completed");
}

Last edited Mar 2, 2010 at 7:51 PM by jgraup, version 2

Comments

No comments yet.