當前位置: 首頁>>代碼示例>>C#>>正文


C# ScaleTransform.BeginAnimation方法代碼示例

本文整理匯總了C#中System.Windows.Media.ScaleTransform.BeginAnimation方法的典型用法代碼示例。如果您正苦於以下問題:C# ScaleTransform.BeginAnimation方法的具體用法?C# ScaleTransform.BeginAnimation怎麽用?C# ScaleTransform.BeginAnimation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Media.ScaleTransform的用法示例。


在下文中一共展示了ScaleTransform.BeginAnimation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ParkHotelExplorer

        public static void ParkHotelExplorer(bool restore, double width, Canvas canvas, double top, double left, double scale, double rotate)
        {
            _canvas = canvas;
            var hotelExplorer = HotelExplorer.GetInstance();
            hotelExplorer.IsFloating = !restore;
            hotelExplorer.HightLight(!restore);
            var ypos = restore ? top : Canvas.GetTop(hotelExplorer);
            var xpos = restore ? width - left - (hotelExplorer.ActualWidth * scale) : Canvas.GetLeft(hotelExplorer);
            var yTo = restore ? 55 : top;
            var xTo = restore ? 55 : width - left - (hotelExplorer.ActualWidth / scale);
            var zoomFrom = restore ? scale : 1;
            var zoomTo = restore ? 1 : scale;
            var rotateFrom = restore ? rotate : 0;
            var rotateTo = restore ? 0 : rotate;
            var yAnimation = new DoubleAnimation
                                 {
                                     From = ypos,
                                     To = yTo,
                                     Duration = new Duration(TimeSpan.FromMilliseconds(500))
                                 };
            var xAnimation = new DoubleAnimation
                                 {
                                     From = xpos,
                                     To = xTo,
                                     Duration = new Duration(TimeSpan.FromMilliseconds(1000))
                                 };

            hotelExplorer.BeginAnimation(Canvas.TopProperty, yAnimation);
            hotelExplorer.BeginAnimation(Canvas.LeftProperty, xAnimation);

            var zoom = new DoubleAnimation
                           {
                               From = zoomFrom,
                               To = zoomTo,
                               BeginTime = TimeSpan.FromMilliseconds(0),
                               Duration = new Duration(TimeSpan.FromMilliseconds(1000))
                           };

            var rotateAnimation = new DoubleAnimation
                             {
                                 From = rotateFrom,
                                 To = rotateTo,
                                 BeginTime = TimeSpan.FromMilliseconds(0),
                                 Duration = new Duration(TimeSpan.FromMilliseconds(1000))
                             };

            zoom.Completed += HotelZoomCompleted;

            var st = new ScaleTransform();
            var rt = new RotateTransform(rotateTo, 0, 0);

            var group = new TransformGroup();
            group.Children.Add(st);
            group.Children.Add(rt);

            hotelExplorer.Container.WorkingObject.RenderTransform = group;
            st.BeginAnimation(ScaleTransform.ScaleXProperty, zoom);
            st.BeginAnimation(ScaleTransform.ScaleYProperty, zoom);
            st.BeginAnimation(RotateTransform.AngleProperty, rotateAnimation);
        }
開發者ID:realsaraf,項目名稱:eConcierge,代碼行數:60,代碼來源:AnimationHelper.cs

示例2: OnVisualChildrenChanged

 protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
 {
     base.OnVisualChildrenChanged(visualAdded, visualRemoved);
     if (visualAdded != null)
     {
         var child = (ContentPresenter)visualAdded;
         if (((Card)child.DataContext).Controller != Player.LocalPlayer)
         {
             var scale = new ScaleTransform();
             child.RenderTransformOrigin = new Point(0.5, 0.5);
             child.RenderTransform = scale;
             var anim = new DoubleAnimation()
             {
                 Duration = new Duration(TimeSpan.FromMilliseconds(400)),
                 AutoReverse = true,
                 RepeatBehavior = new RepeatBehavior(2.166),
                 AccelerationRatio = 0.2,
                 DecelerationRatio = 0.7,
                 To = 1.2, From = 0.9,
                 FillBehavior = FillBehavior.Stop
             };
             scale.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
             scale.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
         }
     }
 }
開發者ID:kellyelton,項目名稱:octgnwlobby,代碼行數:26,代碼來源:TableCanvas.cs

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

示例4: UserControl_Loaded_1

 private void UserControl_Loaded_1(object sender, RoutedEventArgs e)
 {
     ScaleTransform st = new ScaleTransform(1, 1);
     DoubleAnimation cartoonClear = new DoubleAnimation(0.1, 1, new Duration(TimeSpan.FromMilliseconds(500)));
     this.RenderTransform = st;
     st.BeginAnimation(ScaleTransform.ScaleYProperty, cartoonClear);
     st.BeginAnimation(ScaleTransform.ScaleXProperty, cartoonClear);
 }
開發者ID:shew990,項目名稱:github,代碼行數:8,代碼來源:FormworkMainView.xaml.cs

示例5: Wipe

        public void Wipe(TransitionerSlide fromSlide, TransitionerSlide toSlide, Point origin, IZIndexController zIndexController)
        {
            if (fromSlide == null) throw new ArgumentNullException(nameof(fromSlide));
            if (toSlide == null) throw new ArgumentNullException(nameof(toSlide));
            if (zIndexController == null) throw new ArgumentNullException(nameof(zIndexController));

            var horizontalProportion = Math.Max(1.0 - origin.X, 1.0 * origin.X);
            var verticalProportion = Math.Max(1.0 - origin.Y, 1.0 * origin.Y);
            var radius = Math.Sqrt(Math.Pow(toSlide.ActualWidth * horizontalProportion, 2) + Math.Pow(toSlide.ActualHeight * verticalProportion, 2));

            var scaleTransform = new ScaleTransform(0, 0);
            var translateTransform = new TranslateTransform(toSlide.ActualWidth * origin.X, toSlide.ActualHeight * origin.Y);
            var transformGroup = new TransformGroup();
            transformGroup.Children.Add(scaleTransform);
            transformGroup.Children.Add(translateTransform);
            var ellipseGeomotry = new EllipseGeometry()
            {
                RadiusX = radius,
                RadiusY = radius,
                Transform = transformGroup
            };
            
            toSlide.SetCurrentValue(UIElement.ClipProperty, ellipseGeomotry);            
            zIndexController.Stack(toSlide, fromSlide);

            var zeroKeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero);
            var midKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200));
            var endKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400));

            var opacityAnimation = new DoubleAnimationUsingKeyFrames();
            opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, zeroKeyTime));
            opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, midKeyTime));
            opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, endKeyTime));
            opacityAnimation.Completed += (sender, args) =>
            {
                fromSlide.BeginAnimation(UIElement.OpacityProperty, null);
                fromSlide.Opacity = 0;
            };
            fromSlide.BeginAnimation(UIElement.OpacityProperty, opacityAnimation);

            var scaleAnimation = new DoubleAnimationUsingKeyFrames();
            scaleAnimation.Completed  += (sender, args) =>
            {
                toSlide.SetCurrentValue(UIElement.ClipProperty, null);
                fromSlide.BeginAnimation(UIElement.OpacityProperty, null);
                fromSlide.Opacity = 0;
            };
            scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, zeroKeyTime));
            scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, endKeyTime));
            scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
        }
開發者ID:Chandu-cuddle,項目名稱:MaterialDesignInXamlToolkit,代碼行數:52,代碼來源:CircleWipe.cs

示例6: gdMain_MouseDown

 void gdMain_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (click != null)
     {
         DoubleAnimation da = new DoubleAnimation(1.0, 0.95, TimeSpan.FromMilliseconds(50));
         da.AutoReverse = true;
         ScaleTransform rt = new ScaleTransform();
         this.RenderTransformOrigin = new Point(0.5, 0.5);
         this.RenderTransform = rt;
         rt.BeginAnimation(ScaleTransform.ScaleXProperty, da);
         rt.BeginAnimation(ScaleTransform.ScaleYProperty, da);
         click(this, null);
     }
 }
開發者ID:voxPopuli92,項目名稱:ViserInformator,代碼行數:14,代碼來源:btnDugmeTemp.xaml.cs

示例7: _BeginAnimateContentReplacement

        private void _BeginAnimateContentReplacement()
        {
            var flapTransformTop = new ScaleTransform { CenterY = _rectangleTop.ActualHeight / 2 };
            _rectangleTop.RenderTransform = flapTransformTop;

            var flapTransformBottom = new ScaleTransform { CenterY = _rectangleBottom.ActualHeight / 2 };
            _rectangleBottom.RenderTransform = flapTransformBottom;

            _rectangleTop.Visibility = Visibility.Visible;
            _rectangleBottom.Visibility = Visibility.Visible;
            _rectangleBottomStatic.Visibility = Visibility.Visible;

            IEasingFunction ease = null;//new BackEase() { EasingMode = EasingMode.EaseOut };

            AnimationTimeline animationTop = AnimateLib.CreateAnimation(1, 0, 0, 0.1, null, (object s, EventArgs e) =>
            {
                _rectangleTop.Visibility = Visibility.Hidden;
                _rectangleBottom.Visibility = Visibility.Visible;
                _rectangleBottom.Fill = AnimateLib.CreateBrushFromVisual(_displayBottom, (int)_rectangleBottom.ActualWidth, (int)_rectangleBottom.ActualHeight);
            });

            AnimationTimeline animationBottom = AnimateLib.CreateAnimation(0, 1, 0.1, 0.1, ease, (object s, EventArgs e) =>
            {
                _rectangleBottom.Visibility = Visibility.Hidden;
                _rectangleBottomStatic.Visibility = Visibility.Hidden;
            });

            flapTransformTop.BeginAnimation(ScaleTransform.ScaleYProperty, animationTop, HandoffBehavior.SnapshotAndReplace);
            flapTransformBottom.BeginAnimation(ScaleTransform.ScaleYProperty, animationBottom, HandoffBehavior.SnapshotAndReplace);
        }
開發者ID:CodefoundryDE,項目名稱:ViennaTrafficMonitor,代碼行數:30,代碼來源:SplitFlapPanel.cs

示例8: HideInfoBar

        private void HideInfoBar()
        {
            DoubleAnimation dbaOpacity = new DoubleAnimation(0, durationCommon);
            dbaOpacity.Completed += (o, e) =>
            {
                bdrInfo.Visibility = Visibility.Collapsed;
            };

            DoubleAnimation dbaScale = new DoubleAnimation(0.95, durationCommon);
            dbaScale.DecelerationRatio = 1;
            ScaleTransform scaleTransform = new ScaleTransform();
            bdrInfo.RenderTransform = scaleTransform;

            bdrInfo.BeginAnimation(Border.OpacityProperty, dbaOpacity);
            scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, dbaScale);
            scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, dbaScale);
        }
開發者ID:ysmood,項目名稱:Comisor,代碼行數:17,代碼來源:ViewerInfoBar.cs

示例9: Wipe

        public void Wipe(TransitionerSlide fromSlide, TransitionerSlide toSlide, Point origin, IZIndexController zIndexController)
        {
            if (fromSlide == null) throw new ArgumentNullException(nameof(fromSlide));
            if (toSlide == null) throw new ArgumentNullException(nameof(toSlide));
            if (zIndexController == null) throw new ArgumentNullException(nameof(zIndexController));

            var zeroKeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero);
            var midishKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200));
            var endKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400));

            //back out old slide setup
            var scaleTransform = new ScaleTransform(1, 1);
            fromSlide.RenderTransform = scaleTransform;
            var scaleAnimation = new DoubleAnimationUsingKeyFrames();
            scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, zeroKeyTime));
            scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(.8, endKeyTime));
            scaleAnimation.Completed += (sender, args) =>
            {
                fromSlide.RenderTransform = null;                             
            };
            var opacityAnimation = new DoubleAnimationUsingKeyFrames();
            opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, zeroKeyTime));
            opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, endKeyTime));
            opacityAnimation.Completed += (sender, args) =>
            {
                fromSlide.BeginAnimation(UIElement.OpacityProperty, null);
                fromSlide.Opacity = 0;
            };

            //slide in new slide setup
            var translateTransform = new TranslateTransform(0, toSlide.ActualHeight);
            toSlide.RenderTransform = translateTransform;            
            var slideAnimation = new DoubleAnimationUsingKeyFrames();
            slideAnimation.KeyFrames.Add(new LinearDoubleKeyFrame(toSlide.ActualHeight, zeroKeyTime));
            slideAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(toSlide.ActualHeight, midishKeyTime) { EasingFunction = _sineEase});
            slideAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, endKeyTime) { EasingFunction = _sineEase });

            //kick off!
            translateTransform.BeginAnimation(TranslateTransform.YProperty, slideAnimation);
            scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);            
            scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
            fromSlide.BeginAnimation(UIElement.OpacityProperty, opacityAnimation);

            zIndexController.Stack(toSlide, fromSlide);
        }
開發者ID:flying19880517,項目名稱:MaterialDesignInXamlToolkit,代碼行數:45,代碼來源:SlideOutWipe.cs

示例10: ShowDice

        public void ShowDice(Dice dice)
        {
            Rectangle rect = new Rectangle()
            {
                Fill = new SolidColorBrush(Color.FromArgb(192, 255, 255, 255)),
                Stroke = new SolidColorBrush(dice.DiceColor == DiceColor.Red ? Colors.DarkRed : Colors.Black),
                Width = 50,
                Height = 50,
            };

            mainCanvas.Children.Add(rect);
            Canvas.SetLeft(rect, dice.Position.X - 25);
            Canvas.SetTop(rect, dice.Position.Y - 25);

            ScaleTransform trans = new ScaleTransform(1.0, 1.0, 25, 25);
            rect.RenderTransform = trans;

            DoubleAnimation anim = new DoubleAnimation(10.0, 1.0, new Duration(TimeSpan.FromSeconds(0.25)));
            trans.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
            trans.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
        }
開發者ID:UCSD-HCI,項目名稱:RiskBoardGameApp,代碼行數:21,代碼來源:DiceViz.xaml.cs

示例11: HidePopup

        private void HidePopup()
        {
            if (bdrPopup.Visibility != Visibility.Visible) return;

            DoubleAnimation dbaScale = new DoubleAnimation(1, 0.8, durationCommon + durationCommon);
            dbaScale.AccelerationRatio = 1;

            DoubleAnimation dbaOpacity = new DoubleAnimation(0, durationCommon + durationCommon);
            // 防止它捕捉到鼠標
            dbaOpacity.Completed += (o, e) =>
            {
                cavStage.MouseMove -= Popup_FollowMouse;
                bdrPopup.Visibility = Visibility.Collapsed;
            };

            bdrPopup.BeginAnimation(Border.OpacityProperty, dbaOpacity);

            ScaleTransform scaleTransform = new ScaleTransform();
            bdrPopup.RenderTransform = scaleTransform;
            scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, dbaScale);
            scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, dbaScale);
        }
開發者ID:ysmood,項目名稱:Comisor,代碼行數:22,代碼來源:ViewerInfoBar.cs

示例12: OnVisualParentChanged

        protected override void OnVisualParentChanged(DependencyObject oldParent)
        {
            base.OnVisualParentChanged(oldParent);

            if (oldParent == null || oldParent as ContentPresenter != null)
            {
                DoubleAnimation animation = new DoubleAnimation()
                {
                    From = 0,
                    To = 1,
                    Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500)),
                    EasingFunction = new QuadraticEase()
                };

                Point origin = new Point();

                switch (Dock)
                {
                    case Dock.Left:
                        origin.X = 0.0d;
                        origin.Y = 0.0d;
                        break;
                    case Dock.Right:
                        origin.X = 1.0d;
                        origin.Y = 0.0d;
                        break;
                    case Dock.Bottom:
                        throw new NotSupportedException();
                    case Dock.Top:
                        throw new NotSupportedException();
                    default:
                        origin.X = 0.0d;
                        origin.Y = 0.0d;
                        break;
                }

                RenderTransformOrigin = origin;

                RenderTransform = new ScaleTransform();
                RenderTransform.BeginAnimation(ScaleTransform.ScaleXProperty, animation);
            }
        }
開發者ID:Dustin-Howell,項目名稱:Capstone,代碼行數:42,代碼來源:SlideOutControl.cs

示例13: BeginPulsatingAnimation

      /// <summary>Begins a pulsating effect with the specified parameters.</summary>
      /// <param name="element">The element over which to apply the effect.</param>
      /// <param name="period">The effect period.</param>
      /// <param name="rotation">The horizontal rotation span.</param>
      /// <param name="translation">The vertical translation span.</param>
      public static void BeginPulsatingAnimation(UIElement element, TimeSpan period, double rotation, double translation) {
         if (element == null) return;
         StopPulsatingAnimation(element);

         var rnd = _pulsatingAnimationRandomizer;
         var dur = period.TotalSeconds * (5);

         var tx1 = new ScaleTransform();
         var anim1 = new DoubleAnimation {
            From = 0.975,
            To = 1.025,
            BeginTime = TimeSpan.FromSeconds(dur * rnd.NextDouble() - dur / 2),
            Duration = new Duration(TimeSpan.FromSeconds(dur)),
            AutoReverse = true,
            RepeatBehavior = RepeatBehavior.Forever
         };
         tx1.BeginAnimation(ScaleTransform.ScaleXProperty, anim1);

         var tx2 = new ScaleTransform();
         var anim2 = new DoubleAnimation {
            From = 0.975,
            To = 1.025,
            BeginTime = TimeSpan.FromSeconds(dur * rnd.NextDouble() - dur / 2),
            Duration = new Duration(TimeSpan.FromSeconds(dur)),
            AutoReverse = true,
            RepeatBehavior = RepeatBehavior.Forever
         };
         tx2.BeginAnimation(ScaleTransform.ScaleYProperty, anim1);

         var tg = new TransformGroup();
         tg.Children.Add(tx1);
         tg.Children.Add(tx2);

         element.RenderTransform = tg;
         element.RenderTransformOrigin = new Point(0.5, 0.5);
      }
開發者ID:borkaborka,項目名稱:gmit,代碼行數:41,代碼來源:StockEffects.cs

示例14: FlipCardRectangle

        private void FlipCardRectangle(Rectangle cardRectangle, int from, int to)
        {
            cardRectangle.RenderTransformOrigin = new Point(0.5, 0.5);
            ScaleTransform flipTrans = new ScaleTransform();
            flipTrans.ScaleY = 1;
            cardRectangle.RenderTransform = flipTrans;

            DoubleAnimation da = new DoubleAnimation();
            da.From = from;
            da.To = to;
            da.Duration = TimeSpan.FromMilliseconds(200);

            flipTrans.BeginAnimation(ScaleTransform.ScaleYProperty, da);
        }
開發者ID:sbjornell,項目名稱:MemoryV.5,代碼行數:14,代碼來源:GameController.cs

示例15: AnimateNewPerson

        /// <summary>
        /// Animate the new person that was added to the diagram.
        /// </summary>
        private void AnimateNewPerson()
        {
            // The new person is optional, can be null.
            if (newPerson == null)
                return;

            // Get the UI element to animate.                
            DiagramNode node = logic.GetDiagramNode(newPerson);
            if (node != null)
            {
                // Create the new person animation.
                DoubleAnimation anim = new DoubleAnimation(0, 1,
                    App.GetAnimationDuration(Const.NewPersonAnimationDuration));

                // Animate the node.
                ScaleTransform transform = new ScaleTransform();
                transform.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
                transform.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
                node.RenderTransform = transform;
            }

            newPerson = null;
        }
開發者ID:ssickles,項目名稱:archive,代碼行數:26,代碼來源:Diagram.cs


注:本文中的System.Windows.Media.ScaleTransform.BeginAnimation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。