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


C# TranslateTransform.BeginAnimation方法代码示例

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


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

示例1: Bounce

        /// <summary>
        /// Bounces the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="whenDone">The when done.</param>
        public static void Bounce(UIElement element, Direction direction, EventHandler whenDone = null)
        {
            var translateTransform = new TranslateTransform();
            element.RenderTransform = translateTransform;
            switch (direction)
            {
                case Direction.Up:
                    translateTransform.BeginAnimation(
                        TranslateTransform.YProperty,
                        CreateDoubleAnimation(
                        0,
                        -15,
                        0.2,
                        (o, e) => translateTransform.BeginAnimation(TranslateTransform.YProperty, CreateDoubleAnimationWithEasing(-15, 0, 0.8, new BounceEase { Bounces = 3, EasingMode = EasingMode.EaseOut })),
                        whenDone));
                    break;

                case Direction.Down:
                    translateTransform.BeginAnimation(
                        TranslateTransform.YProperty,
                        CreateDoubleAnimation(
                        0,
                        15,
                        0.2,
                        (o, e) => translateTransform.BeginAnimation(TranslateTransform.YProperty, CreateDoubleAnimationWithEasing(15, 0, 0.8, new BounceEase { Bounces = 3, EasingMode = EasingMode.EaseOut })),
                        whenDone));
                    break;
            }
        }
开发者ID:quitrk,项目名称:MiniDeskTube,代码行数:35,代码来源:Animate.cs

示例2: MoveWithRotationAndFadeOut

        public static void MoveWithRotationAndFadeOut(FrameworkElement element, Point to, double rotationAngle, double seconds, AnimationCompletedDelegate callback)
        {
            TransformGroup transformGroup = new TransformGroup();
            transformGroup.Children.Add(new RotateTransform(rotationAngle, element.Width / 2, element.Height / 2));

            Duration duration = new Duration(TimeSpan.FromSeconds(seconds));
            DoubleAnimation animationX = new DoubleAnimation(to.X, duration);
            DoubleAnimation animationY = new DoubleAnimation(to.Y, duration);
            DoubleAnimation fadeOutAnimation = new DoubleAnimation
            {
                From = 1,
                To = 0.4,
                Duration = duration,
                FillBehavior = FillBehavior.Stop
            };

            animationX.Completed += (sender, _) => callback(sender, _);

            TranslateTransform trans = new TranslateTransform();
            element.RenderTransform = transformGroup;

            trans.BeginAnimation(TranslateTransform.XProperty, animationX);
            trans.BeginAnimation(TranslateTransform.YProperty, animationY);

            element.Opacity = 0.4;
            element.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation);
            transformGroup.Children.Add(trans);
        }
开发者ID:rechc,项目名称:KinectMiniApps,代码行数:28,代码来源:Animate.cs

示例3: ExpandMenu

 private void ExpandMenu(Ellipse item, int distance)
 {
     DoubleAnimation animation = new DoubleAnimation(0, distance, TimeSpan.FromSeconds(.5));
     TranslateTransform move = new TranslateTransform();
     item.RenderTransform = move;
     move.BeginAnimation(TranslateTransform.XProperty, animation);
     move.BeginAnimation(TranslateTransform.YProperty, animation);
 }
开发者ID:picoriley,项目名称:xml-viewer,代码行数:8,代码来源:MainWindow.xaml.cs

示例4: AnimateLayout

        private void AnimateLayout()
        {
            var startDelay = new TimeSpan();

            foreach (UIElement child in Children)
            {
                Point arrangePosition;
                Transform currentTransform = GetCurrentLayoutInfo(child, out arrangePosition);

                bool bypassTransform = _isAnimationValid != (int) GetValue(IsAnimationValidProperty);

                // If we had previously stored an arrange position, see if it has moved
                if (child.ReadLocalValue(SavedArrangePositionProperty) != DependencyProperty.UnsetValue)
                {
                    var savedArrangePosition = (Point) child.GetValue(SavedArrangePositionProperty);

                    // If the arrange position hasn't changed, then we've already set up animations, etc
                    // and don't need to do anything
                    if (!AreClose(savedArrangePosition, arrangePosition))
                    {
                        // If we apply the current transform to the saved arrange position, we'll see where
                        // it was last rendered
                        Point lastRenderPosition = currentTransform.Transform(savedArrangePosition);
                        if (bypassTransform)
                            lastRenderPosition = (Point) child.GetValue(SavedCurrentPositionProperty);
                        else
                            child.SetValue(SavedCurrentPositionProperty, lastRenderPosition);

                        // Transform the child from the new location back to the old position
                        var newTransform = new TranslateTransform();
                        SetLayout2LayoutTransform(child, newTransform);

                        // Decay the transformation with an animation
                        double startValue = lastRenderPosition.X - arrangePosition.X;
                        newTransform.BeginAnimation(TranslateTransform.XProperty,
                                                    MakeStaticAnimation(startValue, startDelay));
                        newTransform.BeginAnimation(TranslateTransform.XProperty, MakeAnimation(startValue, startDelay),
                                                    HandoffBehavior.Compose);
                        startValue = lastRenderPosition.Y - arrangePosition.Y;
                        newTransform.BeginAnimation(TranslateTransform.YProperty,
                                                    MakeStaticAnimation(startValue, startDelay));
                        newTransform.BeginAnimation(TranslateTransform.YProperty, MakeAnimation(startValue, startDelay),
                                                    HandoffBehavior.Compose);

                        // Next element starts to move a little later
                        startDelay = startDelay.Add(CascadingDelay);
                    }
                }

                // Save off the previous arrange position				
                child.SetValue(SavedArrangePositionProperty, arrangePosition);
            }
            // currently WPF doesn't allow me to read a value right after the call to BeginAnimation
            // this code enables me to trick it and know whether I can trust the current position or not.
            _isAnimationValid = (int) GetValue(IsAnimationValidProperty) + 1;
            BeginAnimation(IsAnimationValidProperty,
                           new Int32Animation(_isAnimationValid, _isAnimationValid, new Duration(), FillBehavior.HoldEnd));
        }
开发者ID:jonbonne,项目名称:OCTGN,代码行数:58,代码来源:AnimatedWrapPanel.cs

示例5: AnimacjaRuchu

 /// <summary>
 /// Funkcja do animacji kropli wody
 /// </summary>
 /// <param name="target">Tutaj podajemy obiekt, który chcemy animować - w tym przypadku przesuwać wzdłuż osi X i Y</param>
 /// <param name="animacjaDo">Iterator węzła od którego zaczynamy animacje</param>
 /// <param name="animacjaOd">Iterator węzła do którego idzie animacja</param>
 private void AnimacjaRuchu(Image target, int animacjaDo,int animacjaOd)
 {
     double newX = wezel[animacjaDo].X - wezel[animacjaOd].X;
     double newY = wezel[animacjaDo].Y - wezel[animacjaOd].Y;
     TranslateTransform trans = new TranslateTransform();
     target.RenderTransform = trans;
     DoubleAnimation anim1 = new DoubleAnimation(newX, TimeSpan.FromSeconds(2));
     DoubleAnimation anim2 = new DoubleAnimation(newY, TimeSpan.FromSeconds(2));
     trans.BeginAnimation(TranslateTransform.XProperty, anim1);
     trans.BeginAnimation(TranslateTransform.YProperty, anim2);
 }
开发者ID:kademat,项目名称:Strategie-Zespolowe,代码行数:17,代码来源:MainWindow.xaml.cs

示例6: MoveTo

 public static void MoveTo(this Image target, double newX, double newY)
 {
     Vector offset = VisualTreeHelper.GetOffset(target);
     var top = offset.Y;
     var left = offset.X;
     TranslateTransform trans = new TranslateTransform();
     target.RenderTransform = trans;
     DoubleAnimation anim1 = new DoubleAnimation(0, newY - top, TimeSpan.FromSeconds(10));
     DoubleAnimation anim2 = new DoubleAnimation(0, newX - left, TimeSpan.FromSeconds(10));
     trans.BeginAnimation(TranslateTransform.YProperty, anim1);
     trans.BeginAnimation(TranslateTransform.XProperty, anim2);
 }
开发者ID:n0nick,项目名称:pewpew,代码行数:12,代码来源:Helper.cs

示例7: PanelLayoutUpdated

        /// <summary>
        /// Called when panel's layout is updated
        /// </summary>
        /// <remarks>
        /// Note: This is actually called when any layouts are updated
        /// </remarks>
        private void PanelLayoutUpdated(object sender, EventArgs e)
        {
            // At this point, the panel has moved the children to the new locations, but hasn't
            // been rendered
            foreach (UIElement child in _panel.Children)
            {
                // Figure out where child actually is right now. This is a combination of where the
                // panel put it and any render transform currently applied
                Point currentPosition = child.TransformToAncestor(_panel).Transform(new Point());

                // See what transform is being applied
                Transform currentTransform = child.RenderTransform;

                // Compute where the panel actually arranged it to
                Point arrangePosition = currentPosition;
                if (currentTransform != null)
                {
                    // Undo any transform we applied
                    arrangePosition = currentTransform.Inverse.Transform(arrangePosition);
                }

                // If we had previously stored an arrange position, see if it has moved
                if (child.ReadLocalValue(SavedArrangePositionProperty) != DependencyProperty.UnsetValue)
                {
                    Point savedArrangePosition = (Point)child.GetValue(SavedArrangePositionProperty);

                    // If the arrange position hasn't changed, then we've already set up animations, etc
                    // and don't need to do anything
                    if (!AreReallyClose(savedArrangePosition, arrangePosition))
                    {
                        // If we apply the current transform to the saved arrange position, we'll see where
                        // it was last rendered
                        Point lastRenderPosition = currentTransform.Transform(savedArrangePosition);

                        // Transform the child from the new location back to the old position
                        TranslateTransform newTransform = new TranslateTransform();
                        child.RenderTransform = newTransform;

                        // Decay the transformation with an animation
                        newTransform.BeginAnimation(TranslateTransform.XProperty, MakeAnimation(lastRenderPosition.X - arrangePosition.X));
                        newTransform.BeginAnimation(TranslateTransform.YProperty, MakeAnimation(lastRenderPosition.Y - arrangePosition.Y));
                    }
                }

                // Save off the previous arrange position
                child.SetValue(SavedArrangePositionProperty, arrangePosition);
            }
        }
开发者ID:huangjia2107,项目名称:MyControls,代码行数:54,代码来源:PanelLayoutAnimator.cs

示例8: LoadClick

        public void LoadClick(object sender, EventArgs e)
        {
            //MarkAllUiElementsWithTags(); //to delete it later

            var but = sender as Button;
            var move = new TranslateTransform(0, 0);
            var anim = new DoubleAnimation()
            {
                Duration = new Duration(TimeSpan.FromSeconds(0.7)),
                To = but.Margin.Left + Load.Width + 5,
                AccelerationRatio = 0.5,
            };
            anim.Completed += MoveToLoad;
            but.RenderTransform = move;
            move.BeginAnimation(TranslateTransform.XProperty, anim);

            var moveOther = new TranslateTransform(0, 0);
            var animOther = new DoubleAnimation()
            {
                Duration = new Duration(TimeSpan.FromSeconds(0.5)),
                To = -Create.Width - 5,
                AccelerationRatio = 0.5,
            };
            Create.RenderTransform = moveOther;
            moveOther.BeginAnimation(TranslateTransform.XProperty, animOther);
        }
开发者ID:ElGamzoGamingStudio,项目名称:DB-project,代码行数:26,代码来源:CreateLoadTreeDialog.xaml.cs

示例9: MoveCharacterPan

 public static void MoveCharacterPan(TranslateTransform transform, DependencyProperty propertyToPan, Double toValue)
 {
     if (transform != null)
     {
         UiThread.Execute(() =>
             transform.BeginAnimation(propertyToPan, GetMoveCharacterPanAnimation(toValue), HandoffBehavior.SnapshotAndReplace));
     }
 }
开发者ID:VOChris,项目名称:VOStudios,代码行数:8,代码来源:AnimationUtility.cs

示例10: BeginTransition

        protected internal override void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
        {
            TranslateTransform tt = new TranslateTransform(StartPoint.X * transitionElement.ActualWidth, StartPoint.Y * transitionElement.ActualHeight);

              if (IsNewContentTopmost)
            newContent.RenderTransform = tt;
              else
            oldContent.RenderTransform = tt;

              DoubleAnimation da = new DoubleAnimation(EndPoint.X * transitionElement.ActualWidth, Duration);
              tt.BeginAnimation(TranslateTransform.XProperty, da);

              da.To = EndPoint.Y * transitionElement.ActualHeight;
              da.Completed += delegate {
            EndTransition(transitionElement, oldContent, newContent);
              };
              tt.BeginAnimation(TranslateTransform.YProperty, da);
        }
开发者ID:edealbag,项目名称:bot,代码行数:18,代码来源:TranslateTransition.cs

示例11: ConfirmationLocalModalInteractionDialog_Loaded

		void ConfirmationLocalModalInteractionDialog_Loaded(object sender, RoutedEventArgs e)
		{
			DoubleAnimation doubleAnim = new DoubleAnimation(-460, 0,
				new Duration(new TimeSpan(0, 0, 0, 0, 200)));

			var trans = new TranslateTransform();
			this.RenderTransform = trans;

			trans.BeginAnimation(TranslateTransform.XProperty, doubleAnim);
		}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:10,代码来源:ConfirmationLocalModalInteractionDialog.xaml.cs

示例12: decreaseDigit

 private void decreaseDigit(TranslateTransform tf, TimeSpan time)
 {
     
     
     double newPos = tf.Y;
     newPos = newPos + resolutionPerNumber;
     DoubleAnimation animationTB1 = new DoubleAnimation(newPos, time);
     tf.BeginAnimation(TranslateTransform.YProperty, animationTB1);
    
 }
开发者ID:MehmetCagriK,项目名称:Sayac,代码行数:10,代码来源:MainWindow.xaml.cs

示例13: Grow

        public void Grow()
        {
            BringIntoView();
            const int mult = 10;
            const double duration = 0.1;
            RenderTransform = new TranslateTransform();
            var translateAnimation = new DoubleAnimation { From = 0, To = (-Width * mult / 2), Duration = TimeSpan.FromSeconds(duration), AutoReverse = true };
            RenderTransform.BeginAnimation(TranslateTransform.XProperty, translateAnimation);
            RenderTransform.BeginAnimation(TranslateTransform.YProperty, translateAnimation);
            Ellipse.RenderTransform = new ScaleTransform();
            var scaleAnimation = new DoubleAnimation { From = 1, To = mult, Duration = TimeSpan.FromSeconds(duration), AutoReverse = true };
            Ellipse.RenderTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            Ellipse.RenderTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);

            //(RadialGradientBrush)FindResource("RedGradient")
            //var colorTransform = new ColorAnimation {To = Colors.Red, Duration=TimeSpan.FromSeconds(0.1), AutoReverse= true};
            //var brush = (RadialGradientBrush)FindResource("RedGradient");
            //brush.BeginAnimation();
        }
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:19,代码来源:PlanetDrawing.xaml.cs

示例14: BeginAnimateContentReplacement

        /// <summary>
        /// Starts the animation for the new content
        /// </summary>
        private void BeginAnimateContentReplacement()
        {
            var newContentTransform = new TranslateTransform();
            var oldContentTransform = new TranslateTransform();
            m_paintArea.RenderTransform = oldContentTransform;
            m_mainContent.RenderTransform = newContentTransform;
            m_paintArea.Visibility = Visibility.Visible;

            newContentTransform.BeginAnimation(TranslateTransform.XProperty, CreateAnimation(this.ActualWidth, 0));
            oldContentTransform.BeginAnimation(TranslateTransform.XProperty, CreateAnimation(0, -this.ActualWidth, (s, e) => m_paintArea.Visibility = Visibility.Hidden));
        }
开发者ID:guipasmoi,项目名称:MangaTracker,代码行数:14,代码来源:AnimatedContentControl.cs

示例15: AnimateFirstBull

        private void AnimateFirstBull()
        {
            DoubleAnimation translate = new DoubleAnimation();
            translate.From = 0;
            translate.To = 110;
            translate.AutoReverse = false;
            translate.Duration = new Duration(TimeSpan.FromSeconds(1.300));

            TranslateTransform tt = new TranslateTransform();
            bull.RenderTransform = tt;
            tt.BeginAnimation(TranslateTransform.YProperty, translate);
        }
开发者ID:D3A7H13,项目名称:Team-baldinvestir,代码行数:12,代码来源:MainWindow.xaml.cs


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