• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Animation.DoubleAnimation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Windows.UI.Xaml.Media.Animation.DoubleAnimation的典型用法代码示例。如果您正苦于以下问题:C# DoubleAnimation类的具体用法?C# DoubleAnimation怎么用?C# DoubleAnimation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DoubleAnimation类属于Windows.UI.Xaml.Media.Animation命名空间,在下文中一共展示了DoubleAnimation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: StartAnimation

        private void StartAnimation(EasingFunctionBase easingFunction)
        {
            // show the chart
            chartControl.Draw(easingFunction);

            // animation
#if WPF
            NameScope.SetNameScope(translate1, new NameScope());
#endif

            var storyboard = new Storyboard();
            var ellipseMove = new DoubleAnimation();
            ellipseMove.EasingFunction = easingFunction;
            ellipseMove.Duration = new Duration(TimeSpan.FromSeconds(AnimationTimeSeconds));
            ellipseMove.From = 0;
            ellipseMove.To = 460;
#if WPF
            Storyboard.SetTargetName(ellipseMove, nameof(translate1));
            Storyboard.SetTargetProperty(ellipseMove, new PropertyPath(TranslateTransform.XProperty));
#else
            Storyboard.SetTarget(ellipseMove, translate1);
            Storyboard.SetTargetProperty(ellipseMove, "X");
#endif

            ellipseMove.BeginTime = TimeSpan.FromSeconds(0.5); // start animation in 0.5 seconds
            ellipseMove.FillBehavior = FillBehavior.HoldEnd; // keep position after animation

            storyboard.Children.Add(ellipseMove);
#if WPF
            storyboard.Begin(this);
#else
            storyboard.Begin();
#endif
        }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:34,代码来源:EasingFunctions.xaml.cs


示例2: AnimateVertexForward

        public void AnimateVertexForward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                if (CenterScale)
                    target.RenderTransformOrigin = new Point(.5, .5);
                else
                    target.RenderTransformOrigin = new Point(0, 0);
            }

            var sb = new Storyboard();
            var scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);

            //transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            //transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
            sb.Begin();
        }
开发者ID:aliaspilote,项目名称:TX52,代码行数:27,代码来源:MouseOverScaleAnimation.cs


示例3: BeginMenuAnimatie

        /// <summary>
        /// Begint een nieuw storyboard dat het menu grid uitschuift of inschuift naar een positieve (zichtbaar) of negatieve (onzichtbaar) margin.
        /// </summary>
        public void BeginMenuAnimatie()
        {
            Storyboard storyboard = new Storyboard();
            TranslateTransform beweegTransformatie = new TranslateTransform();
            menu.RenderTransform = beweegTransformatie;
            DoubleAnimation verplaatsMenuAnimatie = new DoubleAnimation();
            verplaatsMenuAnimatie.Duration = new Duration(TimeSpan.FromSeconds(0.15));
            if (btnHideShow.Content.Equals(">"))
            {
                verplaatsMenuAnimatie.To = 303;
                verplaatsMenuAnimatie.From = 0;
                btnHideShow.Content = "<";
            }
            else
            {
                verplaatsMenuAnimatie.To = 0;
                verplaatsMenuAnimatie.From = 303;
                btnHideShow.Content = ">";
            }

            storyboard.Children.Add(verplaatsMenuAnimatie);
            Storyboard.SetTarget(verplaatsMenuAnimatie, beweegTransformatie);
            Storyboard.SetTargetProperty(verplaatsMenuAnimatie, "X");
            storyboard.Begin();
        }
开发者ID:EusebiusVD,项目名称:Stage,代码行数:28,代码来源:Menu.xaml.cs


示例4: AnimateVertexBackward

        public void AnimateVertexBackward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                target.RenderTransformOrigin = CenterScale ? new Point(.5, .5) : new Point(0, 0);
                return; //no need to back cause default already
            }

            if (transform.ScaleX <= 1 || transform.ScaleY <= 1) return;

            var sb = new Storyboard();
            var scaleAnimation = new DoubleAnimation{ Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = transform.ScaleX, To = 1 };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = transform.ScaleX, To = 1 };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);

            //transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            //transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
            sb.Begin();
        }
开发者ID:aliaspilote,项目名称:TX52,代码行数:27,代码来源:MouseOverScaleAnimation.cs


示例5: MoveTo

        public void MoveTo(Point from, Point to, EventHandler<object> completed = null)
        {
            TranslateTransform trans = new TranslateTransform();

            _participant.Name = "MyTarget";
            _participant.RenderTransform = trans;

            DoubleAnimation anim1 = new DoubleAnimation() { From = from.X, To = to.X, Duration = TimeSpan.FromMilliseconds(Utility.GAME_TICK_MS - 1) };
            DoubleAnimation anim2 = new DoubleAnimation() { From = from.Y, To = to.Y, Duration = TimeSpan.FromMilliseconds(Utility.GAME_TICK_MS - 1) };

            Storyboard.SetTarget(anim1, _participant);
            Storyboard.SetTargetName(anim1, _participant.Name);
            Storyboard.SetTargetProperty(anim1, "(Canvas.Left)");

            Storyboard.SetTarget(anim2, _participant);
            Storyboard.SetTargetName(anim2, _participant.Name);
            Storyboard.SetTargetProperty(anim2, "(Canvas.Top)");

            Storyboard sb = new Storyboard();
            sb.Children.Add(anim1);
            sb.Children.Add(anim2);

            if (completed == null)
                sb.Completed += (object sender, object e) => { };
            else
                sb.Completed += completed;

            sb.Begin();
        }
开发者ID:bramom,项目名称:Bug.RS,代码行数:29,代码来源:Sprite.cs


示例6: InitializeControl

        private void InitializeControl()
        {
            try
            {

                if (root == null)
                {
                    root = (Canvas)GetTemplateChild("root");
                    layerStoryboard = (Storyboard)root.Resources["layerStoryboard"];

                    layerAnimationX = (DoubleAnimation)layerStoryboard.Children[0];
                    layerAnimationY = (DoubleAnimation)layerStoryboard.Children[1];

                    layerState = new LayerState(SensitivityX, SensitivityY);

                    Conductor.Beat += Conductor_Beat;

                    rootParent = (Canvas)this.Parent;
                    //rootParent.PointerPressed += rootParent_PointerPressed;
                    rootParent.ManipulationDelta += rootParent_ManipulationDelta;
                    rootParent.ManipulationMode = this.ManipulationMode; // &ManipulationModes.TranslateY;

                }


            }
            catch { }
        }
开发者ID:liquidboy,项目名称:X,代码行数:28,代码来源:InnertialLayer.cs


示例7: FadeIn

        private void FadeIn()
        {
            if (_Running)
            {
                DoubleAnimation fadeIn = new DoubleAnimation();

                fadeIn.From = 0.0;
                fadeIn.To = 1;
                fadeIn.Duration = new Duration(TimeSpan.FromSeconds(2));
                fadeIn.BeginTime = TimeSpan.FromSeconds(2);

                Storyboard sb = new Storyboard();

                Storyboard.SetTarget(fadeIn, _Control);
                Storyboard.SetTargetProperty(fadeIn, "Opacity");

                sb.Children.Add(fadeIn);

                _Control.Resources.Clear();
                _Control.Resources.Add("FaderEffect", sb);

                sb.Completed += this.OnFadeInCompleted;

                sb.Begin();
            }
        }
开发者ID:rllibby,项目名称:SignalR,代码行数:26,代码来源:MainPage.xaml.cs


示例8: Animate

        public static void Animate(this UIElement element, double from, double to, double fullDistance)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            var transform = new TranslateTransform();
            element.RenderTransform = transform;

            var xAnimation = new DoubleAnimation
            {
                From = from,
                Duration = TimeSpan.FromMilliseconds(GetAnimationSpeed(from, to, fullDistance)),
                To = to,
                EnableDependentAnimation = true,
                EasingFunction = new SineEase() { EasingMode = EasingMode.EaseOut }
            };

            Storyboard.SetTarget(xAnimation, transform);
            Storyboard.SetTargetProperty(xAnimation, "X");

            var storyboard = new Storyboard();
            storyboard.Children.Add(xAnimation);

            storyboard.Begin();
        }
开发者ID:PavelGriza,项目名称:SlidePane,代码行数:27,代码来源:AnimationExtensions.cs


示例9: UIElement_OnPointerEntered

        private void UIElement_OnPointerEntered(object sender, PointerRoutedEventArgs e)
        {
            var border = (Border)sender;

            // Somehow ZIndex doesn't work in the UniformGrid
            // Perhaps if Jupiter had a method called Panel.GetVisualChild available to override...
            // See: http://blog.pixelingene.com/2007/12/controlling-z-index-of-children-in-custom-controls/
            //Canvas.SetZIndex(border, ++_maxZIndex);
            var sb = new Storyboard();

            var a1 = new DoubleAnimation();
            a1.Duration = TimeSpan.FromSeconds(0.2);
            a1.To = 0.9;
            a1.EasingFunction = new PowerEase { Power = 2, EasingMode = EasingMode.EaseOut };
            Storyboard.SetTarget(a1, border.RenderTransform);
            Storyboard.SetTargetProperty(a1, "ScaleX");
            sb.Children.Add(a1);

            var a2 = new DoubleAnimation();
            a2.Duration = TimeSpan.FromSeconds(0.2);
            a2.To = 0.9;
            a2.EasingFunction = new PowerEase { Power = 2, EasingMode = EasingMode.EaseOut };
            Storyboard.SetTarget(a2, border.RenderTransform);
            Storyboard.SetTargetProperty(a2, "ScaleY");
            sb.Children.Add(a2);

            sb.Begin();
        }
开发者ID:siatwangmin,项目名称:WinRTXamlToolkit,代码行数:28,代码来源:UniformGridTestView.xaml.cs


示例10: AnimateOpacity

        static public void AnimateOpacity(FrameworkElement element, double start, double end, double duration)
        {
            element.Opacity = 0;

            Duration animationDuration = new Duration(TimeSpan.FromSeconds(duration));
            DoubleAnimation opacityAnimation = new DoubleAnimation();

            opacityAnimation.Duration = animationDuration;
            opacityAnimation.From = start;
            opacityAnimation.To = end;

            Storyboard sb = new Storyboard();
            sb.Duration = animationDuration;

            sb.Children.Add(opacityAnimation);

            Storyboard.SetTarget(opacityAnimation, element);

            // Set the X and Y properties of the Transform to be the target properties
            // of the two respective DoubleAnimations.
            Storyboard.SetTargetProperty(opacityAnimation, "Opacity");

            // Begin the animation.
            sb.Begin();
        }
开发者ID:grantamos,项目名称:decibel,代码行数:25,代码来源:AnimationLibrary.cs


示例11: LoginPage

        //public LoginPageViewModel vm { get; private set; }
        public LoginPage()
        {
            this.InitializeComponent();
            DataContextChanged += LoginPage_DataContextChanged;
            _toRegSb = new Storyboard();
            Duration duration = new Duration(TimeSpan.FromSeconds(0.2));
            _logspda = new DoubleAnimation()
            {
                From = 0,
                To = -FrameWidth,
                AutoReverse = false,
                Duration = duration
            };
            _regspda = new DoubleAnimation()
            {
                From = FrameWidth,
                To = 0,
                AutoReverse = false,
                Duration = duration
            };
            Storyboard.SetTargetProperty(_regspda, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            Storyboard.SetTargetProperty(_logspda, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            Storyboard.SetTarget(_logspda, logSP);
            Storyboard.SetTarget(_regspda, regSP);

            _toRegSb.Children.Add(_regspda);
            _toRegSb.Children.Add(_logspda);

            Rect rect = new Rect(0, 0, FrameWidth, 300);
            RectangleGeometry reo = new RectangleGeometry();
            reo.Rect = rect;
            this.infoBorder.Clip = reo;
        }
开发者ID:csongysun,项目名称:HJXYT,代码行数:34,代码来源:LoginPage.xaml.cs


示例12: Splarkle

        private void Splarkle(Windows.UI.Input.PointerPoint point)
        {
            var x = point.Position.X;
            var y = point.Position.Y;
            var s = .5d;
            var dot = new Windows.UI.Xaml.Shapes.Ellipse
            {
                Height = 10,
                Width = 10,
                Opacity = 1,
                VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top,
                HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left,
                Fill = new SolidColorBrush(GetRandColor()),
                RenderTransform = new CompositeTransform
                {
                    TranslateX = x,
                    TranslateY = y,
                    ScaleX = s,
                    ScaleY = s,
                },
            };
            LayoutRoot.Children.Add(dot);

            var d = TimeSpan.FromMilliseconds(_Random.Next(300, 1200));

            x += _Random.Next(-100, 100);
            var atx = new DoubleAnimation { To = x, Duration = d };
            Storyboard.SetTarget(atx, dot.RenderTransform);
            Storyboard.SetTargetProperty(atx, "TranslateX");

            y += _Random.Next(-50, 100);
            var aty = new DoubleAnimation { To = y, Duration = d };
            Storyboard.SetTarget(aty, dot.RenderTransform);
            Storyboard.SetTargetProperty(aty, "TranslateY");

            s += _Random.Next(1, 2);
            var asx = new DoubleAnimation { To = s, Duration = d };
            Storyboard.SetTarget(asx, dot.RenderTransform);
            Storyboard.SetTargetProperty(asx, "ScaleX");

            var asy = new DoubleAnimation { To = s, Duration = d };
            Storyboard.SetTarget(asy, dot.RenderTransform);
            Storyboard.SetTargetProperty(asy, "ScaleY");

            var ao = new DoubleAnimation { To = 0, Duration = d };
            Storyboard.SetTarget(ao, dot);
            Storyboard.SetTargetProperty(ao, "Opacity");

            var story = new Storyboard();
            story.Completed += (sender, e) => LayoutRoot.Children.Remove(dot);
            story.Children.Add(atx);
            story.Children.Add(aty);
            story.Children.Add(asx);
            story.Children.Add(asy);
            story.Children.Add(ao);
            story.Begin();
        }
开发者ID:noriike,项目名称:xaml-106136,代码行数:57,代码来源:MainPage.xaml.cs


示例13: CreatAnimation

 /// <summary>
 /// 创建动画
 /// </summary> 
 public static DoubleAnimation CreatAnimation(DependencyObject obj, string path, int duration, EasingFunctionBase easing = null)
 {
     DoubleAnimation da = new DoubleAnimation();
     da.EasingFunction = easing;
     da.Duration = TimeSpan.FromMilliseconds(duration);
     Storyboard.SetTarget(da, obj);
     Storyboard.SetTargetProperty(da, path);
     return da;
 }
开发者ID:HppZ,项目名称:UniversalTest,代码行数:12,代码来源:StoryboardHelper.cs


示例14: 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


示例15: CreateDouble

 public static DoubleAnimation CreateDouble(double? to, Duration duration, string targetProperty)
 {
     var animation = new DoubleAnimation
     {
         To = to,
         Duration = duration,
         EnableDependentAnimation = true
     };
     Storyboard.SetTargetProperty(animation, targetProperty);
     return animation;
 }
开发者ID:beto-rodriguez,项目名称:Live-Charts,代码行数:11,代码来源:AnimationsHelper.cs


示例16: CreateDoubleAnimation

 public static DoubleAnimation CreateDoubleAnimation(double? from, double? to, Duration duration, string targetProperty, DependencyObject target, EasingFunctionBase easing = null)
 {
     var db = new DoubleAnimation();
     db.To = to;
     db.From = from;
     db.EasingFunction = easing;
     db.Duration = duration;
     Storyboard.SetTarget(db, target);
     Storyboard.SetTargetProperty(db, targetProperty);
     return db;
 }
开发者ID:king89,项目名称:MangaViewer,代码行数:11,代码来源:AnimationHelp.cs


示例17: CreateDoubleAnimation

 public static DoubleAnimation CreateDoubleAnimation(UIElement uiElement, double from, double to,
     string propertyToAnimate)
 {
     DoubleAnimation animation = new DoubleAnimation();
     Storyboard.SetTarget(animation, uiElement);
     Storyboard.SetTargetProperty(animation, propertyToAnimate);
     animation.From = from;
     animation.To = to;
     animation.Duration = TimeSpan.FromSeconds(3);
     return animation;
 }
开发者ID:Arasz,项目名称:StarrySky,代码行数:11,代码来源:BeeStarHelper.cs


示例18: CreateDoubleAnimation

        public static DoubleAnimation CreateDoubleAnimation(UIElement control, double from, double to,
            string property, TimeSpan duration)
        {
            DoubleAnimation animation = new DoubleAnimation();
            Storyboard.SetTarget(animation, control);
            Storyboard.SetTargetProperty(animation, property);
            animation.From = from;
            animation.To = to;
            animation.Duration = duration;

            return animation;
        }
开发者ID:jshininger,项目名称:Invaders,代码行数:12,代码来源:InvadersHelper.cs


示例19: Show

        public void Show()
        {
            //2s之内连续按2次,退出
            if (clickCount > 0)
            {
                if (Completed != null)
                {
                    Completed(true);
                }
            }
            else
            {
                clickCount++;

                if (Completed != null)
                {
                    Completed(false);
                }

                var tips = new JMessboxControl();
                tips.DataContext = this;
                popup.Height = 65;
                popup.Width = 200;
                popup.Margin = new Thickness(140, 380, 0, 0);
                popup.IsOpen = false;
                popup.Child = tips;

                //渐变效果:透明度200毫秒内从0->1
                Storyboard story = new Storyboard();
                DoubleAnimation topAnimation = new DoubleAnimation();
                topAnimation.From = 0;
                topAnimation.To = 1;
                topAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(200));
                Storyboard.SetTarget(topAnimation, tips);
                Storyboard.SetTargetProperty(topAnimation, "(UIElement.Opacity)");

                story.Children.Add(topAnimation);

                popup.IsOpen = true;
                story.Begin();
                //动画延迟2秒
                story.Duration = new Duration(new TimeSpan(0, 0, 2));
                //story.BeginTime = new TimeSpan(0, 0, 0, 0, 1);
                story.Completed += (s1, e1) =>
                {
                    //2s后执行此方法
                    clickCount = 0;
                    popup.IsOpen = false;
                    story.Stop();
                };
            }

        }
开发者ID:jevonsflash,项目名称:ProjectMato,代码行数:53,代码来源:JMessBox.cs


示例20: CreateDoubleSB

        public static Storyboard CreateDoubleSB(DependencyObject dpnObj, string property, double secondTime, Double to)
        {
            DoubleAnimation ca = new DoubleAnimation();
            ca.Duration = TimeSpan.FromSeconds(secondTime);
            ca.To = to;

            Storyboard.SetTarget(ca, dpnObj);
            Storyboard.SetTargetProperty(ca, property);
            Storyboard sb = new Storyboard();

            sb.Children.Add(ca);
            return sb;
        }
开发者ID:wpdu,项目名称:ControlTest,代码行数:13,代码来源:AnimationFactory.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Animation.EasingFunctionBase类代码示例发布时间:2022-05-26
下一篇:
C# Media.SolidColorBrush类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap