private void UpdateTo()
        {
            if (host == null)
            {
                return;
            }
            propset.StopAnimation("offsetx");
            propset.StopAnimation("offsety");
            ExpressionAnimation an = null;

            switch (To)
            {
            case FlipTransitionMode.Left:
                an = host.Compositor.CreateExpressionAnimation("-host.Size.X");
                an.SetReferenceParameter("host", host);
                propset.StartAnimation("offsetx", an);
                propset.InsertScalar("offsety", 0f);
                propset.InsertScalar("degress", 90f);
                propset.InsertVector3("axis", Vector3.UnitY);
                break;

            case FlipTransitionMode.Top:
                an = host.Compositor.CreateExpressionAnimation("-host.Size.Y");
                an.SetReferenceParameter("host", host);
                propset.InsertScalar("offsetx", 0f);
                propset.StartAnimation("offsety", an);
                propset.InsertScalar("degress", 90f);
                propset.InsertVector3("axis", Vector3.UnitX);
                break;

            case FlipTransitionMode.Right:
                an = host.Compositor.CreateExpressionAnimation("host.Size.X");
                an.SetReferenceParameter("host", host);
                propset.StartAnimation("offsetx", an);
                propset.InsertScalar("offsety", 0f);
                propset.InsertScalar("degress", -90f);
                propset.InsertVector3("axis", Vector3.UnitY);
                break;

            case FlipTransitionMode.Bottom:
                an = host.Compositor.CreateExpressionAnimation("host.Size.Y");
                an.SetReferenceParameter("host", host);
                propset.InsertScalar("offsetx", 0f);
                propset.StartAnimation("offsety", an);
                propset.InsertScalar("degress", -90f);
                propset.InsertVector3("axis", Vector3.UnitX);
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Stops spying on the property of the provided object.
        /// </summary>
        /// <param name="sourceObject"></param>
        /// <param name="propertyName"></param>
        public static void StopSpyingProperty(CompositionObject sourceObject, string propertyName)
        {
            if (sourceObject == null || string.IsNullOrWhiteSpace(propertyName))
            {
                throw new ArgumentException();
            }

            CompositionPropertySet propertySet = null;
            Dictionary <string, ExpressionAnimation> expressionAnimations = null;
            ExpressionAnimation expressionAnimation = null;
            string propertySetPropertyName          = null;

            GetExpressionAnimation <CompositionObject>(
                sourceObject,
                propertyName,
                s_objectsDictionary,
                out propertySet,
                out expressionAnimations,
                out expressionAnimation,
                out propertySetPropertyName);

            if (propertySet != null)
            {
                propertySet.StopAnimation(propertySetPropertyName);
                expressionAnimations.Remove(propertySetPropertyName);
            }
        }
Beispiel #3
0
        private static void StopSpyingFacade(UIElement sourceElement, CompositionFacadeType facadeType)
        {
            if (sourceElement == null)
            {
                throw new ArgumentException();
            }

            CompositionPropertySet propertySet = null;
            Dictionary <string, ExpressionAnimation> expressionAnimations = null;
            ExpressionAnimation expressionAnimation = null;
            string propertySetPropertyName          = null;

            GetExpressionAnimation <UIElement>(
                sourceElement,
                FacadeTypeToStringName(facadeType),
                s_elementsDictionary,
                out propertySet,
                out expressionAnimations,
                out expressionAnimation,
                out propertySetPropertyName);

            if (propertySet != null)
            {
                propertySet.StopAnimation(propertySetPropertyName);
                expressionAnimations.Remove(propertySetPropertyName);
            }
        }
Beispiel #4
0
 public override void OnPointerExit(Vector2 pointerPosition, CompositionImage image)
 {
     _propertySet.StartAnimation("Translate", _exitAnimation);
     _propertySet.StopAnimation("Scale");
 }
Beispiel #5
0
        private static CompositionGetValueStatus TryGetValue <T>(
            T source,
            Dictionary <T, KeyValuePair <CompositionPropertySet, Dictionary <string, ExpressionAnimation> > > dictionary,
            string propertyName,
            CompositionPropertyType type,
            out object value)
        {
            value = null;

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

            CompositionPropertySet propertySet = null;
            Dictionary <string, ExpressionAnimation> expressionAnimations = null;
            ExpressionAnimation expressionAnimation = null;
            string propertySetPropertyName          = null;

            GetExpressionAnimation <T>(
                source,
                propertyName,
                dictionary,
                out propertySet,
                out expressionAnimations,
                out expressionAnimation,
                out propertySetPropertyName);

            if (propertySet != null)
            {
                propertySet.StopAnimation(propertySetPropertyName);

                CompositionGetValueStatus status = CompositionGetValueStatus.TypeMismatch;

                switch (type)
                {
                case CompositionPropertyType.Boolean:
                    bool boolValue;
                    status = propertySet.TryGetBoolean(propertySetPropertyName, out boolValue);
                    value  = boolValue;
                    break;

                case CompositionPropertyType.Float:
                    float floatValue;
                    status = propertySet.TryGetScalar(propertySetPropertyName, out floatValue);
                    value  = floatValue;
                    break;

                case CompositionPropertyType.Vector2:
                    Vector2 vector2Value;
                    status = propertySet.TryGetVector2(propertySetPropertyName, out vector2Value);
                    value  = vector2Value;
                    break;

                case CompositionPropertyType.Vector3:
                    Vector3 vector3Value;
                    status = propertySet.TryGetVector3(propertySetPropertyName, out vector3Value);
                    value  = vector3Value;
                    break;
                    // Insert new case for any property type that is being added.
                }

                if (expressionAnimation != null)
                {
                    propertySet.StartAnimation(propertySetPropertyName, expressionAnimation);
                }

                return(status);
            }

            return(CompositionGetValueStatus.NotFound);
        }
 /// <summary>
 /// Stops any animations on the specified property.
 /// </summary>
 /// <param name="propertyName">The name of the property whose animations we are stopping.</param>
 public void StopAnimation(string propertyName)
 {
     _propertySet.StopAnimation(propertyName);
 }