Example #1
0
        protected virtual void InvokeAnimationCompleted()
        {
            EndEvent handler = OnAnimationCompleted;

            if (handler != null)
            {
                OnAnimationCompleted.Invoke();
            }
        }
Example #2
0
    public void SubscribeToAnimationEvent(string animationName, float animationTime, OnAnimationCompleted completionEvent)
    {
        AnimationSubscription sub = new AnimationSubscription(
            animationName,
            animationTime,
            completionEvent
            );

        animationSubscriptions.Add(sub);
    }
Example #3
0
        internal override void Apply(IterationParameters parameters, bool isLastLoop)
        {
            if (To != null)
            {
                // - Get the propertyMetadata from the property
                PropertyMetadata propertyMetadata = _propDp.GetTypeMetaData(_propertyContainer.GetType());

                //we make a specific name for this animation:
                string specificGroupName = parameters.VisualStateGroupName + animationInstanceSpecificName.ToString();

                _animationID = Guid.NewGuid();

                bool cssEquivalentExists = false;
                if (propertyMetadata.GetCSSEquivalent != null)
                {
                    CSSEquivalent cssEquivalent = propertyMetadata.GetCSSEquivalent(_propertyContainer);
                    if (cssEquivalent != null)
                    {
                        cssEquivalentExists = true;
                        StartAnimation(_propertyContainer, cssEquivalent, From, To, Duration, (EasingFunctionBase)EasingFunction, specificGroupName,
                                       OnAnimationCompleted(parameters, isLastLoop, To.Value, _propertyContainer, _targetProperty, _animationID));
                    }
                }
                //todo: use GetCSSEquivalent instead (?)
                if (propertyMetadata.GetCSSEquivalents != null)
                {
                    List <CSSEquivalent> cssEquivalents = propertyMetadata.GetCSSEquivalents(_propertyContainer);
                    foreach (CSSEquivalent equivalent in cssEquivalents)
                    {
                        cssEquivalentExists = true;
                        StartAnimation(_propertyContainer, equivalent, From, To, Duration, (EasingFunctionBase)EasingFunction, specificGroupName,
                                       OnAnimationCompleted(parameters, isLastLoop, To.Value, _propertyContainer, _targetProperty, _animationID));
                    }
                }

                if (!cssEquivalentExists)
                {
                    OnAnimationCompleted(parameters, isLastLoop, To.Value, _propertyContainer, _targetProperty, _animationID)();
                }
            }
        }
Example #4
0
        internal override void Apply(IterationParameters parameters, bool isLastLoop)
        {
            if (To != null)
            {
                var castedValue = DynamicCast(To, _propDp.PropertyType); //Note: we put this line here because the Xaml could use a Color gotten from a StaticResource (which was therefore not converted to a SolidColorbrush by the compiler in the .g.cs file) and led to a wrong type set in a property (Color value in a property of type Brush).

                // - Get the propertyMetadata from the property
                PropertyMetadata propertyMetadata = _propDp.GetTypeMetaData(_propertyContainer.GetType());
                // - Get the cssPropertyName from the PropertyMetadata

                //we make a specific name for this animation:
                string specificGroupName = parameters.VisualStateGroupName + animationInstanceSpecificName.ToString();

                bool cssEquivalentExists = false;
                if (propertyMetadata.GetCSSEquivalent != null)
                {
                    CSSEquivalent cssEquivalent = propertyMetadata.GetCSSEquivalent(_propertyContainer);
                    if (cssEquivalent != null)
                    {
                        cssEquivalentExists = true;
                        TryStartAnimation(_propertyContainer, cssEquivalent, From, To, Duration, EasingFunction, specificGroupName,
                                          OnAnimationCompleted(parameters, isLastLoop, castedValue, _propertyContainer, _targetProperty, _animationID));
                    }
                }
                if (propertyMetadata.GetCSSEquivalents != null)
                {
                    List <CSSEquivalent> cssEquivalents = propertyMetadata.GetCSSEquivalents(_propertyContainer);
                    bool isFirst = true;
                    foreach (CSSEquivalent equivalent in cssEquivalents)
                    {
                        cssEquivalentExists = true;
                        if (equivalent.CallbackMethod == null)
                        {
                            if (isFirst)
                            {
                                bool updateIsFirst = TryStartAnimation(_propertyContainer, equivalent, From, To, Duration, EasingFunction, specificGroupName,
                                                                       OnAnimationCompleted(parameters, isLastLoop, castedValue, _propertyContainer, _targetProperty, _animationID));
                                if (updateIsFirst)
                                {
                                    isFirst = false;
                                }
                            }
                            else
                            {
                                TryStartAnimation(_propertyContainer, equivalent, From, To, Duration, EasingFunction, specificGroupName,
                                                  OnAnimationCompleted(parameters, isLastLoop, castedValue, _propertyContainer, _targetProperty, _animationID));
                            }
                        }
                        else
                        {
                            OnAnimationCompleted(parameters, isLastLoop, castedValue, _propertyContainer, _targetProperty, _animationID)();
                        }
                    }
                }
                if (!cssEquivalentExists)
                {
                    OnAnimationCompleted(parameters, isLastLoop, castedValue, _propertyContainer, _targetProperty, _animationID)();
                }
            }
            else
            {
                OnAnimationCompleted(parameters, isLastLoop, To, _propertyContainer, _targetProperty, _animationID)();
            }
        }
Example #5
0
 public AnimationSubscription(string animationName, float animationTime, OnAnimationCompleted animationCompletedEvent)
 {
     this.animationName           = animationName;
     this.animationTime           = animationTime;
     this.animationCompletedEvent = animationCompletedEvent;
 }
Example #6
0
    public void UnsubscribeFromAnimationEvent(string animationName, float animationTime, OnAnimationCompleted completionEvent)
    {
        AnimationSubscription sub = null;

        for (int i = 0; i < animationSubscriptions.Count; i++)
        {
            sub = animationSubscriptions[i];

            if (sub.animationName == animationName &&
                sub.animationTime == animationTime &&
                sub.animationCompletedEvent == completionEvent)
            {
                animationSubscriptions.RemoveAt(i);
                i--;
            }
        }
    }