zoukankan      html  css  js  c++  java
  • wpf 移动动画

    private void moveTo(Point deskPoint, Control ell, double space)
    
    //deskPoint: 控件要移动到的位置 , ell :你要移动的空间 , space : 设置移动的时间片(关系到控件移动的速度)
    
            {  
                Point curPoint = new Point();
                curPoint.X = Canvas.GetLeft(ell);
                curPoint.Y = Canvas.GetTop(ell);
    
    
                Storyboard storyboard = new Storyboard();   //创建Storyboard对象
    
                double lxspeed = space, lyspeed = space; //设置X方向 / Y方向 移动时间片
    
               //创建X轴方向动画 
    
                DoubleAnimation doubleAnimation = new DoubleAnimation( 
                  Canvas.GetLeft(ell), 
                  deskPoint.X, 
                  new Duration(TimeSpan.FromMilliseconds(lxspeed))
                );
                Storyboard.SetTarget(doubleAnimation, ell);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Left)"));
                storyboard.Children.Add(doubleAnimation);
    
    
                //创建Y轴方向动画 
    
    
                doubleAnimation = new DoubleAnimation(
                  Canvas.GetTop(ell),
                  deskPoint.Y,
                  new Duration(TimeSpan.FromMilliseconds(lyspeed))
                ); 
                Storyboard.SetTarget(doubleAnimation, ell);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Top)")); 
                storyboard.Children.Add(doubleAnimation); 
    
    
    
                //动画播放 
                storyboard.Begin(); 
            }

    【转】https://blog.csdn.net/chr23899/article/details/38853417

  • 相关阅读:
    C_数据结构_栈
    C_数据结构_链表
    C_数据结构_数组的修改和删除
    C_数据结构_数组
    Python_闭包_27
    Python_函数的镶嵌和作用域链_26
    P1428 小鱼比可爱
    P2915 [USACO08NOV]奶牛混合起来Mixed Up Cows
    P2946 [USACO09MAR]牛飞盘队Cow Frisbee Team
    codevs 2173 忠诚
  • 原文地址:https://www.cnblogs.com/lged/p/9501485.html
Copyright © 2011-2022 走看看