zoukankan      html  css  js  c++  java
  • winrt 页面进入动画

    private async void DoAnimistion()
    {
    Storyboard storyboard = new Storyboard(); using (IEnumerator<DependencyObject> enumerator = stack.Children.ToList().GetEnumerator())       //此处的stack是一个StackPanel,我要对它的子元素做动画
    { Random random
    = new Random(); TimeSpan time = TimeSpan.FromSeconds(0.0); var ts = TimeSpan.FromMilliseconds(80.0); double angle = -120.0; while (enumerator.MoveNext()) { //double num = random.Next(200, 500); FrameworkElement frameworkElement = (FrameworkElement)enumerator.Current; DoubleAnimationUsingKeyFrames xdoubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames(); xdoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time), 380)); xdoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time.Add(TimeSpan.FromSeconds(0.3))), 0)); Storyboard.SetTarget(xdoubleAnimationUsingKeyFrames, frameworkElement); Storyboard.SetTargetName(xdoubleAnimationUsingKeyFrames, frameworkElement.Name); Storyboard.SetTargetProperty(xdoubleAnimationUsingKeyFrames, TargetProperty.RenderTransformTranslateX); storyboard.Children.Add(xdoubleAnimationUsingKeyFrames); DoubleAnimationUsingKeyFrames ydoubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames(); ydoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time), angle)); ydoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time.Add(TimeSpan.FromSeconds(0.3))), 0)); Storyboard.SetTarget(ydoubleAnimationUsingKeyFrames, frameworkElement); Storyboard.SetTargetName(ydoubleAnimationUsingKeyFrames, frameworkElement.Name); Storyboard.SetTargetProperty(ydoubleAnimationUsingKeyFrames, TargetProperty.ProjectionRotationY); storyboard.Children.Add(ydoubleAnimationUsingKeyFrames); var num3 = -1.0 * (Math.Tan(DegreesToRadians(angle)) * frameworkElement.ActualWidth); num3 += frameworkElement.ActualWidth; DoubleAnimationUsingKeyFrames zdoubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames(); zdoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time), num3)); zdoubleAnimationUsingKeyFrames.KeyFrames.Add(CreateKeyFrame(KeyTime.FromTimeSpan(time.Add(TimeSpan.FromSeconds(0.3))), 0)); Storyboard.SetTarget(zdoubleAnimationUsingKeyFrames, frameworkElement); Storyboard.SetTargetName(zdoubleAnimationUsingKeyFrames, frameworkElement.Name); Storyboard.SetTargetProperty(zdoubleAnimationUsingKeyFrames, TargetProperty.ProjectionGlobalOffsetZ); storyboard.Children.Add(zdoubleAnimationUsingKeyFrames); time = time.Add(ts); } } storyboard.Begin();
    }
    public static double DegreesToRadians(double degrees)
            {
                return degrees * 2.0 * 3.1415926535897931 / 360.0;
            }
  • 相关阅读:
    微信小程序 添加卡券至微信卡券
    微信小程序 引入第三方字体
    小程序 生成条形码barcode.js
    Pycharm编辑器功能之自动导入模块
    Cannot open include file: 'libxml/xpath.h': No such file or directory
    怎么在32位windows系统上搭建爬虫框架scrapy?
    python2.7安装Twisted报Microsoft Visual C++9.0 required
    在windows下搭建爬虫框架,安装pywin32时出错?
    python如何通过pymongo连接到mongodb?
    python2.7.12自带pip吗?
  • 原文地址:https://www.cnblogs.com/wangjinming/p/3778002.html
Copyright © 2011-2022 走看看