void InitializeCompositionObject(Wd.CompositionObject source, Wc.CompositionObject target) { // Get the CompositionPropertySet on this object. This has the side-effect of initializing // it and starting any animations. // Prevent infinite recursion - the Properties on a CompositionPropertySet is itself. if (source.Type != Wd.CompositionObjectType.CompositionPropertySet) { GetCompositionPropertySet(source.Properties); } if (source.Comment != null) { target.Comment = source.Comment; } }
void StartAnimations(Wd.CompositionObject source, Wc.CompositionObject target) { foreach (var animator in source.Animators) { var animation = GetCompositionAnimation(animator.Animation); target.StartAnimation(animator.AnimatedProperty, animation); var controller = animator.Controller; if (controller != null) { var animationController = GetAnimationController(controller); if (controller.IsPaused) { animationController.Pause(); } } } }
/// <summary> /// Starts an animation on the given property of a <see cref="CompositionObject"/> /// </summary> /// <param name="target">The target <see cref="CompositionObject"/></param> /// <param name="property">The name of the property to animate</param> /// <param name="value">The final value of the property</param> /// <param name="duration">The animation duration</param> public static Task StartAnimationAsync([NotNull] this CompositionObject target, string property, float value, TimeSpan duration) { // Stop previous animations target.StopAnimation(property); // Setup the animation ScalarKeyFrameAnimation animation = target.Compositor.CreateScalarKeyFrameAnimation(); animation.InsertKeyFrame(1f, value); animation.Duration = duration; // Get the batch and start the animations CompositionScopedBatch batch = target.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation); TaskCompletionSource <object> tcs = new TaskCompletionSource <object>(); batch.Completed += (s, e) => tcs.SetResult(null); target.StartAnimation(property, animation); batch.End(); return(tcs.Task); }
internal void RemoveContext(CompositionObject context, string?propertyName) { _contextStore.RemoveContext(context, propertyName); }
public ContextEntry(CompositionObject context, string?propertyName) { Context = new WeakReference <CompositionObject>(context); PropertyName = propertyName; }
public static void BeginVector3Animation(this CompositionObject compObj, string propertyPath, Vector3 to, Vector3?from, TimeSpan duration, TimeSpan?delay, CompositionEasingFunction ease) { compObj.StartAnimation(propertyPath, compObj.Compositor.CreateVector3KeyFrameAnimation(to, from, duration, delay, ease)); }