public static EaseObject AnimateZProps(UIElement element,
                                        double rotationX, double rotationY, double rotationZ,
                                        double localOffsetX, double localOffsetY, double localOffsetZ,
                                        double globalOffsetX, double globalOffsetY, double globalOffsetZ,
                                        double centerOfRotationX, double centerOfRotationY, double centerOfRotationZ,
                                        double time, PercentHandler ease, double delay)
 {
     return(ArtefactAnimator.AddEase(element, UIElement.ProjectionProperty,
                                     new PlaneProjection
     {
         RotationX = rotationX,
         RotationY = rotationY,
         RotationZ = rotationZ,
         LocalOffsetX = localOffsetX,
         LocalOffsetY = localOffsetY,
         LocalOffsetZ = localOffsetZ,
         GlobalOffsetX = globalOffsetX,
         GlobalOffsetY = globalOffsetY,
         GlobalOffsetZ = globalOffsetZ,
         CenterOfRotationX = centerOfRotationX,
         CenterOfRotationY = centerOfRotationY,
         CenterOfRotationZ = centerOfRotationZ,
     },
                                     time, ease, delay));
 }
Ejemplo n.º 2
0
        public EaseObject(double time, PercentHandler ease, double delay)
        {
            // help with reporting
            EaseObjectIndex = ++EaseObjectCount;
            ++EaseObjectRunningCount;

            if (!double.IsNaN(time) && time > 0)
            {
                Time = time * 1000;
            }
            if (!double.IsNaN(delay) && delay > 0)
            {
                Delay = delay * 1000;
            }
            if (delay > 0 && ((flags & IS_DELAYED) != IS_DELAYED))
            {
                flags += IS_DELAYED;
            }
            Ease = ease;
        }
Ejemplo n.º 3
0
 public static EaseObject AddEase(object obj, object props, object endValues, double time, PercentHandler ease)
 {
     return(AddEase(obj, props, endValues, time, ease, 0));
 }
Ejemplo n.º 4
0
        public static EaseObject AddEase(object obj, object props, object endValues, double time, PercentHandler ease, double delay)
        {
            // throw exception here?
            if (obj == null)
            {
                return(null);
            }

            try
            {
                // construct ease object
                return(new EaseObject(time, ease, delay)
                {
                    Target = obj,
                    Props = ValidatePropsAndValue(obj, props, endValues)
                }.Start());
            }
            catch (Exception error)
            {
                Debug.WriteLine(string.Format("[ERROR] - {1} - AddEase({0})", obj, error), typeof(ArtefactAnimator).ToString());
                #if DEBUG
                throw;
                #endif
            }

            // return dummy EaseObject if failed to construct
            return(new EaseObject(time, ease, delay));
        }
Ejemplo n.º 5
0
        public EaseObject(double time, PercentHandler ease, double delay)
        {
            // help with reporting
            EaseObjectIndex = ++EaseObjectCount;
            ++EaseObjectRunningCount;

            if (!double.IsNaN(time) && time > 0) Time = time*1000;
            if (!double.IsNaN(delay) && delay > 0) Delay = delay*1000;
            if (delay > 0 && ((flags & IS_DELAYED) != IS_DELAYED)) flags += IS_DELAYED;
            Ease = ease;
        }
        void _KeyDown(object sender, KeyEventArgs e)
        {
            // REMOVE ALL EASING FOR ITEMS
            for (var i = 0; i < Items.Length; i++)
            {
                UIElement ball = Items[i];

                //// MOVEMENT

                if (e.Key == Key.R)
                {
                    double x = _rnd.NextDouble() * LayoutRoot.ActualWidth;
                    double y = _rnd.NextDouble() * LayoutRoot.ActualHeight;

                    double         delay = i * .02;
                    double         time  = .6;
                    PercentHandler ease  = AnimationTransitions.CubicEaseOut;

                    ball.SlideTo(x, y, time, ease, delay);
                }

                //// EFFECTS

                else if (e.Key == Key.D)
                {
                    var effect = (DropShadowEffect)ball.Effect;
                    if (effect == null)
                    {
                        effect      = new DropShadowEffect();
                        ball.Effect = effect;
                    }
                    DropShadowEffect effectClone = effect.Copy();
                    effectClone.BlurRadius  = _rnd.NextDouble() * 20;
                    effectClone.Opacity     = .7 + (_rnd.NextDouble() * .3);
                    effectClone.ShadowDepth = _rnd.NextDouble() * 20;

                    ArtefactAnimator.AddEase(ball, UIElement.EffectProperty, effectClone, 2, AnimationTransitions.CubicEaseOut, 0);
                }
                else if (e.Key == Key.C)
                {
                    var effect = (DropShadowEffect)Items[i].Effect;
                    if (effect == null)
                    {
                        continue;
                    }

                    ArtefactAnimator.AddEase(effect, DropShadowEffect.ColorProperty, new Color()
                    {
                        A = 1,
                        R = (byte)(_rnd.NextDouble() * 255),
                        G = (byte)(_rnd.NextDouble() * 255),
                        B = (byte)(_rnd.NextDouble() * 255)
                    }
                                             , 1, AnimationTransitions.CubicEaseOut, 0);
                }

                //// REMOVE EFFECT

                else if (e.Key == Key.X)
                {
                    Items[i].Effect = null;
                }
            }
        }
        void _KeyDown(object sender, KeyEventArgs e)
        {
            // REMOVE ALL EASING FOR ITEMS
            for (var i = 0; i < Items.Length; i++)
            {
                UIElement ball = Items[i];

                //// MOVEMENT

                if (e.Key == Key.R)
                {
                    double x = _rnd.NextDouble() * LayoutRoot.ActualWidth;
                    double y = _rnd.NextDouble() * LayoutRoot.ActualHeight;

                    double         delay = i * .02;
                    double         time  = .6;
                    PercentHandler ease  = AnimationTransitions.CubicEaseOut;

                    ball.SlideTo(x, y, time, ease, delay);
                }

                //// EFFECTS

                else if (e.Key == Key.D)
                {
                    var effect = (DropShadowEffect)ball.Effect;
                    if (effect == null)
                    {
                        effect      = new DropShadowEffect();
                        ball.Effect = effect;
                    }
                    DropShadowEffect effectClone = effect.Copy();
                    effectClone.BlurRadius  = _rnd.NextDouble() * 20;
                    effectClone.Opacity     = .7 + (_rnd.NextDouble() * .3);
                    effectClone.ShadowDepth = _rnd.NextDouble() * 20;

                    ArtefactAnimator.AddEase(ball, UIElement.EffectProperty, effectClone, .8, AnimationTransitions.CubicEaseOut, 0);
                }
                else if (e.Key == Key.C)
                {
                    var effect = (DropShadowEffect)ball.Effect;
                    if (effect == null)
                    {
                        continue;
                    }
                    ArtefactAnimator.AddEase(effect, DropShadowEffect.ColorProperty, new Color()
                    {
                        A = 1,
                        R = (byte)(_rnd.NextDouble() * 255),
                        G = (byte)(_rnd.NextDouble() * 255),
                        B = (byte)(_rnd.NextDouble() * 255)
                    }
                                             , 1, AnimationTransitions.CubicEaseOut, 0);
                }

                //// REMOVE EFFECT

                else if (e.Key == Key.X)
                {
                    ball.Effect = null;
                }

                //// 3D

                else if (e.Key == Key.Z)
                {
                    Canvas.SetLeft(ball, Canvas.GetLeft(ball) + 2);

                    var pp = (PlaneProjection)ball.Projection ??
                             new PlaneProjection {
                        RotationX = 0D, RotationY = 0D, RotationZ = 0D
                    };

                    ball.Projection = pp;

                    EaseObject easeObject = ArtefactAnimator.AddEase(pp,
                                                                     new [] {
                        Animation3DEffects.RotationX,
                        Animation3DEffects.RotationY,
                        Animation3DEffects.RotationZ
                    },
                                                                     new [] {
                        RandomDouble(-75, 75),
                        RandomDouble(-75, 75),
                        RandomDouble(-75, 75)
                    },
                                                                     2, AnimationTransitions.ElasticEaseOut, 0);

                    easeObject.Update += (eo, per) =>
                    {
                        (eo.Data as UIElement).Projection = eo.Target as PlaneProjection;
                    };
                    easeObject.Data = ball;
                }
            }
        }
Ejemplo n.º 8
0
 public static EaseObject AddEase(object obj, object props, object endValues, double time, PercentHandler ease)
 {
     return AddEase(obj, props, endValues, time, ease, 0);
 }
 public static EaseObject XTo(this UIElement obj, double X, double time, PercentHandler transition, double delay)
 {
     return(ArtefactAnimator.AddEase(obj, AnimationTypes.X, X, time, transition, delay));
 }
Ejemplo n.º 10
0
        public static EaseObject AddEase(object obj, object props, object endValues, double time, PercentHandler ease, double delay)
        {
            // throw exception here?
            if (obj == null) return null;

            try
            {
                // construct ease object
                return new EaseObject(time, ease, delay)
                {
                    Target = obj,
                    Props = ValidatePropsAndValue(obj, props, endValues)
                }.Start();
            }
            catch (Exception error)
            {
                Debug.WriteLine(string.Format("[ERROR] - {1} - AddEase({0})", obj, error), typeof(ArtefactAnimator).ToString());
            }

            // return dummy EaseObject if failed to construct
            return new EaseObject(time, ease, delay);
        }
 public static EaseObject AutoAlphaCollapsedTo(this UIElement obj, double alpha, double time, PercentHandler transition, double delay)
 {
     ArtefactAnimator.StopEase(obj, new string[] { AnimationTypes.Alpha, AnimationTypes.AutoAlpha, AnimationTypes.AutoAlphaCollapsed });
     return(ArtefactAnimator.AddEase(obj, AnimationTypes.AutoAlphaCollapsed, alpha, time, transition, delay));
 }
 public static EaseObject OffsetTo(this UIElement obj, double offsetX, double offsetY, double time, PercentHandler transition, double delay)
 {
     try
     {
         return(ArtefactAnimator.AddEase(((TransformGroup)obj.RenderTransform).Children[(int)TransformGroupIndexes.TranslateTransform], new object[] { AnimationTypes.OffsetX, AnimationTypes.OffsetY }, new object[] { offsetX, offsetY }, time, transition, delay));
     }
     catch (Exception error) { Debug.WriteLine("[ERROR] ArtefactAnimatorExtensions - OffsetTo - " + error); return(null); }
 }
 public static EaseObject DimensionsTo(this UIElement obj, double width, double height, double time, PercentHandler transition, double delay)
 {
     return(ArtefactAnimator.AddEase(obj, new[] { AnimationTypes.Width, AnimationTypes.Height }, new object[] { width, height }, time, transition, delay));
 }
 public static EaseObject SlideTo(this UIElement obj, double x, double y, double time, PercentHandler transition, double delay)
 {
     return(ArtefactAnimator.AddEase(obj, new[] { AnimationTypes.X, AnimationTypes.Y }, new object[] { x, y }, time, transition, delay));
 }
Ejemplo n.º 15
0
 public EaseObject AnimateBlendTo(double opacity, double seconds, PercentHandler ease)
 {
     return(ArtefactAnimator.AddEase(this, new[] { "Opacity" }, new object[] { opacity }, seconds, ease));
 }