示例#1
0
 //动画
 public static void DoMove(Animatable uie, DependencyProperty dp, double to, double ar, double dr, double duration)
 {
     var doubleAnimation = new DoubleAnimation
         {
             To = to,
             Duration = TimeSpan.FromSeconds(duration),
             AccelerationRatio = ar,
             DecelerationRatio = dr,
             FillBehavior = FillBehavior.HoldEnd
         };//创建双精度动画对象
     uie.BeginAnimation(dp, doubleAnimation);//设置动画应用的属性并启动动画
 }
示例#2
0
 /// <summary>
 /// The animate opacity.
 /// </summary>
 /// <param name="obj">
 /// The obj.
 /// </param>
 /// <param name="toOpacity">
 /// The to opacity.
 /// </param>
 /// <param name="animationTime">
 /// The animation time.
 /// </param>
 private void AnimateOpacity(Animatable obj, double toOpacity, double animationTime)
 {
     var animation = new DoubleAnimation(toOpacity, new Duration(TimeSpan.FromMilliseconds(animationTime)))
         {
             AccelerationRatio = 0.3,
             DecelerationRatio = 0.5
         };
     animation.Completed += this.AnimationCompleted;
     obj.BeginAnimation(UIElement.OpacityProperty, animation);
 }
		static void Animate(Animatable element, DependencyProperty property, double to)
		{
			element.BeginAnimation(property, new DoubleAnimation(to, new Duration(animationTime), FillBehavior.HoldEnd),
			                       HandoffBehavior.SnapshotAndReplace);
		}
        /*private void face_MouseLeave(object sender, MouseEventArgs e)
        {
                        var el = (ModelUIElement3D) sender;
                        var model = el.Model as GeometryModel3D;
                        var mg = model.Material as MaterialGroup;
                        var dm = mg.Children[0] as DiffuseMaterial;
                        AnimateOpacity(dm.Brush, 0.8, 200);
        }

        private void face_MouseEnter(object sender, MouseEventArgs e)
        {
            var el = (ModelUIElement3D) sender;
                var model = el.Model as GeometryModel3D;
                var mg=model.Material as MaterialGroup;
                var dm=mg.Children[0] as DiffuseMaterial;
                AnimateOpacity(dm.Brush, 1.0, 200);
        }*/


        private void AnimateOpacity(Animatable obj, double toOpacity, double animationTime)
        {
            var a = new DoubleAnimation(toOpacity,
                                        new Duration(TimeSpan.FromMilliseconds(animationTime))) { AccelerationRatio = 0.3, DecelerationRatio = 0.5 };
            a.Completed += new EventHandler(a_Completed);
            obj.BeginAnimation(UIElement.OpacityProperty, a);
        }