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


C# TranslateTransform3D.BeginAnimation方法代碼示例

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


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

示例1: MoveTo3D

        /// <summary>
        /// Move icon to position
        /// </summary>
        /// <param name="point"></param>
        public void MoveTo3D(Point point3d, Point point, int _positionOnPile)
        {
            if (State != StateEnum.Pile)
            {
                int speed = 250;
                PositionOnPile = _positionOnPile;
                LocationSave = Location;

                Location = new Point(point.X - ImageIcon.Width + (PositionOnPile*3),
                                     point.Y - ImageIcon.Height - (PositionOnPile*3));
                ImageIcon.Margin = new Thickness(Location.X, Location.Y, 0, 0);
                Label.Visibility = Visibility.Hidden;
                Label.Margin = new Thickness(Location.X - 20, Location.Y + ImageIcon.Height, 0, 0);
                State = StateEnum.Pile;

                newPosition = new Point3D(point3d.X, 0.5 + (5*_positionOnPile), point3d.Y);
                Vector3D computedPos = newPosition - location3d;

                //TranslateTransform3D trans = new TranslateTransform3D(computedPos);
                //_desktopGroundIcon.Transform = trans;

                Transform3DGroup transGroup = new Transform3DGroup();
                Transform3D transform = new TranslateTransform3D(computedPos);
                transGroup.Children.Add(transform);
                _desktopGroundIcon.Transform = transGroup;

                DoubleAnimation AnimationX = new DoubleAnimation();
                AnimationX.From = 0;
                AnimationX.To = computedPos.X;
                AnimationX.Duration = new Duration(TimeSpan.FromMilliseconds(speed));
                transform.BeginAnimation(TranslateTransform3D.OffsetXProperty, AnimationX);

                DoubleAnimation AnimationY = new DoubleAnimation();
                AnimationY.From = 0;
                AnimationY.To = computedPos.Y;
                AnimationY.Duration = new Duration(TimeSpan.FromMilliseconds(speed));
                transform.BeginAnimation(TranslateTransform3D.OffsetYProperty, AnimationY);

                DoubleAnimation AnimationZ = new DoubleAnimation();
                AnimationZ.From = 0;
                AnimationZ.To = computedPos.Z;
                AnimationZ.Duration = new Duration(TimeSpan.FromMilliseconds(speed));
                transform.BeginAnimation(TranslateTransform3D.OffsetZProperty, AnimationZ);

                Timer timer = new Timer();
                timer.Interval = speed;
                timer.Tick += new EventHandler(timer_Tick);
                timer.Start();
            }
        }
開發者ID:jefflequeux,項目名稱:DarkangeUtils,代碼行數:54,代碼來源:DesktopIcon.cs

示例2: BeginTransition3D

        protected override void BeginTransition3D(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent, Viewport3D viewport)
        {
            Size size = transitionElement.RenderSize;

            Point3D origin = new Point3D(); // origin of 2nd face
            Vector3D u = new Vector3D(), v = new Vector3D(); // u & v vectors of 2nd face

            double angle = Angle;
            Point3D rotationCenter;
            Vector3D rotationAxis;
            RotateDirection direction = Direction;

            TranslateTransform3D translation = null;
            double angleRads = Angle * Math.PI / 180;
            if (direction == RotateDirection.Left || direction == RotateDirection.Right)
            {
                if (Contained)
                {
                    rotationCenter = new Point3D(direction == RotateDirection.Left ? size.Width : 0, 0, 0);
                    translation = new TranslateTransform3D();
                    DoubleAnimation x = new DoubleAnimation(direction == RotateDirection.Left ? -size.Width : size.Width, Duration);
                    translation.BeginAnimation(TranslateTransform3D.OffsetXProperty, x);
                }
                else
                {
                    rotationCenter = new Point3D(size.Width / 2, 0, size.Width / 2 * Math.Tan(angle / 2 * Math.PI / 180));
                }

                rotationAxis = new Vector3D(0, 1, 0);

                if (direction == RotateDirection.Left)
                {
                    u.X = -size.Width * Math.Cos(angleRads);
                    u.Z = size.Width * Math.Sin(angleRads);

                    origin.X = size.Width;
                }
                else
                {
                    u.X = -size.Width * Math.Cos(angleRads);
                    u.Z = -size.Width * Math.Sin(angleRads);

                    origin.X = -u.X;
                    origin.Z = -u.Z;
                }
                v.Y = size.Height;
            }
            else
            {
                if (Contained)
                {
                    rotationCenter = new Point3D(0, direction == RotateDirection.Up ? size.Height : 0, 0);
                    translation = new TranslateTransform3D();
                    DoubleAnimation y = new DoubleAnimation(direction == RotateDirection.Up ? -size.Height : size.Height, Duration);
                    translation.BeginAnimation(TranslateTransform3D.OffsetYProperty, y);
                }
                else
                {
                    rotationCenter = new Point3D(0, size.Height / 2, size.Height / 2 * Math.Tan(angle / 2 * Math.PI / 180));
                }

                rotationAxis = new Vector3D(1, 0, 0);

                if (direction == RotateDirection.Up)
                {
                    v.Y = -size.Height * Math.Cos(angleRads);
                    v.Z = size.Height * Math.Sin(angleRads);

                    origin.Y = size.Height;
                }
                else
                {
                    v.Y = -size.Height * Math.Cos(angleRads);
                    v.Z = -size.Height * Math.Sin(angleRads);

                    origin.Y = -v.Y;
                    origin.Z = -v.Z;
                }
                u.X = size.Width;
            }

            double endAngle = 180 - angle;
            if (direction == RotateDirection.Right || direction == RotateDirection.Up)
                endAngle = -endAngle;

            ModelVisual3D m1, m2;
            viewport.Children.Add(m1 = MakeSide(oldContent, new Point3D(), new Vector3D(size.Width, 0, 0), new Vector3D(0, size.Height, 0), endAngle, rotationCenter, rotationAxis, null));
            viewport.Children.Add(m2 = MakeSide(newContent, origin, u, v, endAngle, rotationCenter, rotationAxis, delegate
            {
                EndTransition(transitionElement, oldContent, newContent);
            }));

            m1.Transform = m2.Transform = translation;
        }
開發者ID:hungdluit,項目名稱:bot,代碼行數:94,代碼來源:RotateTransition.cs

示例3: ExplodeMoveTo3D

        public void ExplodeMoveTo3D()
        {
            int speed = 250;
            Vector3D computedPos = location3d - location3dSave;
            Location = LocationSave;

            Transform3DGroup transGroup = new Transform3DGroup();
            Transform3D transform = new TranslateTransform3D(computedPos);
            transGroup.Children.Add(transform);
            _desktopGroundIcon.Transform = transGroup;

            DoubleAnimation AnimationX = new DoubleAnimation();
            AnimationX.From = computedPos.X;
            AnimationX.To = 0;
            AnimationX.Duration = new Duration(TimeSpan.FromMilliseconds(speed));
            transform.BeginAnimation(TranslateTransform3D.OffsetXProperty, AnimationX);

            DoubleAnimation AnimationY = new DoubleAnimation();
            AnimationY.From = computedPos.Y;
            AnimationY.To = 0;
            AnimationY.Duration = new Duration(TimeSpan.FromMilliseconds(speed));
            transform.BeginAnimation(TranslateTransform3D.OffsetYProperty, AnimationY);

            DoubleAnimation AnimationZ = new DoubleAnimation();
            AnimationZ.From = computedPos.Z;
            AnimationZ.To = 0;
            AnimationZ.Duration = new Duration(TimeSpan.FromMilliseconds(speed));
            transform.BeginAnimation(TranslateTransform3D.OffsetZProperty, AnimationZ);

            Timer timer = new Timer();
            timer.Interval = speed;
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();

            State = StateEnum.None;
            PileId = -1;
        }
開發者ID:jefflequeux,項目名稱:DarkangeUtils,代碼行數:37,代碼來源:DesktopIcon.cs

示例4: MoveIt

        public void MoveIt(ServicePlatformElement source, ServiceInspectorStation destination, TimeSpan duration, int p)
        {
            duration = TimeSpan.FromSeconds(duration.TotalSeconds*GlobalTimeScale);

            LastActivity = "C->Ins";
            ServiceBoxElement box = source.ServiceBox;
            source.ServiceBox = null;
            source.Status = StationStatus.Empty;
            int qLen = destination.GetQueueLen;
            double srcX = box.Transformer.OffsetX;
            const double destenX = 16;
            double srcY = box.Transformer.OffsetY;

            double destenY = 0;

            if (p == 0)
            {
                destenY = 10 + (5*qLen);
                destination.PushBoxToQueue(box);
            }
            else if (p == 1)
            {
                destenY = 3;
                destination.Inspector1Box = box;
            }
            else if (p == 2)
            {
                destenY = -3;
                destination.Inspector2Box = box;
            }

            var daX = new DoubleAnimation {From = srcX, To = destenX, Duration = new Duration(duration)};
            var daY = new DoubleAnimation {From = srcY, To = destenY, Duration = new Duration(duration)};
            var newTransformer = new TranslateTransform3D(box.Transformer.OffsetX, box.Transformer.OffsetY, 2.1);
            box.Transform = newTransformer;
            box.Transformer = newTransformer;
            newTransformer.BeginAnimation(TranslateTransform3D.OffsetXProperty, daX);
            newTransformer.BeginAnimation(TranslateTransform3D.OffsetYProperty, daY);

            var robotTransform = new TranslateTransform3D(box.Transformer.OffsetX, box.Transformer.OffsetY, 0);
            World.Instance.MotherRobot.Transform = robotTransform;
            robotTransform.BeginAnimation(TranslateTransform3D.OffsetXProperty, daX);
            robotTransform.BeginAnimation(TranslateTransform3D.OffsetYProperty, daY);
        }
開發者ID:taesiri,項目名稱:Simulation,代碼行數:44,代碼來源:Robot.cs

示例5: GetModelTransforms

        Transform3DGroup GetModelTransforms(int index)
        {
            Transform3DGroup group = new Transform3DGroup();
            RotateTransform3D rotation = new RotateTransform3D();
            TranslateTransform3D tran = new TranslateTransform3D();

            tran.BeginAnimation(TranslateTransform3D.OffsetXProperty, null);
            tran.BeginAnimation(TranslateTransform3D.OffsetYProperty, null);
            tran.BeginAnimation(TranslateTransform3D.OffsetZProperty, null);

            var offsets = new Vector3D();

            this.CalculatePeiceLocation(index, out offsets, out rotation);

            tran.OffsetX = offsets.X;
            tran.OffsetY = offsets.Y;
            tran.OffsetZ = offsets.Z;

            group.Children.Add(tran);
            group.Children.Add(rotation);
            return group;
        }
開發者ID:dingxinbei,項目名稱:OLdBck,代碼行數:22,代碼來源:V3D.cs

示例6: BeginTransition

      /// <summary/>
      protected override void BeginTransition(TransitionEventArgs e) {
         var viewport = AddViewport3D(e);
         var panel = (TransitionPanel)e.Source;
         var size = panel.RenderSize;

         Point3D origin = new Point3D(); // origin of 2nd face
         Vector3D u = new Vector3D(), v = new Vector3D(); // u & v vectors of 2nd face

         double angleRads = Angle.ToRadians();
         double halfAngleRads = (Angle / 2).ToRadians();
         Point3D rotationCenter;
         Vector3D rotationAxis;

         TranslateTransform3D translation = null;
         if (Direction.IsHorizontal()) {
            var RTL = (Direction == MoveDirection.Left);
            if (IsContained) {
               rotationCenter = new Point3D(RTL ? size.Width : 0, 0, 0);
               translation = new TranslateTransform3D();
               DoubleAnimation x = new DoubleAnimation(RTL ? -size.Width : size.Width, Duration);
               translation.BeginAnimation(TranslateTransform3D.OffsetXProperty, x);
            } else {
               rotationCenter = new Point3D(size.Width / 2, 0, size.Width / 2 * Math.Tan(halfAngleRads));
            }

            rotationAxis = new Vector3D(0, 1, 0);

            if (RTL) {
               u.X = -size.Width * Math.Cos(angleRads);
               u.Z = size.Width * Math.Sin(angleRads);
               origin.X = size.Width;
            } else {
               u.X = -size.Width * Math.Cos(angleRads);
               u.Z = -size.Width * Math.Sin(angleRads);
               origin.X = -u.X;
               origin.Z = -u.Z;
            }
            v.Y = size.Height;
         } else {
            var BTT = (Direction == MoveDirection.Up);
            if (IsContained) {
               rotationCenter = new Point3D(0, BTT ? size.Height : 0, 0);
               translation = new TranslateTransform3D();
               DoubleAnimation y = new DoubleAnimation(BTT ? -size.Height : size.Height, Duration);
               translation.BeginAnimation(TranslateTransform3D.OffsetYProperty, y);
            } else {
               rotationCenter = new Point3D(0, size.Height / 2, size.Height / 2 * Math.Tan(halfAngleRads));
            }

            rotationAxis = new Vector3D(1, 0, 0);

            if (BTT) {
               v.Y = -size.Height * Math.Cos(angleRads);
               v.Z = size.Height * Math.Sin(angleRads);
               origin.Y = size.Height;
            } else {
               v.Y = -size.Height * Math.Cos(angleRads);
               v.Z = -size.Height * Math.Sin(angleRads);
               origin.Y = -v.Y;
               origin.Z = -v.Z;
            }
            u.X = size.Width;
         }

         double endAngle = 180 - Angle;
         if (Direction == MoveDirection.Right || Direction == MoveDirection.Up) {
            endAngle = -endAngle;
         }

         var m1 = _createSide(e, e.BackSnapshot, new Point3D(), new Vector3D(size.Width, 0, 0), new Vector3D(0, size.Height, 0), endAngle, rotationCenter, rotationAxis);
         var m2 = _createSide(e, e.FrontSnapshot, origin, u, v, endAngle, rotationCenter, rotationAxis);
         viewport.Children.Add(m1);
         viewport.Children.Add(m2);
         m1.Transform = m2.Transform = translation;
      }
開發者ID:borkaborka,項目名稱:gmit,代碼行數:76,代碼來源:CubeTransition3D.cs

示例7: Unfocus

        internal void Unfocus()
        {
            if (_IsFocused)
            {
                Transform3DGroup t3dg = null;
                if (_Geometry.Transform == null)
                {
                    t3dg = new Transform3DGroup();
                    _Geometry.Transform = t3dg;
                }
                else
                    t3dg = _Geometry.Transform as Transform3DGroup;

                TranslateTransform3D tt = new TranslateTransform3D(0, 0, 0);
                t3dg.Children.Add(tt);
                DoubleAnimation da = new DoubleAnimation(2, _HighlightDuration);
                tt.BeginAnimation(TranslateTransform3D.OffsetZProperty, da);
                _IsFocused = false;
            }
        }
開發者ID:dingxinbei,項目名稱:OLdBck,代碼行數:20,代碼來源:PiePiece.cs

示例8: Do3DAnimation

        private void Do3DAnimation(GradientBall ball, Point3D nextPosition)
        {
            Action animation = () =>
            {
                var speed = new Duration(new TimeSpan(0, 0, 3));
                Point3D currentPosition = ball.Offset;

                var animationX = new DoubleAnimation(currentPosition.X, nextPosition.X, speed);
                var animationY = new DoubleAnimation(currentPosition.Y, nextPosition.Y, speed);
                var animationZ = new DoubleAnimation(currentPosition.Z, nextPosition.Z, speed);

                var tt3D = new TranslateTransform3D(currentPosition.X, currentPosition.Y, currentPosition.Z);
                ball.Transform = tt3D;
                tt3D.BeginAnimation(TranslateTransform3D.OffsetXProperty, animationX);
                tt3D.BeginAnimation(TranslateTransform3D.OffsetYProperty, animationY);
                tt3D.BeginAnimation(TranslateTransform3D.OffsetZProperty, animationZ);
            };
            ball.Dispatcher.BeginInvoke(DispatcherPriority.Send, animation);
        }
開發者ID:atosorigin,項目名稱:Kinect,代碼行數:19,代碼來源:MainWindow.xaml.cs

示例9: TorusSet


//.........這裏部分代碼省略.........
                                         break;
                                     }
                                 case 2:
                                     {
                                         thorus = Torus_007;
                                         tor = Torus_007Container;
                                         break;
                                     }
                                 case 3:
                                     {
                                         thorus = Torus_008;
                                         tor = Torus_008Container;
                                         break;
                                     }
                             }
                             break;
                         }
                     case 2:
                         {
                             switch (y)
                             {
                                 case 0:
                                     {
                                         thorus = Torus_009;
                                         tor = Torus_009Container;
                                         break;
                                     }
                                 case 1:
                                     {
                                         thorus = Torus_010;
                                         tor = Torus_010Container;
                                         break;
                                     }
                                 case 2:
                                     {
                                         thorus = Torus_011;
                                         tor = Torus_011Container;
                                         break;
                                     }
                                 case 3:
                                     {
                                         thorus = Torus_012;
                                         tor = Torus_012Container;
                                         break;
                                     }
                             }
                             break;
                         }
                     case 3:
                         {
                             switch (y)
                             {
                                 case 0:
                                     {
                                         thorus = Torus_013;
                                         tor = Torus_013Container;
                                         break;
                                     }
                                 case 1:
                                     {
                                         thorus = Torus_014;
                                         tor = Torus_014Container;
                                         break;
                                     }
                                 case 2:
                                     {
                                         thorus = Torus_015;
                                         tor = Torus_015Container;
                                         break;
                                     }
                                 case 3:
                                     {
                                         thorus = Torus_016;
                                         tor = Torus_016Container;
                                         break;
                                     }
                             }
                             break;
                         }
                 }
                 break;
             }
     }
     DiffuseMaterial DifMatBl = new DiffuseMaterial(RBrush);
     DiffuseMaterial DifMatB2 = new DiffuseMaterial(BBrush);
     System.Windows.Media.Media3D.TranslateTransform3D trtr3d =new TranslateTransform3D(0.0,20.0,0.0);
     System.Windows.Media.Media3D.Transform3DGroup trgroup =new Transform3DGroup();
     System.Windows.Media.Animation.DoubleAnimation dbAnim = new DoubleAnimation(0, TimeSpan.FromMilliseconds(1000), FillBehavior.HoldEnd);
     trtr3d.BeginAnimation(TranslateTransform3D.OffsetYProperty, dbAnim);
     trgroup.Children.Add(trtr3d);
     tor.Transform = trgroup;
     if (currcol == 1)
     {
         thorus.Material = DifMatBl;
     }
     else
     {
         thorus.Material = DifMatB2;
     }
 }
開發者ID:AVRoosin,項目名稱:3DXO,代碼行數:101,代碼來源:GameWindow.xaml.cs

示例10: Select

        public void Select( bool s )
        {
            Transform3DGroup xform = null;
            if( !( geometry.Transform is Transform3DGroup ) )
            {
                xform = new Transform3DGroup();
                geometry.Transform = xform;
            }
            else
                xform = geometry.Transform as Transform3DGroup;

            TranslateTransform3D translate = new TranslateTransform3D( 0, 0, 0 );
            xform.Children.Add( translate );
            
            double x = -PieGraph.Radius * Math.Sin(cStart+(cEnd-cStart)/2.0);
            double y = -PieGraph.Radius * Math.Cos(cStart+(cEnd-cStart)/2.0);

            DoubleAnimationUsingKeyFrames dax = new DoubleAnimationUsingKeyFrames();
            dax.Duration = TimeSpan.FromMilliseconds(500);
            dax.KeyFrames.Add(new SplineDoubleKeyFrame(s ? -0.25 * x : 0.25 * x, TimeSpan.FromMilliseconds(500), new KeySpline(0.0, 0.6, 0.0, 0.9)));

            DoubleAnimationUsingKeyFrames day = new DoubleAnimationUsingKeyFrames();
            day.Duration = TimeSpan.FromMilliseconds(500);
            day.KeyFrames.Add(new SplineDoubleKeyFrame(s ? -0.25 * y : 0.25 * y, TimeSpan.FromMilliseconds(500), new KeySpline(0.0, 0.6, 0.0, 0.9)));

            DoubleAnimationUsingKeyFrames daz = new DoubleAnimationUsingKeyFrames();
            daz.Duration = TimeSpan.FromMilliseconds(500);
            daz.KeyFrames.Add(new SplineDoubleKeyFrame(s ? -2 : 2, TimeSpan.FromMilliseconds(500), new KeySpline(0.0, 0.6, 0.0, 0.9)));

            translate.BeginAnimation(TranslateTransform3D.OffsetXProperty, dax);
            translate.BeginAnimation(TranslateTransform3D.OffsetYProperty, day);
            translate.BeginAnimation(TranslateTransform3D.OffsetZProperty, daz);
        }
開發者ID:vactorwu,項目名稱:catch23-project,代碼行數:33,代碼來源:PieGraph.cs


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