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


C# Animation.DoubleAnimation类代码示例

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


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

示例1: AntGrid

        private void AntGrid(Grid g)
        {
            g.Width = 5;
            g.Height = 5;
            g.Visibility = Visibility.Visible;

            Storyboard sb = new Storyboard();
            DoubleAnimation da = new DoubleAnimation(5.0, gridmain.ActualWidth - 10, new Duration(TimeSpan.FromSeconds(2)));
            DoubleAnimation da1 = new DoubleAnimation(5.0, gridmain.RowDefinitions[0].ActualHeight - 10, new Duration(TimeSpan.FromSeconds(2)));

            DoubleAnimation da2 = new DoubleAnimation(0, 720, new Duration(TimeSpan.FromSeconds(2)));

            TransformGroup tg = new TransformGroup();
            RotateTransform rt = new RotateTransform(720);

            tg.Children.Add(rt);
            g.RenderTransform = tg;
            g.RenderTransformOrigin = new Point(0.5, 0.5);
            Storyboard.SetTarget(da2, g);
            Storyboard.SetTargetProperty(da2, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)"));//RotateTransform.AngleProperty
            sb.Children.Add(da2);

            Storyboard.SetTarget(da, g);
            Storyboard.SetTargetProperty(da, new PropertyPath(Grid.WidthProperty));
            sb.Children.Add(da);

            Storyboard.SetTarget(da1, g);
            Storyboard.SetTargetProperty(da1, new PropertyPath(Grid.HeightProperty));
            sb.Children.Add(da1);

            if (!Resources.Contains("ShowAn"))
                Resources.Add("ShowAn", sb);
            sb.AccelerationRatio = 1.0;
            sb.Begin();
        }
开发者ID:dingxinbei,项目名称:OLdBck,代码行数:35,代码来源:MainWindow.xaml.cs

示例2: DarkenPropertyChangedCallback

        private static void DarkenPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            var uiElement = dependencyObject as UIElement;
            var dropShadowEffect = uiElement?.Effect as DropShadowEffect;

            if (dropShadowEffect == null) return;

            if ((bool) dependencyPropertyChangedEventArgs.NewValue)
            {
                SetLocalInfo(dependencyObject, new ShadowLocalInfo(dropShadowEffect.Opacity));

                var doubleAnimation = new DoubleAnimation(1, new Duration(TimeSpan.FromMilliseconds(350)))
                {
                    FillBehavior = FillBehavior.HoldEnd
                };
                dropShadowEffect.BeginAnimation(DropShadowEffect.OpacityProperty, doubleAnimation);
            }
            else
            {
                var shadowLocalInfo = GetLocalInfo(dependencyObject);
                if (shadowLocalInfo == null) return;

                var doubleAnimation = new DoubleAnimation(shadowLocalInfo.StandardOpacity, new Duration(TimeSpan.FromMilliseconds(350)))
                {
                    FillBehavior = FillBehavior.HoldEnd
                };
                dropShadowEffect.BeginAnimation(DropShadowEffect.OpacityProperty, doubleAnimation);
            }
        }
开发者ID:punker76,项目名称:MaterialDesignInXamlToolkit,代码行数:29,代码来源:ShadowAssist.cs

示例3: GetStoryboard

        //得到动画画板
        private Storyboard GetStoryboard(double? From1, double To1, double? From2, double To2, double Time1, double Time2)
        {
            Storyboard myStoryboard = new Storyboard();

            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            if (From1 != null)
            {
                myDoubleAnimation.From = From1;
            }
            myDoubleAnimation.To = To1;
            myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(Time1));

            myStoryboard.Children.Add(myDoubleAnimation);
            Storyboard.SetTargetName(myDoubleAnimation, MaskFloor.Name);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Rectangle.OpacityProperty));

            DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
            if (From2 != null)
            {
                myDoubleAnimation1.From = From2;
            }
            myDoubleAnimation1.To = To2;
            myDoubleAnimation1.Duration = new Duration(TimeSpan.FromSeconds(Time2));

            myStoryboard.Children.Add(myDoubleAnimation1);
            Storyboard.SetTargetName(myDoubleAnimation1, InfFloor.Name);
            Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath(Rectangle.OpacityProperty));

            return myStoryboard;
        }
开发者ID:yonglehou,项目名称:BPMSV1,代码行数:31,代码来源:MaskControl.xaml.cs

示例4: CalibrationWpf

        public CalibrationWpf(Screen current)
        {
            InitializeComponent();
            screen = current;

            // Create the calibration target
            calibrationPointWpf = new CalibrationPointWpf(new Size(screen.Bounds.Width, screen.Bounds.Height));
            CalibrationCanvas.Children.Add(calibrationPointWpf);

            Opacity = 0;
            IsAborted = false;

            // Create the animation-out object and close form when completed
            animateOut = new DoubleAnimation(0, TimeSpan.FromSeconds(FADE_OUT_TIME))
            {
                From = 1.0,
                To = 0.0,
                AutoReverse = false
            };

            animateOut.Completed += delegate
            {
                Close();
            };
        }
开发者ID:kgram,项目名称:tet-csharp-samples,代码行数:25,代码来源:CalibrationWPF.xaml.cs

示例5: SmoothSetAsync

        public static Task SmoothSetAsync(this FrameworkElement @this, DependencyProperty dp, double targetvalue,
            TimeSpan iDuration, CancellationToken iCancellationToken)
        {
            TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
            DoubleAnimation anim = new DoubleAnimation(targetvalue, new Duration(iDuration));
            PropertyPath p = new PropertyPath("(0)", dp);
            Storyboard.SetTargetProperty(anim, p);
            Storyboard sb = new Storyboard();
            sb.Children.Add(anim);
            EventHandler handler = null;
            handler = delegate
            {
                sb.Completed -= handler;
                sb.Remove(@this);
                @this.SetValue(dp, targetvalue);
                tcs.TrySetResult(null);
            };
            sb.Completed += handler;
            sb.Begin(@this, true);

            iCancellationToken.Register(() =>
            {
                double v = (double)@this.GetValue(dp);  
                sb.Stop(); 
                sb.Remove(@this); 
                @this.SetValue(dp, v);
                tcs.TrySetCanceled();
            });

            return tcs.Task;
        }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:31,代码来源:FrameworkElementExtender.cs

示例6: BeginEnterAnimation

        /// <summary>
        /// 登录窗体逐渐缩小动画
        /// </summary>
        private void BeginEnterAnimation()
        {
            NameScope.SetNameScope(this, new NameScope());
            ScaleTransform st = this.RenderTransform as ScaleTransform;
            this.RegisterName("scale", st);

            Storyboard sb = new Storyboard();
            sb.Completed += (s, e) =>
            {
                this.Hide();
                new MainWindow().Show();
            };

            DoubleAnimation daX = new DoubleAnimation();
            daX.To = 0;
            daX.Duration = TimeSpan.FromSeconds(0.3);

            DoubleAnimation daY = new DoubleAnimation();
            daY.To = 0;
            daY.Duration = TimeSpan.FromSeconds(0.3);

            Storyboard.SetTargetName(daX, "scale");
            Storyboard.SetTargetProperty(daX, new PropertyPath(ScaleTransform.ScaleXProperty));
            Storyboard.SetTargetName(daY, "scale");
            Storyboard.SetTargetProperty(daY, new PropertyPath(ScaleTransform.ScaleYProperty));

            sb.Children.Add(daX);
            sb.Children.Add(daY);

            sb.Begin(this);

            //ST.BeginAnimation(ScaleTransform.ScaleXProperty, new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(1))));
            //ST.BeginAnimation(ScaleTransform.ScaleYProperty, new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(1))));
        }
开发者ID:dalinhuang,项目名称:ChargeLeaderSystem,代码行数:37,代码来源:WinLogin.xaml.cs

示例7: Tilt

    static Tilt()
    {
      tiltStoryboard = new Storyboard();
      untiltStoryboard = new Storyboard();

      depressAnimation = new DoubleAnimation { From = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(depressAnimation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.GlobalOffsetZ)"));
      tiltStoryboard.Children.Add(depressAnimation);

      rotationXAnimation = new DoubleAnimation { From = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(rotationXAnimation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.RotationX)"));
      tiltStoryboard.Children.Add(rotationXAnimation);

      rotationYAnimation = new DoubleAnimation { From = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(rotationYAnimation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.RotationY)"));
      tiltStoryboard.Children.Add(rotationYAnimation);

      DoubleAnimation animation = new DoubleAnimation { To = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(animation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.GlobalOffsetZ)"));
      untiltStoryboard.Children.Add(animation);

      animation = new DoubleAnimation { To = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(animation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.RotationX)"));
      untiltStoryboard.Children.Add(animation);

      animation = new DoubleAnimation { To = 0, Duration = TimeSpan.FromSeconds(.05) };
      Storyboard.SetTargetProperty(animation, new PropertyPath("(FrameworkElement.Projection).(PlaneProjection.RotationY)"));
      untiltStoryboard.Children.Add(animation);
    }
开发者ID:JoeMarsh,项目名称:Astro-Flare-Rampage,代码行数:29,代码来源:Tilt.cs

示例8: border_mouseLeftButtonDown

        // When the user left-clicks, use the 
        // SnapshotAndReplace HandoffBehavior when applying the animation.        
        private void border_mouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var clickPoint = Mouse.GetPosition(_containerBorder);

            // Set the target point so the center of the ellipse
            // ends up at the clicked point.
            var targetPoint = new Point
            {
                X = clickPoint.X - _interactiveEllipse.Width/2,
                Y = clickPoint.Y - _interactiveEllipse.Height/2
            };

            // Animate to the target point.
            var xAnimation =
                new DoubleAnimation(targetPoint.X,
                    new Duration(TimeSpan.FromSeconds(4)));
            _interactiveTranslateTransform.BeginAnimation(
                TranslateTransform.XProperty, xAnimation, HandoffBehavior.SnapshotAndReplace);

            var yAnimation =
                new DoubleAnimation(targetPoint.Y,
                    new Duration(TimeSpan.FromSeconds(4)));
            _interactiveTranslateTransform.BeginAnimation(
                TranslateTransform.YProperty, yAnimation, HandoffBehavior.SnapshotAndReplace);

            // Change the color of the ellipse.
            _interactiveEllipse.Fill = Brushes.Lime;
        }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:30,代码来源:InteractiveAnimationExample.cs

示例9: btnRadiusAnimation_Click

 private void btnRadiusAnimation_Click(object sender, RoutedEventArgs e)
 {
     DoubleAnimation animation = new DoubleAnimation(200, new Duration(TimeSpan.FromSeconds(5)));
     animation.AutoReverse = true;
     myEllipse.BeginAnimation(WidthProperty, animation);
     myEllipse.BeginAnimation(HeightProperty, animation);
 }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:7,代码来源:Window1.xaml.cs

示例10: Animate

        public static void Animate(this DependencyObject target, double from, double to, object propertyPath, int duration, int startTime, IEasingFunction easing = null, Action completed = null)
        {
            if (easing == null)
                easing = new SineEase();

            var db = new DoubleAnimation();
            db.To = to;
            db.From = from;
            db.EasingFunction = easing;
            db.Duration = TimeSpan.FromMilliseconds(duration);

            Storyboard.SetTarget(db, target);
            Storyboard.SetTargetProperty(db, new PropertyPath(propertyPath));

            var sb = new Storyboard();
            sb.BeginTime = TimeSpan.FromMilliseconds(startTime);

            if (completed != null)
            {
                sb.Completed += (s, e) => completed();
            }

            sb.Children.Add(db);
            sb.Begin();
        }
开发者ID:kiendev,项目名称:FarjiChat,代码行数:25,代码来源:Extensions.cs

示例11: ShowHelp

        public void ShowHelp(string msg, int maxRepetitions)
        {
            if (Enabled == false) return;

            if (repetitions.ContainsKey(msg))
            {
                --repetitions[msg];
                if (repetitions[msg] <= 0)
                {
                    return;
                }
            }
            else
            {
                repetitions.Add(msg, maxRepetitions);
            }

            currentMsg = msg;

            label.Content = "Help: " + msg;
            label.Foreground = Brushes.Orange;
            label.Visibility = Visibility.Visible;
            DoubleAnimation fadein = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(0.5)));
            //fadein.RepeatBehavior = RepeatBehavior.Forever;
            label.BeginAnimation(UIElement.OpacityProperty, fadein);
        }
开发者ID:fenbf,项目名称:search3D,代码行数:26,代码来源:HelpSystem.cs

示例12: Animation_Completed

        private void Animation_Completed(object sender, EventArgs e)
        {
            switch (navArgs.NavigationMode)
            {
                case NavigationMode.New:
                    if (navArgs.Uri == null)
                        NavigationFrame.Navigate(navArgs.Content);
                    else
                        NavigationFrame.Navigate(navArgs.Uri);
                    break;
                case NavigationMode.Back:
                    NavigationFrame.GoBack();
                    break;
                case NavigationMode.Forward:
                    NavigationFrame.GoForward();
                    break;
                case NavigationMode.Refresh:
                    NavigationFrame.Refresh();
                    break;
            }
            inNavigation = false;

            var animation = new DoubleAnimation
            {
                From = 0f,
                To = 1f,
                Duration = new Duration(TimeSpan.FromMilliseconds(200))
            };
            NavigationFrame.BeginAnimation(OpacityProperty, animation);
        }
开发者ID:PatGet,项目名称:CasualRacer,代码行数:30,代码来源:MainWindow.xaml.cs

示例13: fade

        internal void fade(bool fadein)
        {            // Create a storyboard to contain the animations.
            storyboard = new Storyboard();
            TimeSpan duration = new TimeSpan(0, 0, 1);

            // Create a DoubleAnimation to fade the not selected option control
            DoubleAnimation animation = new DoubleAnimation();
            if (fadein)
            {
                animation.From = 0.0;
                animation.To = 1.0;
            }
            else
            {
                animation.From = 1.0;
                animation.To = 0.0;
            }
            animation.Duration = new Duration(duration);
            // Configure the animation to target de property Opacity
            Storyboard.SetTargetName(animation, this.uiImage.Name);
            Storyboard.SetTargetProperty(animation, new PropertyPath(Image.OpacityProperty));
            // Add the animation to the storyboard
            storyboard.Children.Add(animation);

            // Begin the storyboard
            storyboard.Begin(this.uiImage);
        }
开发者ID:muzefm,项目名称:ebucms,代码行数:27,代码来源:ImgSlot.xaml.cs

示例14: Paddle

        public Paddle()
        {
            // Sets up the body part's shape.
            this.Shape = new Polygon
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                StrokeThickness = 3.0,
                Opacity = 1.0,
                Fill = Brushes.Orange,
                Stroke = Brushes.Black
            };
            this.state = PaddleState.PreGame;

            // Sets up the appear animation.
            this.AppearAnimation = new Storyboard();
            DoubleAnimation da = new DoubleAnimation(1.0, new Duration(Paddle.AppearAnimationDuration));
            Storyboard.SetTarget(da, this.Shape);
            Storyboard.SetTargetProperty(da, new PropertyPath(Polygon.OpacityProperty));
            this.AppearAnimation.Children.Add(da);

            // Sets up the hit animation.
            this.FillAnimation = new Storyboard();
            ColorAnimation ca = new ColorAnimation(Colors.Red, Colors.Orange, new Duration(Paddle.HitAnimationDuration));
            Storyboard.SetTarget(ca, this.Shape);
            Storyboard.SetTargetProperty(ca, new PropertyPath("Fill.Color", new object[] { Polygon.FillProperty, SolidColorBrush.ColorProperty }));
            this.FillAnimation.Children.Add(ca);
            this.State = PaddleState.PreGame;
        }
开发者ID:NIAEFEUP,项目名称:Kommando,代码行数:29,代码来源:Paddle.cs

示例15: AnimateEntry

        private void AnimateEntry(Size targetSize)
        {
            var svi = GuiHelpers.GetParentObject<ScatterViewItem>(this, false);
            if (svi != null)
            {
                // Easing function provide a more natural animation
                IEasingFunction ease = new BackEase {EasingMode = EasingMode.EaseOut, Amplitude = 0.3};
                var duration = new Duration(TimeSpan.FromMilliseconds(500));
                var w = new DoubleAnimation(0.0, targetSize.Width, duration) {EasingFunction = ease};
                var h = new DoubleAnimation(0.0, targetSize.Height, duration) {EasingFunction = ease};
                var o = new DoubleAnimation(0.0, 1.0, duration);

                // Remove the animation after it has completed so that its possible to manually resize the scatterviewitem
                w.Completed += (s, e) => svi.BeginAnimation(ScatterViewItem.WidthProperty, null);
                h.Completed += (s, e) => svi.BeginAnimation(ScatterViewItem.HeightProperty, null);
                // Set the size manually, otherwise once the animation is removed the size will revert back to the minimum size
                // Since animation has higher priority for DP's, this setting won't have effect until the animation is removed
                svi.Width = targetSize.Width;
                svi.Height = targetSize.Height;

                svi.BeginAnimation(ScatterViewItem.WidthProperty, w);
                svi.BeginAnimation(ScatterViewItem.HeightProperty, h);
                svi.BeginAnimation(ScatterViewItem.OpacityProperty, o);
            }
        }
开发者ID:gdlprj,项目名称:duscusys,代码行数:25,代码来源:PopupWindow.xaml.cs


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