예제 #1
0
        public IAnimator this[string propertyPath, string animationId = null]
        {
            get
            {
                IAnimator animator;
                if (TryFind(propertyPath, out animator, animationId))
                {
                    return(animator);
                }
                var(p, _, _) = AnimationUtils.GetPropertyByPath(owner, propertyPath);
                var pi = p.Info;
                if (pi == null)
                {
                    throw new Lime.Exception("Unknown property {0} in {1}", propertyPath, owner.GetType().Name);
                }
                animator = AnimatorRegistry.Instance.CreateAnimator(pi.PropertyType);
                animator.TargetPropertyPath = propertyPath;
                animator.AnimationId        = animationId;
                Add(animator);
#if TANGERINE
                Version++;
#endif // TANGERINE
                owner.OnAnimatorCollectionChanged();
                return(animator);
            }
        }
예제 #2
0
파일: Animator.cs 프로젝트: aologos/Citrus
        private void Bind()
        {
            var(p, animable, index) = AnimationUtils.GetPropertyByPath(Owner, TargetPropertyPath);
            var mi = p.Info?.GetSetMethod();

            IsZombie = animable == null || mi == null || p.Info.PropertyType != typeof(T) || animable is IList list && index >= list.Count;
            if (IsZombie)
            {
                return;
            }
            Animable      = animable;
            IsTriggerable = p.Triggerable;
            if (index == -1)
            {
                setter = (SetterDelegate)Delegate.CreateDelegate(typeof(SetterDelegate), animable, mi);
            }
            else
            {
                var indexedSetter = (IndexedSetterDelegate)Delegate.CreateDelegate(typeof(IndexedSetterDelegate), animable, mi);
                setter = (v) => {
                    indexedSetter(index, v);
                };
            }
        }