Sysnet.TouchScreen/Controls/TransitionHelper.cs

(完整代码) 2KB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace Sysnet.TouchScreen.Controls
{
    public class TransitionHelper
    {
        // Methods
        public static Storyboard BuildTranslateTransformTransition(UIElement element, Point newLocation, TimeSpan period, bool autoReverse)
        {
            Duration duration = new Duration(period);
            ElasticEase ease = new ElasticEase();
            ease.EasingMode = 0;
            ease.Oscillations = 2;
            ease.Springiness = 6.0;
            DoubleAnimation animation = new DoubleAnimation();
            animation.To = new double?(newLocation.X);
            animation.Duration = duration;
            animation.EasingFunction = ease;
            Storyboard.SetTarget(animation, element);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[2].(TranslateTransform.X)", new object[0]));
            DoubleAnimation animation2 = new DoubleAnimation();
            animation2.To = new double?(newLocation.Y);
            animation2.Duration = duration;
            animation2.EasingFunction = ease;
            Storyboard.SetTarget(animation2, element);
            Storyboard.SetTargetProperty(animation2, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[2].(TranslateTransform.Y)", new object[0]));
            Storyboard storyboard = new Storyboard();
            storyboard.AutoReverse = autoReverse;
            storyboard.Duration = duration;
            storyboard.Children.Add(animation);
            storyboard.Children.Add(animation2);
            return storyboard;
        }

        public static TransformGroup GetTransformGroupForXYOffset(double X, double Y, double scaleX, double scaleY)
        {
            TranslateTransform transform = new TranslateTransform();
            transform.X = X;
            transform.Y = Y;
            RotateTransform transform2 = new RotateTransform();
            transform2.Angle = 0.0;
            ScaleTransform transform3 = new ScaleTransform();
            transform3.ScaleX = scaleX;
            transform3.ScaleY = scaleY;
            TransformGroup group = new TransformGroup();
            group.Children.Add(transform3);
            group.Children.Add(transform2);
            group.Children.Add(transform);
            return group;
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。