Пример #1
0
        public void Bind(IAnimable owner)
        {
            Owner = owner;
            var p = AnimationUtils.GetProperty(owner.GetType(), TargetProperty);

            IsTriggerable = p.Triggerable;
            var mi = p.Info.GetSetMethod();

            if (mi == null)
            {
                throw new Lime.Exception("Property '{0}' (class '{1}') is readonly", TargetProperty, owner.GetType());
            }
            Setter = (SetterDelegate)Delegate.CreateDelegate(typeof(SetterDelegate), owner, mi);
        }
Пример #2
0
        public static void SetAnimatorAndInitialKeyframeIfNeed(IAnimable animable, params string[] properties)
        {
            var frame = Document.Current.AnimationFrame;

            Document.Current.AnimationFrame = 0;
            IAnimator animator;

            foreach (var propName in properties)
            {
                if (!animable.Animators.TryFind(propName, out animator, Document.Current.AnimationId))
                {
                    var propValue = animable.GetType().GetProperty(propName).GetValue(animable);
                    SetProperty.Perform(animable, propName, propValue);
                    var type = animable.GetType().GetProperty(propName).PropertyType;
                    animator = AnimatorRegistry.Instance.CreateAnimator(type);
                    animator.TargetProperty = propName;
                    animator.AnimationId    = Document.Current.AnimationId;
                    SetAnimator.Perform(animable, animator);
                    SetAnimableProperty.Perform(animable, propName, propValue);
                }
            }
            Document.Current.AnimationFrame = frame;
        }