Example #1
0
        /// <summary>
        /// Creates a new layout animation when an arrange pass starts.
        /// </summary>
        protected void BeginArrange()
        {
            if (_layoutAnimation != null)
            {
                if (_layoutAnimation.IsPlaying)
                {
                    _layoutAnimation.Stop(ProceduralAnimationStopState.Abort);
                }
                _layoutAnimation = null;
            }

            _useAnimation = UseAnimatedLayout;
            _animations   = new List <ProceduralAnimation>();

            if (_useAnimation)
            {
                if (_useDefaultInterpolation)
                {
                    _interpolation = EasingInterpolation.Default;
                }
                else
                {
                    _interpolation = Interpolation;
                    if (_interpolation.IsLinearInterpolation)
                    {
                        _interpolation = null;
                    }
                }
                _duration = Duration;
            }
        }
Example #2
0
        private void RemoveItem(object dataItem)
        {
            if (_itemsPresenter == null)
            {
                return;
            }

            ListViewItem item = GetItem(dataItem);

            if (item == null)
            {
                return;
            }

            _items.Remove(item);
            _itemMap.Remove(dataItem);

            Effect removedEffect = ItemRemovedEffect;

            if (removedEffect == null)
            {
                _itemsPresenter.Children.Remove(item);
            }
            else
            {
                removedEffect.Target = (FrameworkElement)item.Content;

                ProceduralAnimation removeAnimation = ((IProceduralAnimationFactory)removedEffect).CreateAnimation();
                removeAnimation.Stopped += OnItemRemovedAnimationStopped;

                removeAnimation.Play(item);
            }
        }
Example #3
0
        private void AddItem(object dataItem, int index)
        {
            if (_itemsPresenter == null)
            {
                return;
            }

            Style        itemContainerStyle = ItemContainerStyle;
            DataTemplate itemTemplate       = ItemTemplate;

            if (itemTemplate == null)
            {
                return;
            }

            ListViewItem item = CreateItem(dataItem, index, itemTemplate, itemContainerStyle);

            if (item != null)
            {
                _itemsPresenter.Children.Insert(index, item);

                Effect addedEffect = ItemAddedEffect;
                if (addedEffect != null)
                {
                    addedEffect.Target = (FrameworkElement)item.Content;

                    ProceduralAnimation addedAnimation = ((IProceduralAnimationFactory)addedEffect).CreateAnimation();
                    addedAnimation.Play(item);
                }
            }
        }
Example #4
0
        /// <internalonly />
        protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction)
        {
            if (_effects.Count == 0)
            {
                throw new InvalidOperationException("A CompositeEffect must have more than 1 nested child effect.");
            }

            if (_childrenInitialized == false)
            {
                foreach (Effect childEffect in _effects)
                {
                    ((IAttachedObject)childEffect).Attach(AssociatedObject);
                }

                _childrenInitialized = true;
            }

            List <ProceduralAnimation> animations = new List <ProceduralAnimation>(_effects.Count);

            foreach (Effect childEffect in _effects)
            {
                EffectDirection childDirection = direction;
                if (childEffect.AutoReverse)
                {
                    childDirection = EffectDirection.Forward;
                }

                ProceduralAnimation childAnimation = childEffect.CreateEffectAnimation(childDirection);
                if (childAnimation != null)
                {
                    animations.Add(childAnimation);
                }
            }

            if (animations.Count != 0)
            {
                ProceduralAnimation[] animationItems = animations.ToArray();

                if (_composition == EffectComposition.Parallel)
                {
                    ProceduralAnimationSet animation = new ProceduralAnimationSet(animationItems);
                    animation.AutoReverse = AutoReverse;

                    return(animation);
                }
                else
                {
                    ProceduralAnimationSequence animation = new ProceduralAnimationSequence(animationItems);
                    animation.AutoReverse = AutoReverse;

                    return(animation);
                }
            }

            return(null);
        }
Example #5
0
        /// <summary>
        /// Plays the current layout animation when an arrange pass is completed.
        /// </summary>
        protected void EndArrange()
        {
            if ((_animations != null) && (_animations.Count != 0))
            {
                _layoutAnimation = new ProceduralAnimationSet(_animations.ToArray());
                _layoutAnimation.Play(this);
            }

            _animations = null;
        }
Example #6
0
        private void OnItemRemovedAnimationStopped(object sender, EventArgs e)
        {
            if (_itemsPresenter == null)
            {
                return;
            }

            ProceduralAnimation animation = (ProceduralAnimation)sender;
            ListViewItem        item      = (ListViewItem)animation.AssociatedElement;

            _itemsPresenter.Children.Remove(item);
        }
Example #7
0
    void Start()
    {
        _nOfCoins              = 0;
        mySpeedKeyframes       = new Keyframe[0];
        myHeightKeyframes      = new Keyframe[0];
        editingIndex           = -1;
        firstClickInBoundaries = false;
        lastCurveEdited        = "";

        proceduralAnimation = GetComponentInChildren <ProceduralAnimation>();
        ShowCycle(proceduralAnimation.speedCurve, proceduralAnimation.heightCurve);
        //_rigibody = GetComponent<Rigidbody>();
        Cursor.lockState = CursorLockMode.Locked;
    }