Example #1
0
        public static int calcAnimateYTime(FrameworkElement item, double destPosition, double ratio)
        {
            double translateY = TransformUtil.getTranslateY(item);
            int    num        = 100;

            return((int)(50.0 * Math.Abs(destPosition - translateY) / (double)num * ratio));
        }
Example #2
0
        public static void addTranslateDelta(FrameworkElement item, double xDelta, double yDelta)
        {
            TransformUtil.addCompositeTransform(item);
            CompositeTransform compositeTransform = (CompositeTransform)item.RenderTransform;

            compositeTransform.TranslateX += xDelta;
            compositeTransform.TranslateY += yDelta;
        }
Example #3
0
 public static void setTranslateY(FrameworkElement item, double value)
 {
     if (Double.IsInfinity(value))
     {
         return;
     }
     TransformUtil.addCompositeTransform(item);
     ((CompositeTransform)item.RenderTransform).TranslateY = value;
 }
        public static void zoom(FrameworkElement item, double to, int msec, Action <object, EventArgs> callback)
        {
            double          globalOffsetZ    = TransformUtil.GetGlobalOffsetZ(item);
            Storyboard      storyboard       = new Storyboard();
            DoubleAnimation doubleAnimation1 = new DoubleAnimation();

            doubleAnimation1.From     = new double?(globalOffsetZ);
            doubleAnimation1.To       = new double?(to);
            doubleAnimation1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, msec));
            DoubleAnimation doubleAnimation2 = doubleAnimation1;

            Storyboard.SetTarget((Timeline)doubleAnimation2, (DependencyObject)item);
            Storyboard.SetTargetProperty((Timeline)doubleAnimation2, new PropertyPath("(UIElement.Projection).(PlaneProjection.GlobalOffsetZ)", new object[0]));
            storyboard.Children.Add((Timeline)doubleAnimation2);
            if (callback != null)
            {
                storyboard.Completed += new EventHandler(callback.Invoke);
            }
            storyboard.Begin();
        }
        public static void translateY(FrameworkElement item, double toY, int msec, Action <object, EventArgs> callback)
        {
            double          translateY       = TransformUtil.getTranslateY(item);
            Storyboard      storyboard       = new Storyboard();
            DoubleAnimation doubleAnimation1 = new DoubleAnimation();

            doubleAnimation1.From     = new double?(translateY);
            doubleAnimation1.To       = new double?(toY);
            doubleAnimation1.Duration = new Duration(new TimeSpan(0, 0, 0, 0, msec));
            DoubleAnimation doubleAnimation2 = doubleAnimation1;

            Storyboard.SetTarget((Timeline)doubleAnimation2, (DependencyObject)item);
            Storyboard.SetTargetProperty((Timeline)doubleAnimation2, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)", new object[0]));
            storyboard.Children.Add((Timeline)doubleAnimation2);
            if (callback != null)
            {
                storyboard.Completed += new EventHandler(callback.Invoke);
            }
            storyboard.Begin();
        }
        public static void bounce(FrameworkElement item, double height, int msec, Action <object, EventArgs> callback)
        {
            double     translateY = TransformUtil.getTranslateY(item);
            Storyboard storyboard = new Storyboard();
            DoubleAnimationUsingKeyFrames animationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
            EasingDoubleKeyFrame          easingDoubleKeyFrame1   = new EasingDoubleKeyFrame();

            easingDoubleKeyFrame1.KeyTime = (KeyTime) new TimeSpan(0, 0, 0, 0, (int)((double)msec * 0.5));
            easingDoubleKeyFrame1.Value   = translateY - height;
            animationUsingKeyFrames.KeyFrames.Add((DoubleKeyFrame)easingDoubleKeyFrame1);
            EasingDoubleKeyFrame easingDoubleKeyFrame2 = new EasingDoubleKeyFrame();

            easingDoubleKeyFrame2.KeyTime = (KeyTime) new TimeSpan(0, 0, 0, 0, msec);
            easingDoubleKeyFrame2.Value   = translateY;
            animationUsingKeyFrames.KeyFrames.Add((DoubleKeyFrame)easingDoubleKeyFrame2);
            Storyboard.SetTarget((Timeline)animationUsingKeyFrames, (DependencyObject)item);
            Storyboard.SetTargetProperty((Timeline)animationUsingKeyFrames, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)", new object[0]));
            storyboard.Children.Add((Timeline)animationUsingKeyFrames);
            if (callback != null)
            {
                storyboard.Completed += new EventHandler(callback.Invoke);
            }
            storyboard.Begin();
        }
Example #7
0
 public static double getTranslateY(FrameworkElement item)
 {
     TransformUtil.addCompositeTransform(item);
     return(((CompositeTransform)item.RenderTransform).TranslateY);
 }
Example #8
0
 public static void setRotateY(FrameworkElement item, double value)
 {
     TransformUtil.addPlaneProjection(item);
     ((PlaneProjection)item.Projection).RotationY = value;
 }
Example #9
0
 public static double getRotateY(FrameworkElement item)
 {
     TransformUtil.addPlaneProjection(item);
     return(((PlaneProjection)item.Projection).RotationY);
 }