Beispiel #1
0
        public GPUFloatValueAnimator(float from, float to, IEnumerable <IBindingItem> bindingPath)
        {
            _to          = to;
            _from        = from;
            _bindingPath = bindingPath;

            _valueAnimator         = new FloatValueAnimator(from, to);
            _valueAnimator.Update += OnInnerAnimatorUpdate;

            _coreAnimation = null;
        }
Beispiel #2
0
        private void InitializeCoreAnimation()
        {
            var animatedItem = _bindingPath.LastOrDefault();

            var view = animatedItem.DataContext as UIView;

            #region PickAnimation
            // If we animate the opacity
            if (view != null && animatedItem.PropertyName.EndsWith("Opacity"))
            {
                _coreAnimation = InitializeOpacityCoreAnimation(view);
                return;
            }

            var dataContextType = animatedItem.DataContext.GetType();

            // If we animate a Transform
            if (dataContextType == typeof(TranslateTransform))
            {
                _coreAnimation = InitializeTranslateCoreAnimation(animatedItem);
                return;
            }

            if (dataContextType == typeof(RotateTransform))
            {
                _coreAnimation = InitializeRotateCoreAnimation(animatedItem);
                return;
            }

            if (dataContextType == typeof(ScaleTransform))
            {
                _coreAnimation = InitializeScaleCoreAnimation(animatedItem);
                return;
            }

            if (dataContextType == typeof(SkewTransform))
            {
                _coreAnimation = InitializeSkewCoreAnimation(animatedItem);
                return;
            }

            if (dataContextType == typeof(CompositeTransform))
            {
                _coreAnimation = InitializeCompositeCoreAnimation(animatedItem);
                return;
            }

            throw new NotSupportedException(__notSupportedProperty);
            #endregion
        }
Beispiel #3
0
        public void Dispose()
        {
            if (!_isDisposed)
            {
                _bindingPath = null;

                _valueAnimator.Dispose();
                _valueAnimator = null;

                _coreAnimation?.Dispose();
                _coreAnimation = null;

                this.Update          = null;
                this.AnimationEnd    = null;
                this.AnimationCancel = null;
            }

            _isDisposed = true;
        }
Beispiel #4
0
        private void InitializeCoreAnimation()
        {
            var animatedItem = _bindingPath.LastOrDefault();

            switch (animatedItem.DataContext)
            {
            case _View view when animatedItem.PropertyName.EndsWith("Opacity"):
                _coreAnimation = InitializeOpacityCoreAnimation(view);

                return;

            case TranslateTransform translate:
                _coreAnimation = InitializeTranslateCoreAnimation(translate, animatedItem);
                return;

            case RotateTransform rotate:
                _coreAnimation = InitializeRotateCoreAnimation(rotate, animatedItem);
                return;

            case ScaleTransform scale:
                _coreAnimation = InitializeScaleCoreAnimation(scale, animatedItem);
                return;

            case SkewTransform skew:
                _coreAnimation = InitializeSkewCoreAnimation(skew, animatedItem);
                return;

            case CompositeTransform composite:
                _coreAnimation = InitializeCompositeCoreAnimation(composite, animatedItem);
                return;

            // case TransformGroup group:
            //  ==> No needs to validate the TransformGroup: there is no animatable property on it.
            //		If a anmiation is declared on it (e.g. "(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"),
            //		the _bindingPath should resolve the target child Transform, and animatedItem.DataContext should be the ScaleTransform.


            default:
                throw new NotSupportedException(__notSupportedProperty);
            }
        }
Beispiel #5
0
 private void ReleaseCoreAnimation()
 {
     _coreAnimation?.Dispose();
     _coreAnimation = null;
 }