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


C# UIElement.BeginAnimation方法代码示例

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


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

示例1: StartAnimation

        /// <summary>
        /// Starts an animation to a particular value on the specified dependency property.
        /// You can pass in an event handler to call when the animation has completed.
        /// </summary>
        /// <param name="pAnimatableElement">The gui element to animate.</param>
        /// <param name="pDependencyProperty">The dependency property to animate.</param>
        /// <param name="pToValue">The final value of the dependency property.</param>
        /// <param name="pAnimationDurationSeconds">The animation duration.</param>
        /// <param name="pCompletedEvent">The callback executed when the animation ended.</param>
        public static void StartAnimation(UIElement pAnimatableElement, DependencyProperty pDependencyProperty, double pToValue, double pAnimationDurationSeconds, EventHandler pCompletedEvent)
        {
            double lFromValue = (double)pAnimatableElement.GetValue(pDependencyProperty);

            DoubleAnimation lAnimation = new DoubleAnimation();
            lAnimation.From = lFromValue;
            lAnimation.To = pToValue;
            lAnimation.Duration = TimeSpan.FromSeconds(pAnimationDurationSeconds);

            lAnimation.Completed += delegate(object pSender, EventArgs pEventArgs)
            {
                //
                // When the animation has completed bake final value of the animation
                // into the property.
                //
                pAnimatableElement.SetValue(pDependencyProperty, pAnimatableElement.GetValue(pDependencyProperty));
                CancelAnimation(pAnimatableElement, pDependencyProperty);

                if (pCompletedEvent != null)
                {
                    pCompletedEvent(pSender, pEventArgs);
                }
            };

            lAnimation.Freeze();

            pAnimatableElement.BeginAnimation(pDependencyProperty, lAnimation);
        }
开发者ID:mastertnt,项目名称:XRay,代码行数:37,代码来源:AnimationHelper.cs

示例2: UIElementCome

 /// <summary>
 /// 控件窗口弹出动画
 /// </summary>
 public static void UIElementCome(UIElement uIElement, ScaleTransform _scale)
 {
     PennerDoubleAnimation da = new PennerDoubleAnimation()
     {
         From = 0.8,
         To = 1,
         Equation = Equations.BackEaseOut,
         FillBehavior = FillBehavior.Stop,
         Duration = TimeSpan.FromSeconds(0.5)
     };
     da.Completed += delegate
     {
         _scale.ScaleX = 1;
         _scale.ScaleY = 1;
     };
     DoubleAnimation daO = new DoubleAnimation()
     {
         From = 0,
         To = 1,
         FillBehavior = FillBehavior.Stop,
         Duration = TimeSpan.FromSeconds(0.7)
     };
     daO.Completed += delegate
     {
         uIElement.Opacity = 1;
     };
     _scale.BeginAnimation(ScaleTransform.ScaleXProperty, da);
     _scale.BeginAnimation(ScaleTransform.ScaleYProperty, da);
     uIElement.BeginAnimation(UIElement.OpacityProperty, daO);
 }
开发者ID:jiailiuyan,项目名称:Jisons,代码行数:33,代码来源:UserAnimationMethod.cs

示例3: StartAnimation

        /// <summary>
        /// Starts an animation to a particular value on the specified dependency property.
        /// You can pass in an event handler to call when the animation has completed.
        /// </summary>
        public static void StartAnimation(UIElement animationElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
        {
            if (animationElement == null)
            {
                throw new ArgumentNullResourceException("animationElement", Resources.General_Given_Parameter_Cannot_Be_Null);
            }

            var fromValue = (double)animationElement.GetValue(dependencyProperty);

            var animation = new DoubleAnimation { From = fromValue, To = toValue, Duration = TimeSpan.FromSeconds(animationDurationSeconds) };

            animation.Completed += (sender, e) =>
                                       {
                                           // When the animation has completed bake final value of the animation
                                           // into the property.
                                           animationElement.SetValue(dependencyProperty, animationElement.GetValue(dependencyProperty));
                                           CancelAnimation(animationElement, dependencyProperty);

                                           if (completedEvent != null)
                                           {
                                               completedEvent(sender, e);
                                           }
                                       };

            animation.Freeze();

            animationElement.BeginAnimation(dependencyProperty, animation);
        }
开发者ID:Benrnz,项目名称:TypeVisualiser,代码行数:32,代码来源:AnimationHelper.cs

示例4: StartAnimation

        /// <summary>
        /// Starts an animation to a particular value on the specified dependency property.
        /// You can pass in an event handler to call when the animation has completed.
        /// </summary>
        public static void StartAnimation(UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
        {
            double fromValue = (double)animatableElement.GetValue(dependencyProperty);

            DoubleAnimation animation = new DoubleAnimation();
            animation.From = fromValue;
            animation.To = toValue;
            animation.Duration = TimeSpan.FromSeconds(animationDurationSeconds);

            animation.Completed += delegate(object sender, EventArgs e)
            {
                //
                // When the animation has completed bake final value of the animation
                // into the property.
                //
                animatableElement.SetValue(dependencyProperty, animatableElement.GetValue(dependencyProperty));
                CancelAnimation(animatableElement, dependencyProperty);

                if (completedEvent != null)
                {
                    completedEvent(sender, e);
                }
            };

            animation.Freeze();

            animatableElement.BeginAnimation(dependencyProperty, animation);
        }
开发者ID:modopotato,项目名称:LibnoiseDesigner,代码行数:32,代码来源:AnimationHelper.cs

示例5: FadeUIElement

 public static void FadeUIElement(double fromValue, double toValue, UIElement control)
 {
     DoubleAnimation da = new DoubleAnimation(fromValue, toValue, time);
     da.DecelerationRatio = acceleration;
     da.Completed += UIElementFadeCompleted;
     control.BeginAnimation(UIElement.OpacityProperty, da);
 }
开发者ID:Shoop123,项目名称:Reworder-C-Sharp,代码行数:7,代码来源:Modification.cs

示例6: Animate

 public static void Animate(UIElement element, DependencyProperty property, double toValue, double duration)
 {
     DoubleAnimation Animation = new DoubleAnimation();
     Animation.To = toValue;
     Animation.Duration = new Duration(TimeSpan.FromSeconds(duration));
     element.BeginAnimation(property, Animation);
 }
开发者ID:mohamedgeemi,项目名称:FCIS-Photoshop,代码行数:7,代码来源:Animator.cs

示例7: fadeIn

 public static void fadeIn(UIElement itemToBeAnimated, double animationTimeInSeconds)
 {
     DoubleAnimation da = new DoubleAnimation();
     da.From = 0;
     da.To = 1;
     da.Duration = new Duration(TimeSpan.FromSeconds(animationTimeInSeconds));
     itemToBeAnimated.BeginAnimation(OpacityProperty, da);
 }
开发者ID:jimmichristensen,项目名称:Sprint3Projekt,代码行数:8,代码来源:AnimationClass.cs

示例8: CancelAnimation

        /// <summary>
        /// Cancel any animations that are running on the specified dependency property.
        /// </summary>
        public static void CancelAnimation(UIElement animatedElement, DependencyProperty dependencyProperty)
        {
            if (animatedElement == null)
            {
                throw new ArgumentNullResourceException("animatedElement", Resources.General_Given_Parameter_Cannot_Be_Null);
            }

            animatedElement.BeginAnimation(dependencyProperty, null);
        }
开发者ID:Benrnz,项目名称:TypeVisualiser,代码行数:12,代码来源:AnimationHelper.cs

示例9: HideAndFadeOut

 public static void HideAndFadeOut(UIElement control, double seconds)
 {
     DoubleAnimation fadeout = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromSeconds(seconds)));
     fadeout.Completed += delegate(object sender,EventArgs e)
     {
         control.Visibility = Visibility.Collapsed;
     };
     control.BeginAnimation(UIElement.OpacityProperty, fadeout);
 }
开发者ID:fenbf,项目名称:search3D,代码行数:9,代码来源:Helper.cs

示例10: fadeInOut

 public static void fadeInOut(UIElement itemToBeAnimated, double animationTimeInSeconds, int timesRepeated)
 {
     DoubleAnimation da = new DoubleAnimation();
     da.From = 1;
     da.To = 0;
     da.Duration = new Duration(TimeSpan.FromSeconds(animationTimeInSeconds));
     da.AutoReverse = true;
     da.RepeatBehavior = new RepeatBehavior(timesRepeated);
     itemToBeAnimated.BeginAnimation(OpacityProperty, da);
 }
开发者ID:jimmichristensen,项目名称:Sprint3Projekt,代码行数:10,代码来源:AnimationClass.cs

示例11: Start

        public void Start(object source)
        {
            //WPF objects MUST be created on the goddamn dispatcher thread, otherwise you run into trouble
            makeVisible = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(Duration)));
            makeInvisible = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromSeconds(Duration)));

            openingSource = source as UIElement;
            if (openingSource == null) return;

            openingSource.BeginAnimation(UIElement.OpacityProperty, makeVisible);
        }
开发者ID:flq,项目名称:TheDailyTweeter,代码行数:11,代码来源:AbstractInteractionButtonViewModel.cs

示例12: DoMove

 public static void DoMove(UIElement 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);//设置动画应用的属性并启动动画
 }
开发者ID:SeptemberWind,项目名称:AlarmClock-WPF,代码行数:12,代码来源:UIHelp.cs

示例13: StartAnimation

        public static void StartAnimation (UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double durationMilliseconds, double accelerationRatio, double decelerationRatio)
        {
            DoubleAnimation animation = new DoubleAnimation();
            animation.To = toValue;
            animation.AccelerationRatio = accelerationRatio;
            animation.DecelerationRatio = decelerationRatio;
            animation.FillBehavior = FillBehavior.HoldEnd;
            animation.Duration = TimeSpan.FromMilliseconds(durationMilliseconds);
            animation.Freeze();

            animatableElement.BeginAnimation(dependencyProperty, animation, HandoffBehavior.Compose);
        }
开发者ID:BdGL3,项目名称:CXPortal,代码行数:12,代码来源:AnimationHelper.cs

示例14: AddChildSP

        public static void AddChildSP(UIElement child, StackPanel sp, int start_time)
        {
            sp.Children.Add(child);

            child.Opacity = 0.0;

            DoubleAnimation an = new DoubleAnimation(0.0, 1.0, TimeSpan.FromMilliseconds(200));
            an.BeginTime = TimeSpan.FromMilliseconds(start_time += 80);

            child.BeginAnimation(btnDugmeTemp.OpacityProperty, an);

            DoubleAnimation da = new DoubleAnimation(50, 0, new Duration(TimeSpan.FromMilliseconds(200)));
            da.BeginTime = TimeSpan.FromMilliseconds(start_time);
            da.DecelerationRatio = 0.7;
            TranslateTransform rt = new TranslateTransform();
            child.RenderTransform = rt;
            rt.BeginAnimation(TranslateTransform.XProperty, da);
        }
开发者ID:voxPopuli92,项目名称:ViserInformator,代码行数:18,代码来源:Animate.cs

示例15: CancelAnimation

 /// <summary>
 /// Cancel any animations that are running on the specified dependency property.
 /// </summary>
 public static void CancelAnimation(UIElement animatableElement, DependencyProperty dependencyProperty)
 {
     animatableElement.BeginAnimation(dependencyProperty, null);
 }
开发者ID:modopotato,项目名称:LibnoiseDesigner,代码行数:7,代码来源:AnimationHelper.cs


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