public override CompositionAnimation BuildCompositionAnimation() { if (CompositionAnimation != null) { return(CompositionAnimation); } if (TargetElement == null) { throw new InvalidOperationException("没有为动画提供目标对象。"); } if (TargetProperty == VisualProperty.None) { throw new InvalidOperationException("没有为动画提供目标属性。"); } CompositionAnimation?.Dispose(); CompositionAnimation = TargetVisual.Compositor.CreateExpressionAnimation(Expression); foreach (var parameter in Parameters) { parameter.AddParameterToAnimation(CompositionAnimation); } return(CompositionAnimation); }
CompositionAnimation GetCompositionAnimation(CompositionAnimation obj) { switch (obj.Type) { case CompositionObjectType.ExpressionAnimation: return(GetExpressionAnimation((ExpressionAnimation)obj)); case CompositionObjectType.ColorKeyFrameAnimation: return(GetColorKeyFrameAnimation((ColorKeyFrameAnimation)obj)); case CompositionObjectType.PathKeyFrameAnimation: return(GetPathKeyFrameAnimation((PathKeyFrameAnimation)obj)); case CompositionObjectType.ScalarKeyFrameAnimation: return(GetScalarKeyFrameAnimation((ScalarKeyFrameAnimation)obj)); case CompositionObjectType.Vector2KeyFrameAnimation: return(GetVector2KeyFrameAnimation((Vector2KeyFrameAnimation)obj)); case CompositionObjectType.Vector3KeyFrameAnimation: return(GetVector3KeyFrameAnimation((Vector3KeyFrameAnimation)obj)); default: throw new InvalidOperationException(); } }
public static void StopAnimation(this CompositionObject compositionObject, CompositionAnimation animation) { if (string.IsNullOrWhiteSpace(animation.Target)) throw new ArgumentNullException("Animation has no target"); compositionObject.StopAnimation(animation.Target); }
public static ICompositionAnimationBase CreateAnimationGroup(CompositionAnimation listContentShowAnimations, ScalarKeyFrameAnimation listContentOpacityAnimations) { var group = Window.Current.Compositor.CreateAnimationGroup(); group.Add(listContentShowAnimations); group.Add(listContentOpacityAnimations); return(group); }
public void ApplyDesaturationAnimation(CompositionAnimation animation) { if (_saturationEffect != null) { _saturationEffect.Properties.StartAnimation( "myEffect.Saturation", animation); } }
public virtual void Dispose() { if (TargetProperty != VisualProperty.None) { TargetVisual?.StopAnimation(TargetProperty.ToString()); } CompositionAnimation?.Dispose(); CompositionAnimation = null; }
public CompositionAnimation GetScrollAnimation( int correlationId, Vector2 currentPosition, CompositionAnimation defaultAnimation) { LogMessage( "ScrollBarController: GetScrollAnimation for Orientation=" + Orientation + " with offsetChangeCorrelationId=" + correlationId + ", currentPosition=" + currentPosition); return(null); }
public CompositionAnimation GetScrollAnimation( ScrollInfo info, Vector2 currentPosition, CompositionAnimation defaultAnimation) { LogMessage( "ScrollBarController: GetScrollAnimation for Orientation=" + Orientation + " with offsetChangeId=" + info.OffsetsChangeId + ", currentPosition=" + currentPosition); return(null); }
internal static CompositionAnimation ApplyParameters(CompositionAnimation animation, CompositionAnimationPropertyCollection parameters) { foreach (var p in parameters.Keys.ToList()) { var type = parameters[p].GetType(); if (type == typeof(float)) { animation.SetScalarParameter(p, (float)parameters[p]); } else if (parameters[p] is CompositionObject) { animation.SetReferenceParameter(p, (CompositionObject)parameters[p]); } else if (parameters[p] is CompositionPropertySetWrapper) { parameters[p] = ((CompositionPropertySetWrapper)parameters[p]).PropertySet; animation.SetReferenceParameter(p, (CompositionObject)parameters[p]); } else if (type == typeof(Vector2)) { animation.SetVector2Parameter(p, (Vector2)parameters[p]); } else if (type == typeof(Vector3)) { animation.SetVector3Parameter(p, (Vector3)parameters[p]); } else if (type == typeof(Vector4)) { animation.SetVector4Parameter(p, (Vector4)parameters[p]); } else if (type == typeof(Matrix3x2)) { animation.SetMatrix3x2Parameter(p, (Matrix3x2)parameters[p]); } else if (type == typeof(Matrix4x4)) { animation.SetMatrix4x4Parameter(p, (Matrix4x4)parameters[p]); } else if (type == typeof(Quaternion)) { animation.SetQuaternionParameter(p, (Quaternion)parameters[p]); } else if (type == typeof(Color)) { animation.SetColorParameter(p, (Color)parameters[p]); } else { parameters[p] = CompositionPropertySetExtensions.ToPropertySet(parameters[p], animation.Compositor); animation.SetReferenceParameter(p, (CompositionObject)parameters[p]); } } return(animation); }
internal Animator( string animatedProperty, CompositionObject animatedObject, CompositionAnimation animation, AnimationController controller) { AnimatedProperty = animatedProperty; AnimatedObject = animatedObject; Animation = animation; Controller = controller; }
/// <summary> /// Adds a composition effect animation to be run on backing <see cref="Visual"/> /// </summary> /// <param name="effectBrush">The <see cref="CompositionEffectBrush"/> that will have a property animated</param> /// <param name="animation">The animation to be applied</param> /// <param name="propertyName">The property of the effect to be animated</param> public void AddCompositionEffectAnimation(CompositionObject effectBrush, CompositionAnimation animation, string propertyName) { var effect = new EffectAnimationDefinition() { EffectBrush = effectBrush, Animation = animation, PropertyName = propertyName }; _compositionEffectAnimations.Add(effect); }
internal void SetAllParameters(CompositionAnimation anim) { // Make sure the list is populated EnsureReferenceInfo(); foreach (var refInfo in _objRefList) { anim.SetReferenceParameter(refInfo.ParameterName, refInfo.CompObject); } foreach (var constParam in _constParamMap) { if (constParam.Value.GetType() == typeof(bool)) { anim.SetBooleanParameter(constParam.Key, (bool)constParam.Value); } else if (constParam.Value.GetType() == typeof(float)) { anim.SetScalarParameter(constParam.Key, (float)constParam.Value); } else if (constParam.Value.GetType() == typeof(Vector2)) { anim.SetVector2Parameter(constParam.Key, (Vector2)constParam.Value); } else if (constParam.Value.GetType() == typeof(Vector3)) { anim.SetVector3Parameter(constParam.Key, (Vector3)constParam.Value); } else if (constParam.Value.GetType() == typeof(Vector4)) { anim.SetVector4Parameter(constParam.Key, (Vector4)constParam.Value); } else if (constParam.Value.GetType() == typeof(Color)) { anim.SetColorParameter(constParam.Key, (Color)constParam.Value); } else if (constParam.Value.GetType() == typeof(Quaternion)) { anim.SetQuaternionParameter(constParam.Key, (Quaternion)constParam.Value); } else if (constParam.Value.GetType() == typeof(Matrix3x2)) { anim.SetMatrix3x2Parameter(constParam.Key, (Matrix3x2)constParam.Value); } else if (constParam.Value.GetType() == typeof(Matrix4x4)) { anim.SetMatrix4x4Parameter(constParam.Key, (Matrix4x4)constParam.Value); } else { throw new Exception($"Unexpected constant parameter datatype ({constParam.Value.GetType()})"); } } }
public SlidableListItem() { DefaultStyleKey = typeof(SlidableListItem); compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; resetOffsetAnimation = CreateAnimation(200); resetOpacityAnimation = CreateAnimation(200); offsetAnimation = CreateAnimation(350); opacityAnimation = CreateAnimation(350); Loaded += OnLoaded; }
static void StartProgressBoundAnimation( CompositionObject target, string animatedPropertyName, CompositionAnimation animation, ExpressionAnimation controllerProgressExpression) { target.StartAnimation(animatedPropertyName, animation); var controller = target.TryGetAnimationController(animatedPropertyName); controller.Pause(); controller.StartAnimation("Progress", controllerProgressExpression); }
private void Player_FirstFrameRendered(object sender, EventArgs e) { _thumbnailShimmer = null; ElementCompositionPreview.SetElementChildVisual(Player, null); var sticker = _message?.Content as MessageSticker; if (sticker?.Sticker.PremiumAnimation != null && sticker.IsPremium && _message.GeneratedContentUnread && IsLoaded) { _message.GeneratedContentUnread = false; PlayPremium(_message, sticker.Sticker); } }
bool StartAnimationGroupPart(CompositionAnimation animation, string target, ExpressionVariant finalValue) { if (animation.Target == null) { throw new ArgumentException("Animation Target can't be null"); } if (animation.Target == target) { StartAnimation(animation.Target, animation, finalValue); return(true); } else { StartAnimation(animation.Target, animation); return(false); } }
public void ApplyDesaturationAnimation(CompositionAnimation animation) { if (_saturationAnimator != null) { _saturationAnimator.Dispose(); _saturationAnimator = null; } if (_saturationEffect != null) { _saturationAnimator = _saturationEffect.Properties.ConnectAnimation( "myEffect.Saturation", animation); _saturationAnimator.Start(); } }
public void StartAnimation() { if (_animation != null) { return; } _iconVisual = GestureIcon.GetVisual(); var comp = _iconVisual.Compositor; var animation = comp.CreateVector3KeyFrameAnimation(); animation.InsertKeyFrame(0f, new Vector3(0f, 0f, 0f)); animation.InsertKeyFrame(0.5f, new Vector3(0f, 80f, 0f)); animation.InsertKeyFrame(1f, new Vector3(0f, 0f, 0f)); animation.Duration = TimeSpan.FromMilliseconds(2000); animation.Direction = AnimationDirection.Normal; animation.IterationBehavior = AnimationIterationBehavior.Forever; _iconVisual.StartAnimation("Translation", animation); _animation = animation; }
XElement FromAnimation <T>(string name, CompositionAnimation animation, T?initialValue) where T : struct { switch (animation.Type) { case CompositionObjectType.ExpressionAnimation: return(FromExpressionAnimation((ExpressionAnimation)animation, name)); case CompositionObjectType.ColorKeyFrameAnimation: case CompositionObjectType.PathKeyFrameAnimation: case CompositionObjectType.ScalarKeyFrameAnimation: case CompositionObjectType.Vector2KeyFrameAnimation: case CompositionObjectType.Vector3KeyFrameAnimation: return(FromKeyFrameAnimation(name, (KeyFrameAnimation <T>)animation, initialValue)); default: throw new InvalidOperationException(); } }
internal ImplicitAnimationCollection GetImplicitAnimationCollection(UIElement parent) { Compositor compositor = ElementCompositionPreview.GetElementVisual(parent).Compositor; ImplicitAnimationCollection animations = compositor.CreateImplicitAnimationCollection(); foreach (IImplicitTimeline timeline in this) { CompositionAnimation animation = timeline.GetAnimation(parent, out string?target); target ??= animation.Target; if (!animations.ContainsKey(target)) { animations[target] = animations.Compositor.CreateAnimationGroup(); } ((CompositionAnimationGroup)animations[target]).Add(animation); } return(animations); }
public override CompositionAnimation BuildCompositionAnimation() { if (CompositionAnimation != null) { return(CompositionAnimation); } if (TargetElement == null) { throw new InvalidOperationException("没有为动画提供目标对象。"); } if (TargetProperty == VisualProperty.None) { throw new InvalidOperationException("没有为动画提供目标属性。"); } CompositionAnimation?.Dispose(); var resultAnimation = CreateCompositionAnimation(TargetVisual.Compositor); CompositionAnimation = resultAnimation; resultAnimation.DelayTime = DelayTime; resultAnimation.Duration = Duration; resultAnimation.IterationBehavior = IterationBehavior; resultAnimation.IterationCount = IterationCount; resultAnimation.StopBehavior = StopBehavior; foreach (var parameter in Parameters) { parameter.AddParameterToAnimation(resultAnimation); } foreach (var keyFrame in KeyFrames) { keyFrame.AddKayFrameToAnimation(resultAnimation); } return(CompositionAnimation); }
public TargetedCompositionAnimation(CompositionObject compositionObject, Expression expression, CompositionAnimation animation) { Target = compositionObject; TargetProperty = ExpressionHelper.ExpressionToPropertyName(expression); Animation = animation; }
private void InitializeAnimations() { FadeOutAnimation = Compositor.FadeOut(1500); LandAnimation = Compositor.Land(500,duration); }
internal virtual void StartAnimation(string propertyName, CompositionAnimation animation, ExpressionVariant?finalValue) { throw new ArgumentException("Unknown property " + propertyName); }
/// <summary> /// Connects an animation with the specified property of the object and starts the animation. /// </summary> public void StartAnimation(string propertyName, CompositionAnimation animation) => StartAnimation(propertyName, animation, null);
/// <summary> /// Starts 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 start the animation</param> /// <param name="animation">The animation to execute on the specified property</param> public static void StartAnimation(this CompositionObject compositionObject, Expression<Func<object>> expression, CompositionAnimation animation) { compositionObject.StartAnimation(CompositionExpressionEngine.ParseExpression(expression), animation); }
public void ApplyDesaturationAnimation(CompositionAnimation animation) { if (_saturationAnimator != null) { _saturationAnimator.Dispose(); _saturationAnimator = null; } if (_saturationEffect != null) { _saturationAnimator = _saturationEffect.Properties.ConnectAnimation( "myEffect.Saturation", animation); _saturationAnimator.Start(); } }
private void InitializeAnimations() { FadeOutAnimation = Compositor.FadeOut(duration); }
private void InitializeAnimations() { FadeInAnimation = Compositor.FadeIn(); FadeOutAnimation = Compositor.FadeOut(); }
private void Player_FirstFrameRendered(object sender, EventArgs e) { _thumbnailShimmer = null; ElementCompositionPreview.SetElementChildVisual(Player, null); }
private void UpdateThumbnail(MessageViewModel message, Sticker sticker) { _thumbnailShimmer = CompositionPathParser.ParseThumbnail(sticker, out ShapeVisual visual); ElementCompositionPreview.SetElementChildVisual(Player, visual); }
public void ApplyDesaturationAnimation(CompositionAnimation animation) { if (_saturationEffect != null) { _saturationEffect.Properties.StartAnimation( "myEffect.Saturation", animation); } }
private void InitializeAnimations() { SlideInAnimation = Compositor.SlideIn(500,500); SlideOutAnimation = Compositor.SlideOut(500,500); }
public virtual void Dispose() { if (Property != null) { TargetVisual?.DisconnectAnimation(Property); } CompositionAnimation?.Dispose(); CompositionAnimation = null; Animator?.Dispose(); Animator = null; }
static public void StartAnimation(this UIElement element, string propertyName, CompositionAnimation animation) { var visual = ElementCompositionPreview.GetElementVisual(element); visual.StartAnimation(propertyName, animation); }
/// <summary> /// Adds a composition animation to be run on <see cref="StartAsync"/> /// </summary> /// <param name="propertyName">The property to be animated on the backing Visual</param> /// <param name="animation">The <see cref="CompositionAnimation"/> to be applied</param> public void AddCompositionAnimation(string propertyName, CompositionAnimation animation) { _compositionAnimations[propertyName] = animation; }
/// <summary> /// 为动画添加参数。 /// </summary> /// <param name="animation"></param> public override void AddParameterToAnimation(CompositionAnimation animation) { animation.SetVector3Parameter(Key, ObjectValue); }
private void InitializeAnimations() { FallDownAnimation = Compositor.FallDown(500, 500); FallUpAnimation = Compositor.FallUp(500, 500); }
public virtual void Dispose() { if (TargetProperty != VisualProperty.None) { TargetVisual?.StopAnimation(TargetProperty.ToString()); } CompositionAnimation?.Dispose(); CompositionAnimation = null; }
private void InitializeAnimations() { FadeInAnimation = Compositor.FadeIn(250); FadeOutAnimation = Compositor.FadeOut(250); DropInAnimation = Compositor.DropIn(500); DropOutAnimation = Compositor.DropOut(500); }
private async Task InitializeAnimations() { FadeInAnimation = Compositor.FadeIn(1500); var elementFramework = Element as FrameworkElement; while (elementFramework.ActualHeight <= 0) await Task.Delay(60); var altitude = elementFramework.ActualHeight + elementFramework.Margin.Top; TakeOffAnimation = Compositor.TakeOff(500 + altitude,1500); }
/// <summary> /// Starts 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 start the animation</param> /// <param name="animation">The animation to execute on the specified property</param> public static void StartAnimation(this CompositionObject compositionObject, Expression <Func <object> > expression, CompositionAnimation animation) { compositionObject.StartAnimation(CompositionExpressionEngine.ParseExpression(expression), animation); }
private void InitializeAnimations() { SquaresDownAnimation = Compositor.RotateClock(); SquaresUpAnimation = Compositor.RotateUnClock(); }