// Returns a name for the given CompositionObject, suitable for use as an identifier.
        static NodeName NameCompositionObject(TNode node, CompositionObject obj)
        {
            var name = NameOf(obj);

            if (name != null)
            {
                // The object has a name, so use it.
                return(NodeName.FromNonTypeName(name));
            }

            return(obj.Type switch
            {
                // For some animations, we can include a description of the start and end values
                // to make the names more descriptive.
                CompositionObjectType.ColorKeyFrameAnimation
                => NodeName.FromNameAndDescription("ColorAnimation", DescribeAnimationRange((ColorKeyFrameAnimation)obj)),
                CompositionObjectType.ScalarKeyFrameAnimation
                => NodeName.FromNameAndDescription($"{TryGetAnimatedPropertyName(node)}ScalarAnimation", DescribeAnimationRange((ScalarKeyFrameAnimation)obj)),

                // Do not include descriptions of the animation range for vectors - the names
                // end up being very long, complicated, and confusing to the reader.
                CompositionObjectType.Vector2KeyFrameAnimation => NodeName.FromNonTypeName($"{TryGetAnimatedPropertyName(node)}Vector2Animation"),
                CompositionObjectType.Vector3KeyFrameAnimation => NodeName.FromNonTypeName($"{TryGetAnimatedPropertyName(node)}Vector3Animation"),
                CompositionObjectType.Vector4KeyFrameAnimation => NodeName.FromNonTypeName($"{TryGetAnimatedPropertyName(node)}Vector4Animation"),

                // Boolean animations don't have interesting range descriptions, but their property name
                // is helpful to know (it is typically "IsVisible").
                CompositionObjectType.BooleanKeyFrameAnimation => NodeName.FromNonTypeName($"{TryGetAnimatedPropertyName(node)}BooleanAnimation"),

                // Geometries include their size as part of the description.
                CompositionObjectType.CompositionRectangleGeometry
                => NodeName.FromNameAndDescription("Rectangle", Vector2AsId(((CompositionRectangleGeometry)obj).Size)),
                CompositionObjectType.CompositionRoundedRectangleGeometry
                => NodeName.FromNameAndDescription("RoundedRectangle", Vector2AsId(((CompositionRoundedRectangleGeometry)obj).Size)),
                CompositionObjectType.CompositionEllipseGeometry
                => NodeName.FromNameAndDescription("Ellipse", Vector2AsId(((CompositionEllipseGeometry)obj).Radius)),

                CompositionObjectType.ExpressionAnimation => NameExpressionAnimation((ExpressionAnimation)obj),
                CompositionObjectType.CompositionColorBrush => NameCompositionColorBrush((CompositionColorBrush)obj),
                CompositionObjectType.CompositionColorGradientStop => NameCompositionColorGradientStop((CompositionColorGradientStop)obj),
                CompositionObjectType.StepEasingFunction => NameStepEasingFunction((StepEasingFunction)obj),

                _ => NameCompositionObjectType(obj.Type),
            });
Beispiel #2
0
 CxInstantiatorGenerator(
     string className,
     CompositionObject graphRoot,
     TimeSpan duration,
     bool setCommentProperties,
     bool disableFieldOptimization,
     CppStringifier stringifier,
     string headerFileName)
     : base(
         className: className,
         graphRoot: graphRoot,
         duration: duration,
         setCommentProperties: setCommentProperties,
         disableFieldOptimization: false,
         stringifier: stringifier)
 {
     _stringifier    = stringifier;
     _headerFileName = headerFileName;
 }
        /// <summary>
        /// Triggers and performs the to-do action.
        /// Groups all selected <see cref="Shape"/>s into a newly created
        /// <see cref="CompositionObject"/>.
        /// </summary>
        /// <seealso cref="UMLAction.Trigger()"/>
        public override void Trigger()
        {
            Shape[] selectedShapes = Canvas.SelectedShapes;

            if (selectedShapes.Length < 2)
            {
                MessageBox.Show("Please select 2 or more object for grouping", "Warning", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }

            CompositionObject compositionObject = GroupShapes(selectedShapes);

            Canvas.AddShape(compositionObject);
            compositionObject.IsSelected = true;
            Canvas.Invalidate();

            base.Trigger();
        }
Beispiel #4
0
        public static FrameworkElement SetImplicitAnimation(this FrameworkElement element, string path, ICompositionAnimationBase animation)
        {
            CompositionObject composition = ElementCompositionPreview.GetElementVisual(element);

            if (composition.ImplicitAnimations == null)
            {
                composition.ImplicitAnimations = composition.Compositor.CreateImplicitAnimationCollection();
            }

            if (animation == null)
            {
                composition.ImplicitAnimations.Remove(path);
            }
            else
            {
                composition.ImplicitAnimations[path] = animation;
            }
            return(element);
        }
Beispiel #5
0
        internal static PropertyId GetNonDefaultCompositionObjectProperties(CompositionObject obj)
        {
            var result = PropertyId.None;

            foreach (var animator in obj.Animators)
            {
                var animatedPropertyName = animator.AnimatedProperty;

                // The property name may contain subchannels. Trim those off.
                var dotIndex = animatedPropertyName.IndexOf('.');
                if (dotIndex > 0)
                {
                    animatedPropertyName = animatedPropertyName.Substring(0, dotIndex);
                }

                result |= PropertyIdFromName(animatedPropertyName);
            }

            return(result);
        }
        public static void CreateAnimation<T>(CompositionObject obj, string Target, TimeSpan Duration) where T : struct
        {
            var compositor = obj.Compositor;

            KeyFrameAnimation an = null;
            if (typeof(T) == typeof(float)) an = compositor.CreateScalarKeyFrameAnimation();
            if (typeof(T) == typeof(Vector2)) an = compositor.CreateVector2KeyFrameAnimation();
            if (typeof(T) == typeof(Vector3)) an = compositor.CreateVector3KeyFrameAnimation();
            if (typeof(T) == typeof(Vector4)) an = compositor.CreateVector4KeyFrameAnimation();
            if (typeof(T) == typeof(Quaternion)) an = compositor.CreateQuaternionKeyFrameAnimation();
            if (typeof(T) == typeof(Color)) an = compositor.CreateColorKeyFrameAnimation();
            if (an == null) return;
            an.InsertExpressionKeyFrame(1f, "this.FinalValue");
            an.Duration = Duration;
            an.Target = Target;
            if (obj.ImplicitAnimations == null)
            {
                obj.ImplicitAnimations = compositor.CreateImplicitAnimationCollection();
            }
            obj.ImplicitAnimations[Target] = an;
        }
Beispiel #7
0
        IEnumerable <XObject> GetCompositionObjectContents(CompositionObject obj)
        {
#if !RenderCommentsAsXmlComments
            if (!string.IsNullOrWhiteSpace(obj.Comment))
            {
                yield return(new XAttribute("Comment", obj.Comment));
            }
#endif // !RenderCommentsAsXmlComments

            // Find the animations that are targetting properties in the property set.
            var propertySetAnimators =
                from pn in obj.Properties.PropertyNames
                from an in obj.Animators
                where an.AnimatedProperty == pn
                select an;

            if (!obj.Properties.IsEmpty)
            {
                yield return(FromCompositionPropertySet(obj.Properties, propertySetAnimators));
            }
        }
Beispiel #8
0
        void StartAnimationsAndFreeze(CompositionObject source, CompositionObject target)
        {
            foreach (var animator in source.Animators)
            {
                var animation = GetCompositionAnimation(animator.Animation);

                // Freeze the animation to indicate that it will not be mutated further. This
                // will ensure that it does not need to be copied when target.StartAnimation is called.
                animation.Freeze();
                target.StartAnimation(animator.AnimatedProperty, animation);
                var controller = animator.Controller;
                if (controller != null)
                {
                    var animationController = GetAnimationController(controller);
                    if (controller.IsPaused)
                    {
                        animationController.Pause();
                    }
                }
            }
        }
        public static void CreateAnimation(CompositionObject obj, string Target, TimeSpan Duration)
        {
            var compositor = obj.Compositor;

            KeyFrameAnimation an = null;
            if (ScalarTargets.Contains(Target)) an = compositor.CreateScalarKeyFrameAnimation();
            if (Vector2Targets.Contains(Target)) an = compositor.CreateVector2KeyFrameAnimation();
            if (Vector3Targets.Contains(Target)) an = compositor.CreateVector3KeyFrameAnimation();
            if (Vector4Targets.Contains(Target)) an = compositor.CreateVector4KeyFrameAnimation();
            if (QuaternionTargets.Contains(Target)) an = compositor.CreateQuaternionKeyFrameAnimation();
            if (ColorTargets.Contains(Target)) an = compositor.CreateColorKeyFrameAnimation();
            if (an == null) return;
            an.InsertExpressionKeyFrame(1f, "this.FinalValue");
            an.Duration = Duration;
            an.Target = Target;
            if (obj.ImplicitAnimations == null)
            {
                obj.ImplicitAnimations = compositor.CreateImplicitAnimationCollection();
            }
            obj.ImplicitAnimations[Target] = an;
        }
Beispiel #10
0
        private static void StartSpyingProperty(
            CompositionObject sourceObject,
            ref string propertyName,
            out CompositionPropertySet propertySet,
            out ExpressionAnimation expressionAnimation,
            out string propertySetPropertyName)
        {
            propertySet             = null;
            propertySetPropertyName = null;
            expressionAnimation     = null;

            if (sourceObject == null || string.IsNullOrWhiteSpace(propertyName))
            {
                throw new ArgumentException();
            }

            propertyName            = propertyName.Trim();
            propertySetPropertyName = propertyName.Replace('.', '_');
            StartSpy <CompositionObject>(sourceObject, s_objectsDictionary, sourceObject.Compositor, ref propertyName, ref propertySetPropertyName, out propertySet, out expressionAnimation);

            expressionAnimation.SetReferenceParameter(c_source, sourceObject);
        }
Beispiel #11
0
        IEnumerable <XObject> FromCompositionObject(CompositionObject obj)
        {
            if (obj == null)
            {
                yield break;
            }

#if RenderCommentsAsXmlComments
            if (!string.IsNullOrWhiteSpace(obj.Comment))
            {
                yield return(new XComment(obj.Comment));
            }
#endif
            switch (obj.Type)
            {
            case CompositionObjectType.AnimationController:
                yield return(FromAnimationController((AnimationController)obj));

                break;

            case CompositionObjectType.ColorKeyFrameAnimation:
                yield return(FromColorKeyFrameAnimation((ColorKeyFrameAnimation)obj));

                break;

            case CompositionObjectType.CompositionColorBrush:
                yield return(FromCompositionColorBrush((CompositionColorBrush)obj));

                break;

            case CompositionObjectType.CompositionContainerShape:
                yield return(FromCompositionContainerShape((CompositionContainerShape)obj));

                break;

            case CompositionObjectType.CompositionEllipseGeometry:
                yield return(FromCompositionEllipseGeometry((CompositionEllipseGeometry)obj));

                break;

            case CompositionObjectType.CompositionEffectBrush:
                yield return(FromCompositionEffectBrush((CompositionEffectBrush)obj));

                break;

            case CompositionObjectType.CompositionLinearGradientBrush:
                yield return(FromCompositionLinearGradientBrush((CompositionLinearGradientBrush)obj));

                break;

            case CompositionObjectType.CompositionPathGeometry:
                yield return(FromCompositionPathGeometry((CompositionPathGeometry)obj));

                break;

            case CompositionObjectType.CompositionPropertySet:
                yield return(FromCompositionPropertySet((CompositionPropertySet)obj));

                break;

            case CompositionObjectType.CompositionRadialGradientBrush:
                yield return(FromCompositionRadialGradientBrush((CompositionRadialGradientBrush)obj));

                break;

            case CompositionObjectType.CompositionRectangleGeometry:
                yield return(FromCompositionRectangleGeometry((CompositionRectangleGeometry)obj));

                break;

            case CompositionObjectType.CompositionRoundedRectangleGeometry:
                yield return(FromCompositionRoundedRectangleGeometry((CompositionRoundedRectangleGeometry)obj));

                break;

            case CompositionObjectType.CompositionSpriteShape:
                yield return(FromCompositionSpriteShape((CompositionSpriteShape)obj));

                break;

            case CompositionObjectType.CompositionViewBox:
                yield return(FromCompositionViewBox((CompositionViewBox)obj));

                break;

            case CompositionObjectType.ContainerVisual:
                yield return(FromContainerVisual((ContainerVisual)obj));

                break;

            case CompositionObjectType.CubicBezierEasingFunction:
                yield return(FromCubicBezierEasingFunction((CubicBezierEasingFunction)obj));

                break;

            case CompositionObjectType.ExpressionAnimation:
                yield return(FromExpressionAnimation((ExpressionAnimation)obj));

                break;

            case CompositionObjectType.InsetClip:
                yield return(FromInsetClip((InsetClip)obj));

                break;

            case CompositionObjectType.CompositionGeometricClip:
                yield return(FromCompositionGeometricClip((CompositionGeometricClip)obj));

                break;

            case CompositionObjectType.LinearEasingFunction:
                yield return(FromLinearEasingFunction((LinearEasingFunction)obj));

                break;

            case CompositionObjectType.PathKeyFrameAnimation:
                yield return(FromPathKeyFrameAnimation((PathKeyFrameAnimation)obj));

                break;

            case CompositionObjectType.ScalarKeyFrameAnimation:
                yield return(FromScalarKeyFrameAnimation((ScalarKeyFrameAnimation)obj));

                break;

            case CompositionObjectType.ShapeVisual:
                yield return(FromShapeVisual((ShapeVisual)obj));

                break;

            case CompositionObjectType.StepEasingFunction:
                yield return(FromStepEasingFunction((StepEasingFunction)obj));

                break;

            case CompositionObjectType.Vector2KeyFrameAnimation:
                yield return(FromVector2KeyFrameAnimation((Vector2KeyFrameAnimation)obj));

                break;

            case CompositionObjectType.SpriteVisual:
                yield return(FromSpriteVisual((SpriteVisual)obj));

                break;

            case CompositionObjectType.CompositionSurfaceBrush:
                yield return(FromCompositionSurfaceBrush((CompositionSurfaceBrush)obj));

                break;

            default:
                throw new InvalidOperationException();
            }
        }
Beispiel #12
0
 XDocument ToXDocument(CompositionObject compositionObject)
 {
     return(new XDocument(FromCompositionObject(compositionObject)));
 }
Beispiel #13
0
 public static XDocument ToXml(CompositionObject compositionObject)
 {
     return(new CompositionObjectXmlSerializer().ToXDocument(compositionObject));
 }
 /// <summary>
 /// Starts the given KeyFrameAnimation&lt;&gt; on the property specified by the given expression.
 /// The expression is converted to the appropriate property string by the
 /// CompositionExpressionEngine
 /// </summary>
 /// <typeparam name="T">Type of the property to be animated.</typeparam>
 /// <param name="compositionObject">CompositionObject</param>
 /// <param name="targetProperty">Property on which the animation has to be started.</param>
 /// <param name="keyframeAnimation">The KeyFrameAnimation to run on the specified property.</param>
 public static void StartAnimation <T>(this CompositionObject compositionObject,
                                       string targetProperty, KeyFrameAnimation <T> keyframeAnimation)
 {
     compositionObject.StartAnimation(targetProperty, keyframeAnimation.Animation);
 }
Beispiel #15
0
 TC CanonicalObject <TC>(CompositionObject obj) => (TC)NodeFor(obj).Object;
 /// <summary>
 /// Starts the given KeyFrameAnimation&lt;&gt; on the property specified by the given expression.
 /// The expression is converted to the appropriate property string by the
 /// CompositionExpressionEngine
 /// </summary>
 /// <typeparam name="T">Type of the property to be animated.</typeparam>
 /// <param name="compositionObject">CompositionObject</param>
 /// <param name="expression">Lambda expression defining the property on
 /// which the animation has to be started.</param>
 /// <param name="keyframeAnimation">The KeyFrameAnimation to run on the specified property.</param>
 public static void StartAnimation <T>(this CompositionObject compositionObject,
                                       Expression <Func <T> > expression, KeyFrameAnimation <T> keyframeAnimation)
 {
     compositionObject.StartAnimation(CompositionExpressionEngine.ParseExpression(expression), keyframeAnimation.Animation);
 }
 public void SetReferenceParameter(string key, CompositionObject compositionObject) =>
 _propertySet.Set(key, compositionObject);
Beispiel #18
0
        XDocument ToXDocument(CompositionObject compositionObject)
        {
            // Build the graph of objects.
            _objectGraph = ObjectGraph <ObjectData> .FromCompositionObject(compositionObject, includeVertices : true);

            // Give names to each object.
            foreach ((var node, var name) in CodeGen.NodeNamer <ObjectData> .GenerateNodeNames(_objectGraph.Nodes))
            {
                node.Name = name;
            }

            // Initialize each node.
            foreach (var n in _objectGraph.Nodes)
            {
                n.Initialize(this);
            }

            // Second stage initialization - relies on all nodes having had the first stage of initialization.
            foreach (var n in _objectGraph.Nodes)
            {
                n.Initialize2();
            }

            var rootNode = _objectGraph[compositionObject];

            // Give the root object a special name and category.
            rootNode.Name     = $"{rootNode.Name} (Root)";
            rootNode.Category = CategoryRoot;

            // Get the groups.
            var groups = GroupTree(rootNode, null).ToArray();

            // Get the Nodes for the objects that are going to show up in the DGML.
            var objectNodes = _objectGraph.Nodes.Where(n => n.IsDgmlNode).ToArray();

            // Create the DGML nodes.
            var nodes =
                from n in objectNodes
                select CreateNodeXml(id : n.Id, label : n.Name, category : n.Category.Id);

            // Create the DGML nodes for the groups.
            nodes = nodes.Concat(
                from gn in groups
                select CreateNodeXml(id: gn.Id, label: gn.GroupName, @group: "Expanded"));

            // Create the categories used by object nodes.
            var categories =
                (from n in objectNodes
                 select n.Category).Distinct();

            // Create the links between the nodes.
            var links =
                from n in objectNodes
                from otherNode in n.Children
                select new XElement(ns + "Link", new XAttribute("Source", n.Id), new XAttribute("Target", otherNode.Id));

            // Create the "contains" links for the nodes contained in groups.
            var containsLinks =
                (from g in groups
                 from member in g.ItemsInGroup
                 select new XElement(ns + "Link", new XAttribute("Source", g.Id), new XAttribute("Target", member.Id), new XAttribute("Category", "Contains"))).ToArray();

            // Create the "contains" links for the groups contained in groups
            var groupContainsGroupsLinks =
                (from g in groups
                 from member in g.GroupsInGroup
                 select new XElement(ns + "Link", new XAttribute("Source", g.Id), new XAttribute("Target", member.Id), new XAttribute("Category", "Contains"))).ToArray();

            containsLinks = containsLinks.Concat(groupContainsGroupsLinks).ToArray();

            // Create the XML
            return(new XDocument(
                       new XElement(
                           ns + "DirectedGraph",
                           new XElement(ns + "Nodes", nodes),
                           new XElement(ns + "Links", links.Concat(containsLinks)),
                           new XElement(
                               ns + "Categories",
                               categories.Select(c => c.ToXElement()).Append(
                                   new XElement(
                                       ns + "Category",
                                       new XAttribute("Id", "Contains"),
                                       new XAttribute("Label", "Contains"),
                                       new XAttribute("Description", "Whether the source of the link contains the target object"),
                                       new XAttribute("CanBeDataDriven", "False"),
                                       new XAttribute("CanLinkedNodesBeDataDriven", "True"),
                                       new XAttribute("IncomingActionLabel", "Contained By"),
                                       new XAttribute("IsContainment", "True"),
                                       new XAttribute("OutgoingActionLabel", "Contains")))
                               ),
                           new XElement(
                               ns + "Properties",
                               CreatePropertyXml(id: "Bounds", dataType: "System.Windows.Rect"),
                               CreatePropertyXml(id: "CanBeDataDriven", label: "CanBeDataDriven", description: "CanBeDataDriven", dataType: "System.Boolean"),
                               CreatePropertyXml(id: "CanLinkedNodesBeDataDriven", label: "CanLinkedNodesBeDataDriven", description: "CanLinkedNodesBeDataDriven", dataType: "System.Boolean"),
                               CreatePropertyXml(id: "Group", label: "Group", description: "Display the node as a group", dataType: "Microsoft.VisualStudio.GraphModel.GraphGroupStyle"),
                               CreatePropertyXml(id: "IncomingActionLabel", label: "IncomingActionLabel", description: "IncomingActionLabel", dataType: "System.String"),
                               CreatePropertyXml(id: "IsContainment", dataType: "System.Boolean"),
                               CreatePropertyXml(id: "Label", label: "Label", description: "Displayable label of an Annotatable object", dataType: "System.String"),
                               CreatePropertyXml(id: "Layout", dataType: "System.String"),
                               CreatePropertyXml(id: "OutgoingActionLabel", label: "OutgoingActionLabel", description: "OutgoingActionLabel", dataType: "System.String"),
                               CreatePropertyXml(id: "UseManualLocation", dataType: "System.Boolean"),
                               CreatePropertyXml(id: "ZoomLevel", dataType: "System.String")
                               )
                           )
                       ));
        }
Beispiel #19
0
 public static void WithExpression(
     CompositionObject compObject,
     ExpressionAnimation animation,
     string target) =>
 compObject.StartAnimation(target, animation);
 /// <summary>
 /// Connects the specified ExpressionNode with the specified property of the object.
 /// </summary>
 /// <param name="compObject">The comp object.</param>
 /// <param name="propertyName">The name of the property that the expression will target.</param>
 /// <param name="expressionNode">The root ExpressionNode that represents the ExpressionAnimation.</param>
 public static void StartAnimation(this CompositionObject compObject, string propertyName, ExpressionNode expressionNode)
 {
     compObject.StartAnimation(propertyName, CreateExpressionAnimationFromNode(compObject.Compositor, expressionNode));
 }
Beispiel #21
0
 ObjectData NodeFor(CompositionObject obj)
 {
     return(_graph[obj].Canonical);
 }
            public CompositionAnimation GetAnimation(CompositionObject targetHint, out CompositionObject?target)
            {
                CompositionEasingFunction?easingFunction = targetHint.Compositor.TryCreateEasingFunction(EasingType, EasingMode);

                (AnimationIterationBehavior iterationBehavior, int iterationCount) = Repeat.ToBehaviorAndCount();

                target = null;

                if (typeof(T) == typeof(bool))
                {
                    return(targetHint.Compositor.CreateBooleanKeyFrameAnimation(
                               Property,
                               GetToAs <bool>(),
                               GetFromAs <bool>(),
                               Delay,
                               Duration,
                               iterationBehavior: iterationBehavior,
                               iterationCount: iterationCount));
                }

                if (typeof(T) == typeof(float))
                {
                    return(targetHint.Compositor.CreateScalarKeyFrameAnimation(
                               Property,
                               GetToAs <float>(),
                               GetFromAs <float>(),
                               Delay,
                               Duration,
                               easingFunction,
                               iterationBehavior: iterationBehavior,
                               iterationCount: iterationCount));
                }

                if (typeof(T) == typeof(double))
                {
                    return(targetHint.Compositor.CreateScalarKeyFrameAnimation(
                               Property,
                               (float)GetToAs <double>(),
                               (float?)GetFromAs <double>(),
                               Delay,
                               Duration,
                               easingFunction,
                               iterationBehavior: iterationBehavior,
                               iterationCount: iterationCount));
                }

                if (typeof(T) == typeof(Vector2))
                {
                    return(targetHint.Compositor.CreateVector2KeyFrameAnimation(
                               Property,
                               GetToAs <Vector2>(),
                               GetFromAs <Vector2>(),
                               Delay,
                               Duration,
                               easingFunction,
                               iterationBehavior: iterationBehavior,
                               iterationCount: iterationCount));
                }

                if (typeof(T) == typeof(Vector3))
                {
                    return(targetHint.Compositor.CreateVector3KeyFrameAnimation(
                               Property,
                               GetToAs <Vector3>(),
                               GetFromAs <Vector3>(),
                               Delay,
                               Duration,
                               easingFunction,
                               iterationBehavior: iterationBehavior,
                               iterationCount: iterationCount));
                }

                if (typeof(T) == typeof(Vector4))
                {
                    return(targetHint.Compositor.CreateVector4KeyFrameAnimation(
                               Property,
                               GetToAs <Vector4>(),
                               GetFromAs <Vector4>(),
                               Delay,
                               Duration,
                               easingFunction,
                               iterationBehavior: iterationBehavior,
                               iterationCount: iterationCount));
                }

                if (typeof(T) == typeof(Color))
                {
                    return(targetHint.Compositor.CreateColorKeyFrameAnimation(
                               Property,
                               GetToAs <Color>(),
                               GetFromAs <Color>(),
                               Delay,
                               Duration,
                               easingFunction,
                               iterationBehavior: iterationBehavior,
                               iterationCount: iterationCount));
                }

                if (typeof(T) == typeof(Quaternion))
                {
                    return(targetHint.Compositor.CreateQuaternionKeyFrameAnimation(
                               Property,
                               GetToAs <Quaternion>(),
                               GetFromAs <Quaternion>(),
                               Delay,
                               Duration,
                               easingFunction,
                               iterationBehavior: iterationBehavior,
                               iterationCount: iterationCount));
                }

                throw new InvalidOperationException("Invalid animation type");
            }
Beispiel #23
0
 TNode NodeFor(CompositionObject obj) => _graph[obj].Canonical;
 /// <summary>
 /// This extension method is a dummy method added to specify to start/stop animation on the
 /// 'Scale.XY' property of the CompositionObject. Though no such property exists in CompositionObject,
 /// it merely indicates that the animation has to be executed (or stopped) on both the 'Scale.X' and 'Scale.Y'
 /// properties of the CompositionObject.
 /// </summary>
 /// <param name="compositionObject">CompositionObject</param>
 /// <returns></returns>
 public static string ScaleXY(this CompositionObject compositionObject)
 {
     return("Scale.XY");
 }
 /// <summary>
 /// This extension method is a dummy method added to specify to start/stop animation on the
 /// 'Scale.XY' property of the CompositionObject. Though no such property exists in CompositionObject,
 /// it merely indicates that the animation has to be executed (or stopped) on both the 'Scale.X' and 'Scale.Y'
 /// properties of the CompositionObject.
 /// </summary>
 /// <param name="compositionObject">CompositionObject</param>
 /// <returns>Vector2</returns>
 public static Vector2 ScaleXY(this CompositionObject compositionObject)
 {
     return(new Vector2());
 }
 public static CubicBezierEasingFunction GetCubicBeizerFunction(CompositionObject compObject, float x1, float y1, float x2, float y2)
 {
     return compObject.Compositor.CreateCubicBezierEasingFunction(new Vector2 { X = x1, Y = y1 }, new Vector2 { X = x2, Y = y2 });
 }
 /// <summary>
 /// Connects an ExpressionAnimation&lt;T&gt; with the specified property of the object
 /// and starts the animation.
 /// </summary>
 /// <typeparam name="T">Type of the property to be animated</typeparam>
 /// <param name="compositionObject">The object on whose property the animation has to
 /// be started.</param>
 /// <param name="targetProperty">Property on which the animation has to be started.</param>
 /// <param name="expressionAnimation">The ExpressionAnimation&lt;T&gt; to run on the specified property.</param>
 public static void StartAnimation <T>(this CompositionObject compositionObject,
                                       string targetProperty, ExpressionAnimation <T> expressionAnimation)
 {
     compositionObject.StartAnimation(targetProperty, expressionAnimation.Animation);
 }
 /// <summary>
 /// ��һ���������붯����
 /// </summary>
 /// <param name="key"></param>
 /// <param name="parameter"></param>
 /// <returns></returns>
 public AnimationFluentContext SetParameter(string key, CompositionObject parameter)
 {
     CompositionAnimation.SetReferenceParameter(key, parameter);
     return this;
 }
 /// <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));
 }
 public TargetedCompositionAnimation(CompositionObject compositionObject, Expression expression, CompositionAnimation animation)
 {
     Target         = compositionObject;
     TargetProperty = ExpressionHelper.ExpressionToPropertyName(expression);
     Animation      = animation;
 }
 /// <summary>
 /// Analyzes the given tree and returns information about its compatibility with a runtime.
 /// </summary>
 /// <returns>An object with properties describing the compatibility requirements of the tree.</returns>
 public static ApiCompatibility Analyze(CompositionObject graphRoot)
 {
     // Always require CompostionGeometryClip - this ensures that we are never compatible with
     // RS4 (geometries are flaky in RS4, and CompositionGeometryClip is new in RS5).
     return(new ApiCompatibility(requiresCompositionGeometricClip: true));
 }
Beispiel #32
0
 public ReferenceInfo(string paramName, CompositionObject compObj)
 {
     ParameterName = paramName;
     CompObject    = compObj;
 }