/// <summary> /// Inserts a KeyFrame in the KeyFrameAnimation by converting /// the given Expression to appropriate string /// </summary> /// <typeparam name="T">Type of the Expression</typeparam> /// <param name="animation">KeyFrameAnimation</param> /// <param name="normalizedProgressKey">The time the key frame should occur at, expressed as /// a percentage of the animation Duration. Allowed value is from 0.0 to 1.0.</param> /// <param name="expression">The expression used to calculate the value of the key frame.</param> /// <param name="easingFunction">Easing Function (optional)</param> /// <returns>KeyFrameAnimation</returns> public static KeyFrameAnimation InsertExpressionKeyFrame <T>(this KeyFrameAnimation animation, float normalizedProgressKey, Expression <CompositionLambda <T> > expression, CompositionEasingFunction easingFunction = null) { var result = CompositionExpressionEngine.CreateCompositionExpression(expression); animation.InsertExpressionKeyFrame(normalizedProgressKey, result.Expression, easingFunction); animation.SetParameters(result.Parameters); return(animation); }
/// <summary> /// Sets the Expression property of ExpressionAnimation by converting /// the given Expression to appropriate string /// </summary> /// <typeparam name="T">Type of the Expression</typeparam> /// <param name="animation">ExpressionAnimation</param> /// <param name="expression">Expression</param> /// <returns>Dictionary of parameter names and the parameters</returns> public static Dictionary <string, object> SetExpression <T>(this ExpressionAnimation animation, Expression <CompositionLambda <T> > expression) { var result = CompositionExpressionEngine.CreateCompositionExpression(expression); animation.Expression = result.Expression; animation.SetParameters(result.Parameters); return(result.Parameters); }
/// <summary> /// Creates an ExpressionAnimation based on the given CompositionLambda Expression /// </summary> /// <typeparam name="T">Type of the CompositionLambda Expression</typeparam> /// <param name="compositor">Compositor</param> /// <param name="expression">CompositionLambda Expression</param> /// <returns>ExpressionAnimation</returns> public static ExpressionAnimation CreateExpressionAnimation <T>(this Compositor compositor, Expression <CompositionLambda <T> > expression) { var result = CompositionExpressionEngine.CreateCompositionExpression(expression); var animation = compositor.CreateExpressionAnimation(); animation.Expression = result.Expression; animation.SetParameters(result.Parameters); return(animation); }
/// <summary> /// Stops the given animation on the property specified by the given expression. /// The expression is converted to the appropriate property string by the /// CompositionExpressionEngine /// </summary> /// <param name="compositionObject">CompositionObject</param> /// <param name="expression">Expression defining the property on which to stop the animation</param> public static void StopAnimation(this CompositionObject compositionObject, Expression <Func <object> > expression) { compositionObject.StopAnimation(CompositionExpressionEngine.ParseExpression(expression)); }
/// <summary> /// Sets the target for the encapsulated KeyFrameAnimation object /// </summary> /// <param name="targetExpression">Expression for the target</param> /// <returns>KeyFrameAnimation<T></returns> public KeyFrameAnimation <T> ForTarget(Expression <Func <object> > targetExpression) { Animation.Target = CompositionExpressionEngine.ParseExpression(targetExpression); return(this); }