当前位置: 首页>>代码示例>>C#>>正文


C# this.BeginAnimation方法代码示例

本文整理汇总了C#中this.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# this.BeginAnimation方法的具体用法?C# this.BeginAnimation怎么用?C# this.BeginAnimation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.BeginAnimation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AnimateImageSourceChange

        public static void AnimateImageSourceChange(this Image image, ImageSource bitmap, Action<Image> onShowImage, AnimateImageChangeParams animateImageChangeParams = null)
        {
            var animationParameters = animateImageChangeParams ?? new AnimateImageChangeParams();
            var fadeInAnimation = new DoubleAnimation(animationParameters.TargetOpacity, animationParameters.FadeTime);

            if (image.Source != null)
            {
                var fadeOutAnimation = new DoubleAnimation(0d, animationParameters.FadeTime);

                fadeOutAnimation.Completed += (o, e) =>
                {
                    image.Source = bitmap;
                    onShowImage(image);
                    image.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation);
                };

                image.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation);
            }
            else
            {
                image.Opacity = 0d;
                image.Source = bitmap;
                onShowImage(image);
                image.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation);
            }
        }
开发者ID:liange,项目名称:ClaudiaIDE,代码行数:26,代码来源:ImageSourceAnimator.cs

示例2: AnimateTo

        /// <summary>
        /// Animates the camera position and directions.
        /// </summary>
        /// <param name="camera">
        /// The camera to animate.
        /// </param>
        /// <param name="newPosition">
        /// The position to animate to.
        /// </param>
        /// <param name="newDirection">
        /// The direction to animate to.
        /// </param>
        /// <param name="newUpDirection">
        /// The up direction to animate to.
        /// </param>
        /// <param name="animationTime">
        /// Animation time in milliseconds.
        /// </param>
        public static void AnimateTo(
            this Camera camera,
            Point3D newPosition,
            Vector3D newDirection,
            Vector3D newUpDirection,
            double animationTime)
        {
            var projectionCamera = camera as ProjectionCamera;
            if (projectionCamera == null)
            {
                return;
            }

            var fromPosition = projectionCamera.Position;
            var fromDirection = projectionCamera.LookDirection;
            var fromUpDirection = projectionCamera.UpDirection;

            projectionCamera.Position = newPosition;
            projectionCamera.LookDirection = newDirection;
            projectionCamera.UpDirection = newUpDirection;

            if (animationTime > 0)
            {
                var a1 = new Point3DAnimation(
                    fromPosition, newPosition, new Duration(TimeSpan.FromMilliseconds(animationTime)))
                    {
                        AccelerationRatio = 0.3,
                        DecelerationRatio = 0.5,
                        FillBehavior = FillBehavior.Stop
                    };

                a1.Completed += (s, a) => { camera.BeginAnimation(ProjectionCamera.PositionProperty, null); };
                camera.BeginAnimation(ProjectionCamera.PositionProperty, a1);

                var a2 = new Vector3DAnimation(
                    fromDirection, newDirection, new Duration(TimeSpan.FromMilliseconds(animationTime)))
                    {
                        AccelerationRatio = 0.3,
                        DecelerationRatio = 0.5,
                        FillBehavior = FillBehavior.Stop
                    };
                a2.Completed += (s, a) => { camera.BeginAnimation(ProjectionCamera.LookDirectionProperty, null); };
                camera.BeginAnimation(ProjectionCamera.LookDirectionProperty, a2);

                var a3 = new Vector3DAnimation(
                    fromUpDirection, newUpDirection, new Duration(TimeSpan.FromMilliseconds(animationTime)))
                    {
                        AccelerationRatio = 0.3,
                        DecelerationRatio = 0.5,
                        FillBehavior = FillBehavior.Stop
                    };
                a3.Completed += (s, a) => { camera.BeginAnimation(ProjectionCamera.UpDirectionProperty, null); };
                camera.BeginAnimation(ProjectionCamera.UpDirectionProperty, a3);
            }
        }
开发者ID:dermeister0,项目名称:helix-toolkit,代码行数:73,代码来源:CameraExtensions.cs

示例3: animateHeight

 public static void animateHeight(this UIElement element, DependencyProperty prop, double height, int mode)
 {           
     double newHeight;
     ElasticEase cc = new ElasticEase();
     if (mode == 1)
     {
         newHeight = 260;
     }
     else if(mode == 2)
     {
         newHeight = 520;
     }
     else
     {
         newHeight = 0;
     }
     if(height != newHeight)
     {
         DoubleAnimation op = new DoubleAnimation(height, newHeight, program.tSpan);
         
         cc.Springiness = 5;
         cc.Oscillations = 1;
         op.EasingFunction = cc;
         cc.EasingMode = EasingMode.EaseInOut;
         element.BeginAnimation(prop, op);
     }
     
 }
开发者ID:TomasFilingr,项目名称:CManager,代码行数:28,代码来源:blur.cs

示例4: AnimateEase

		public static void AnimateEase(this Animatable obj, DependencyProperty property, double fromValue, double toValue, TimeSpan duration)
		{
			var anim = new DoubleAnimation(fromValue, toValue, new Duration(duration));
			anim.AccelerationRatio = 0.5;
			anim.DecelerationRatio = 0.5;
			obj.BeginAnimation(property, anim);
		}
开发者ID:uxoricide,项目名称:TxTranslation,代码行数:7,代码来源:AnimationHelper.cs

示例5: ShowwithAnimation

 public static void ShowwithAnimation(this Window window)
 {
     window.Visibility = Visibility.Visible;
     window.Topmost = false;
     TimeSpan slidetime = TimeSpan.FromSeconds(0.3);
     DoubleAnimation bottomAnimation = new DoubleAnimation();
     bottomAnimation.Duration = new Duration(slidetime);
     double top = window.Top;
     bottomAnimation.From = window.Top + 25;
     bottomAnimation.To = window.Top;
     bottomAnimation.FillBehavior = FillBehavior.Stop;
     bottomAnimation.Completed += (s, e) =>
     {
         window.Topmost = true;
         // Set the final position again. This covers a case where frames are dropped.
         // and the window ends up over the taskbar instead.
         window.Top = top;
         window.Activate();
         window.Focus();
     };
     var easing = new QuinticEase();
     easing.EasingMode = EasingMode.EaseOut;
     bottomAnimation.EasingFunction = easing;
     window.BeginAnimation(Window.TopProperty, bottomAnimation);
 }
开发者ID:nao0gtx,项目名称:EarTrumpet,代码行数:25,代码来源:WindowExtensions.cs

示例6: Animation_Opacity_View_Frame

 public static void Animation_Opacity_View_Frame(this UIElement E, bool isview = true, Action CompleteAction = null, double minisecond=500)
 {
     Visibility visibility = E.Visibility;
     if (visibility != Visibility.Visible)
     {
         E.Visibility = Visibility.Visible;
     }
     DoubleAnimation da = new DoubleAnimation() { Duration = TimeSpan.FromMilliseconds(minisecond), EasingFunction = new PowerEase() { Power = 4, EasingMode = EasingMode.EaseInOut } };
     if (isview)
     {
         da.From = E.Opacity;
         da.To = 1;
     }
     else
     {
         da.From = E.Opacity;
         da.To = 0;
     }
     da.Completed += (o, e) =>
     {
         if (!isview)
             E.Visibility = Visibility.Hidden;
         if (CompleteAction != null)
         {
             CompleteAction();
         }
     };
     E.BeginAnimation(UIElement.OpacityProperty, da);
 }
开发者ID:iceriver102,项目名称:alta-mtc-version-2,代码行数:29,代码来源:UIElementExtensions.cs

示例7: AnimateOpacity

 /// <summary>
 /// Animates the opacity of the specified object.
 /// </summary>
 /// <param name="obj">
 /// The object to animate.
 /// </param>
 /// <param name="targetOpacity">
 /// The target opacity.
 /// </param>
 /// <param name="animationTime">
 /// The animation time.
 /// </param>
 public static void AnimateOpacity(this IAnimatable obj, double targetOpacity, double animationTime)
 {
     var animation = new DoubleAnimation(targetOpacity, new Duration(TimeSpan.FromMilliseconds(animationTime)))
                         {
                             AccelerationRatio = 0.3,
                             DecelerationRatio = 0.5
                         };
     obj.BeginAnimation(UIElement.OpacityProperty, animation);
 }
开发者ID:dermeister0,项目名称:helix-toolkit,代码行数:21,代码来源:AnimationExtensions.cs

示例8: AnimateTo

        public static void AnimateTo(this RowDefinition row, double pixelValue, TimeSpan duration)
        {
            GridLengthAnimation heightAnim = new GridLengthAnimation() {
                To = pixelValue,
                Duration = new Duration(duration)
            };

            row.BeginAnimation(RowDefinition.HeightProperty, heightAnim);
        }
开发者ID:peteblois,项目名称:rooler,代码行数:9,代码来源:Extensions.cs

示例9: Fade

 /// <summary>Fades the specified source opacity.</summary>
 /// <param name="control">The <c>control</c>.</param>
 /// <param name="sourceOpacity">The source opacity.</param>
 /// <param name="targetOpactity">The target <c>opactity</c>.</param>
 /// <param name="milliseconds">The <c>milliseconds</c>.</param>
 /// <exception cref="OverflowException"><paramref>
 ///         <name>value</name>
 ///     </paramref>
 /// is less than <see cref="F:System.TimeSpan.MinValue" /> or greater than <see cref="F:System.TimeSpan.MaxValue" />.-or-<paramref>
 ///         <name>value</name>
 ///     </paramref>
 /// is <see cref="F:System.Double.PositiveInfinity" />.-or-<paramref>
 ///         <name>value</name>
 ///     </paramref>
 /// is <see cref="F:System.Double.NegativeInfinity" />. </exception>
 public static void Fade(this UIElement control, double sourceOpacity, double targetOpactity, int milliseconds)
 {
     control.BeginAnimation(
         UIElement.OpacityProperty,
         new DoubleAnimation(
             sourceOpacity,
             targetOpactity,
             new Duration(TimeSpan.FromMilliseconds(milliseconds))));
 }
开发者ID:jamsoft,项目名称:WPF-Prism-Demo-Part2,代码行数:24,代码来源:Animator.cs

示例10: animateOpacity

 public static void animateOpacity(this UIElement element, DependencyProperty prop, double from = 0, double to = 1)
 {
     double opa = element.Opacity;
     if (opa == from)
     {
         DoubleAnimation op = new DoubleAnimation(from, to, program.tSpan);
         element.BeginAnimation(prop, op);
     }
     if (to == 0) element.Visibility = Visibility.Hidden;
     else element.Visibility = Visibility.Visible;
 }
开发者ID:TomasFilingr,项目名称:CManager,代码行数:11,代码来源:blur.cs

示例11: BeginDoubleAnimation

 public static void BeginDoubleAnimation(this DependencyObject target, string path, double? to,
     Duration duration)
 {
     var animation = new DoubleAnimation
     {
         To = to,
         Duration = duration,
         EnableDependentAnimation = true
     };
     target.BeginAnimation(animation, path);
 }
开发者ID:beto-rodriguez,项目名称:Live-Charts,代码行数:11,代码来源:AnimationsHelper.cs

示例12: AnimateSourceChange

        /// <summary>
        /// Provides an animation while changing the source of an <see cref="Image"/> control.
        /// </summary>
        /// <param name="image">The target <see cref="Image"/> control.</param>
        /// <param name="source">The new <see cref="ImageSource"/> value.</param>
        /// <param name="fadeOutDuration">The duration to run the fade out animation for.</param>
        /// <param name="fadeInDuration">The duration to run the fade out animation for.</param>
        public static void AnimateSourceChange(this Image image, ImageSource source, TimeSpan fadeOutDuration, TimeSpan fadeInDuration)
        {
            var fadeInAnimation = new DoubleAnimation(1d, fadeInDuration);

            if (image.Source != null && fadeOutDuration > TimeSpan.Zero)
            {
                var fadeOutAnimation = new DoubleAnimation(0d, fadeOutDuration);

                fadeOutAnimation.Completed += (o, e) =>
                {
                    image.Source = source;
                    image.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation);
                };

                image.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation);
            }
            else
            {
                image.Opacity = 0d;
                image.Source = source;
                image.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation);
            }
        }
开发者ID:ChadJPetersen,项目名称:CCSWE-Libraries,代码行数:30,代码来源:ImageExtensions.cs

示例13: ChangeSource

	public static void ChangeSource(this Image image, ImageSource source, TimeSpan fadeOutTime, TimeSpan fadeInTime)
	{
		var fadeInAnimation = new DoubleAnimation(1d, fadeInTime);

		if (image.Source != null)
		{
			var fadeOutAnimation = new DoubleAnimation(0d, fadeOutTime);

			fadeOutAnimation.Completed += (o, e) =>
			{
				image.Source = source;
				image.BeginAnimation(Image.OpacityProperty, fadeInAnimation);
			};

			image.BeginAnimation(Image.OpacityProperty, fadeOutAnimation);
		}
		else
		{
			image.Opacity = 0d;
			image.Source = source;
			image.BeginAnimation(Image.OpacityProperty, fadeInAnimation);
		}
	}
开发者ID:kavenblog,项目名称:Comic-Smart-Panels,代码行数:23,代码来源:Extensions.cs

示例14: Animation_Color_Repeat

 public static void Animation_Color_Repeat(this SolidColorBrush E, Color from, Color to, double time = 500)
 {
     if (from == null)
     {
         from = E.GetColor();
     }
     ColorAnimation animation = new ColorAnimation();
     animation.From = from;
     animation.To = to;
     animation.Duration = TimeSpan.FromMilliseconds(time);
     animation.RepeatBehavior = RepeatBehavior.Forever;
     animation.EasingFunction = new PowerEase() { EasingMode = EasingMode.EaseInOut, Power = 3 };
     E.BeginAnimation(SolidColorBrush.ColorProperty, animation);
 }
开发者ID:iceriver102,项目名称:alta-mtc-version-2,代码行数:14,代码来源:UIElementExtensions.cs

示例15: FadeFromTo

 public static UIElement FadeFromTo(this UIElement uiElement,
     double fromOpacity, double toOpacity,
     int durationInMilliseconds, bool loopAnimation, bool showOnStart, bool collapseOnFinish)
 {
     var timeSpan = TimeSpan.FromMilliseconds(durationInMilliseconds);
     var doubleAnimation =
         new DoubleAnimation(fromOpacity, toOpacity,
             new Duration(timeSpan));
     if (loopAnimation)
         doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
     uiElement.BeginAnimation(UIElement.OpacityProperty, doubleAnimation);
     if (showOnStart)
     {
         uiElement.ApplyAnimationClock(UIElement.VisibilityProperty, null);
         uiElement.Visibility = Visibility.Visible;
     }
     if (collapseOnFinish)
     {
         var keyAnimation = new ObjectAnimationUsingKeyFrames { Duration = new Duration(timeSpan) };
         keyAnimation.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Collapsed, KeyTime.FromTimeSpan(timeSpan)));
         uiElement.BeginAnimation(UIElement.VisibilityProperty, keyAnimation);
     }
     return uiElement;
 }
开发者ID:kmcginnes,项目名称:PoC.NuGetWpf,代码行数:24,代码来源:UIElementExtensions.cs


注:本文中的this.BeginAnimation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。