void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.myWindow = ((VideoText.Window1)(target));
                return;

            case 2:
                this.canvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 3:
                this.myMediaElement = ((System.Windows.Controls.MediaElement)(target));
                return;

            case 4:
                this.path = ((System.Windows.Shapes.Path)(target));
                return;

            case 5:
                this.ellipse = ((System.Windows.Shapes.Ellipse)(target));
                return;

            case 6:
                this.storyboard = ((System.Windows.Media.Animation.Storyboard)(target));
                return;

            case 7:
                this.matrixAnimation = ((System.Windows.Media.Animation.MatrixAnimationUsingPath)(target));
                return;
            }
            this._contentLoaded = true;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.path1 = ((System.Windows.Shapes.Path)(target));
                return;

            case 2:
                this.e1 = ((System.Windows.Media.EllipseGeometry)(target));
                return;

            case 3:
                this.ellipse2 = ((System.Windows.Shapes.Ellipse)(target));
                return;

            case 4:
                this.mt2 = ((System.Windows.Media.MatrixTransform)(target));
                return;

            case 5:
                this.ellipse1 = ((System.Windows.Shapes.Ellipse)(target));
                return;

            case 6:
                this.mt1 = ((System.Windows.Media.MatrixTransform)(target));
                return;

            case 7:
                this.sb1 = ((System.Windows.Media.Animation.Storyboard)(target));
                return;

            case 8:
                this.ma1 = ((System.Windows.Media.Animation.MatrixAnimationUsingPath)(target));
                return;

            case 9:
                this.button1 = ((System.Windows.Controls.Button)(target));

            #line 56 "..\..\Window1.xaml"
                this.button1.Click += new System.Windows.RoutedEventHandler(this.button1_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
示例#3
0
        private void Test_Matrix()
        {
            Canvas.SetLeft(this.border1, -this.border1.ActualWidth / 2);
            Canvas.SetTop(this.border1, -this.border1.ActualHeight / 2);
            this.border1.RenderTransformOrigin = new Point(0.5, 0.5);

            MatrixTransform matrix = new MatrixTransform();
            this.border1.RenderTransform = matrix;

            NameScope.SetNameScope(this, new NameScope());
            this.RegisterName("matrix", matrix);

            MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = this.path1.Data.GetFlattenedPathGeometry();
            matrixAnimation.Duration = new Duration(TimeSpan.FromSeconds(2));
            matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;
            matrixAnimation.AutoReverse = true;
            matrixAnimation.IsOffsetCumulative = !matrixAnimation.AutoReverse;
            matrixAnimation.DoesRotateWithTangent = true;//旋转

            Storyboard story = new Storyboard();
            story.Children.Add(matrixAnimation);
            Storyboard.SetTargetName(matrixAnimation, "matrix");
            Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty));
            story.Begin(this);
        }
示例#4
0
        private void AnimatePutCardMiddleOrRight(int iLocationIndex)
        {
            Canvas targetCanves = GetCanvas(iLocationIndex);
            Point pointCanvasCorner = targetCanves.PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyBezierSegment pBezierSegment = new PolyBezierSegment();

            pFigure.StartPoint = new Point(-pointCanvasCorner.X + this.ActualWidth / 2, -pointCanvasCorner.Y);
            pBezierSegment.Points.Add(pFigure.StartPoint);
            pBezierSegment.Points.Add(new Point(-targetCanves.ActualWidth, 0));
            pBezierSegment.Points.Add(new Point(0, 0));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();
            targetCanves.RenderTransform = matrixTransform;

            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(iAnimationPutCardTime);

            // Set the animation's DoesRotateWithTangent property
            // to true so that rotates the card in addition to moving it.
            matrixAnimation.DoesRotateWithTangent = true;
            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
示例#5
0
        private void InitAntiBubble(CustomControls.Bubbles bb)
        {
            bb.RenderTransformOrigin = new Point(0.5, 0.5);
            MatrixTransform matrix = new MatrixTransform();
            bb.RenderTransform = matrix;

            NameScope.SetNameScope(this, new NameScope());
            this.RegisterName("matrix", matrix);

            MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = (PathGeometry)PathGeometry.Parse("M416,752 C416.62132,721.83583 376.22793,703.51499 417.86397,661.5075 459.5,619.5 418.99008,606.83656 419.55313,579.50109 420.17109,549.50009 385.31468,541.49617 421.40702,489.49808 457.49935,437.5 422.80709,421.52692 423.50712,387.54134 424.0839,359.53949 388.9757,351.57158 425.23747,303.53579 461.49924,255.5 426.58377,238.17526 427.25691,205.49499 427.77851,180.1724 372.14433,181.55445 428.8217,129.52722 485.49907,77.5 429.94781,74.856289
430.51087,47.520822 430.84058,31.513881 387.50032,25.5 431.5,-0.5"); ;
            matrixAnimation.Duration = new Duration(TimeSpan.FromSeconds(2));
            matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;
            //matrixAnimation.AutoReverse = true;
            matrixAnimation.IsOffsetCumulative = !matrixAnimation.AutoReverse;
            matrixAnimation.DoesRotateWithTangent = true;//旋转

            Storyboard story = new Storyboard();
            story.SpeedRatio = 0.5;
            //story.RepeatBehavior = RepeatBehavior.Forever;
            story.Children.Add(matrixAnimation);
            Storyboard.SetTargetName(matrixAnimation, "matrix");
            Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty));
            story.Begin(this);
        }
示例#6
0
        private void AnimatePutCard(int iLocationIndex)
        {
            Canvas targetCanves = GetCanvas(iLocationIndex);
            Point pointCanvasCorner = targetCanves.PointToScreen(new Point(0, 0));
            Point pointWindowCorner = PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyLineSegment pLineSegment = new PolyLineSegment();
            Point pointStart = new Point();
            pointStart.X = pointWindowCorner.X - pointCanvasCorner.X + this.ActualWidth / 2 - targetCanves.ActualHeight / 4;
            pointStart.Y = pointWindowCorner.Y - pointCanvasCorner.Y - targetCanves.ActualWidth;
            pFigure.StartPoint = pointStart;
            pLineSegment.Points.Add(pFigure.StartPoint);
            pLineSegment.Points.Add(new Point(0, 0));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();
            targetCanves.RenderTransform = matrixTransform;

            pFigure.Segments.Add(pLineSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(iAnimationPutCardTime);

            DoubleAnimation doubleAnimation = new DoubleAnimation(90, 360, TimeSpan.FromSeconds(iAnimationPutCardTime));
            RotateTransform renderTransform = new RotateTransform(0, targetCanves.ActualWidth / 2, targetCanves.ActualHeight / 2);//targetCanves.ActualHeight);
            targetCanves.Children[0].RenderTransform = renderTransform;
            renderTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);

            //matrixAnimation.DoesRotateWithTangent = true;
            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
示例#7
0
        private void AnimatePutCardLeft(int iLocationIndex)
        {
            Canvas targetCanves = GetCanvas(iLocationIndex);
            Point pointCanvasCorner = targetCanves.PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyBezierSegment pBezierSegment = new PolyBezierSegment();
            pFigure.StartPoint = new Point(-pointCanvasCorner.X + this.ActualWidth / 2, -pointCanvasCorner.Y);
            pBezierSegment.Points.Add(pFigure.StartPoint);
            pBezierSegment.Points.Add(new Point(targetCanves.ActualWidth * 2, targetCanves.ActualHeight));
            pBezierSegment.Points.Add(new Point(targetCanves.ActualWidth, targetCanves.ActualHeight));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();
            targetCanves.RenderTransform = matrixTransform;

            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(2 * iAnimationPutCardTime / 3);

            matrixAnimation.Completed += delegate
            {
                // the cards get reversed - there for need animation to flip it...
                DoubleAnimation doubleAnimation = new DoubleAnimation(180, 0, TimeSpan.FromSeconds(iAnimationPutCardTime / 3));
                RotateTransform rotareTransform = new RotateTransform(0, targetCanves.ActualWidth / 2, targetCanves.ActualHeight / 2);//targetCanves.ActualHeight);
                targetCanves.RenderTransform = rotareTransform;
                rotareTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);
            };

            // Set the animation's DoesRotateWithTangent property
            // to true so that rotates the card in addition to moving it.
            matrixAnimation.DoesRotateWithTangent = true;
            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
示例#8
0
        private void AnimateMoveCard(int iLocationFrom, int iLocationTo)
        {
            Canvas canvesFrom = GetCanvas(iLocationFrom);
            Point pointCanvasCornerFrom = canvesFrom.PointToScreen(new Point(0, 0));
            Canvas canvesTo = GetCanvas(iLocationTo);
            Point pointCanvasCornerTo = canvesTo.PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyLineSegment pLineSegment = new PolyLineSegment();
            pFigure.StartPoint = new Point(0, 0);
            pLineSegment.Points.Add(pFigure.StartPoint);
            pLineSegment.Points.Add(new Point(pointCanvasCornerTo.X - pointCanvasCornerFrom.X, pointCanvasCornerTo.Y - pointCanvasCornerFrom.Y));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();

            pFigure.Segments.Add(pLineSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(iAnimationRemoveCardTime);

            canvesFrom.Children[0].RenderTransform = matrixTransform;
            matrixAnimation.Completed += delegate
            {
                MoveCard(iLocationFrom, iLocationTo);
            };

            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
        public void MatrixAnimationUsingPathDoesRotateWithTangentExample()
        {

            // Create a NameScope for the page so that
            // we can use Storyboards.
            NameScope.SetNameScope(MainGrid ,new NameScope());

            // Create a button.
            Map.MapBlock aButton = new Map.MapBlock();
            aButton.LeftSideVisable = true;
            aButton.RightSideVisable = true;
            // Create a MatrixTransform. This transform
            // will be used to move the button.
            MatrixTransform buttonMatrixTransform = new MatrixTransform();
            aButton.RenderTransform = buttonMatrixTransform;

            // Register the transform's name with the page
            // so that it can be targeted by a Storyboard.
            MainGrid.RegisterName("ButtonMatrixTransform" ,buttonMatrixTransform);

            // Create a Canvas to contain the button
            // and add it to the page.
            // Although this example uses a Canvas,
            // any type of panel will work.
            Canvas mainPanel = new Canvas();
            mainPanel.Width = 400;
            mainPanel.Height = 400;
            mainPanel.Children.Add(aButton);
            MainGrid.Children.Add(mainPanel);

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();
            pFigure.StartPoint = new Point(10, 100);
            PolyBezierSegment pBezierSegment = new PolyBezierSegment();
            pBezierSegment.Points.Add(new Point(35, 0));
            pBezierSegment.Points.Add(new Point(135, 0));
            pBezierSegment.Points.Add(new Point(160, 100));
            pBezierSegment.Points.Add(new Point(180, 190));
            pBezierSegment.Points.Add(new Point(285, 200));
            pBezierSegment.Points.Add(new Point(310, 100));
            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating
            // its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(5);
            matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Set the animation's DoesRotateWithTangent property
            // to true so that rotates the rectangle in addition
            // to moving it.
            matrixAnimation.DoesRotateWithTangent = true;

            // Set the animation to target the Matrix property
            // of the MatrixTransform named "ButtonMatrixTransform".
            Storyboard.SetTargetName(matrixAnimation, "ButtonMatrixTransform");
            Storyboard.SetTargetProperty(matrixAnimation, 
                new PropertyPath(MatrixTransform.MatrixProperty));

            // Create a Storyboard to contain and apply the animation.
            Storyboard pathAnimationStoryboard = new Storyboard();
            pathAnimationStoryboard.Children.Add(matrixAnimation);

            // Start the storyboard when the button is loaded.
            aButton.Loaded += delegate(object sender, RoutedEventArgs e)
            {
                // Start the storyboard.
                pathAnimationStoryboard.Begin(MainGrid);
            };



        }
示例#10
0
        private void animatePlayerRanged()
        {
            BitmapImage arrowSource = new BitmapImage();

            arrowSource.BeginInit();
            arrowSource.UriSource = new Uri("/Resources/PArrow_25x16_Trans.png", UriKind.Relative);
            arrowSource.EndInit();
            arrow = new Image();
            arrow.Source = arrowSource;

            PArrowGrid.Children.Add(arrow);

            NameScope.SetNameScope(this, new NameScope());

            MatrixTransform buttonMatrixTransform = new MatrixTransform();
            PArrowGrid.RenderTransform = buttonMatrixTransform;

            this.RegisterName("FireMatrixTransform", buttonMatrixTransform);

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();
            pFigure.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment = new PolyBezierSegment();
            pBezierSegment.Points.Add(new Point(150,0));
            pBezierSegment.Points.Add(new Point(175,0));
            pBezierSegment.Points.Add(new Point(200,0));
            pBezierSegment.Points.Add(new Point(225,0));
            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the 
            // button along the path by animating 
            // its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(.5);

            // Set the animation to target the Matrix property 
            // of the MatrixTransform named "ButtonMatrixTransform".
            Storyboard.SetTargetName(matrixAnimation, "FireMatrixTransform");
            Storyboard.SetTargetProperty(matrixAnimation,
                new PropertyPath(MatrixTransform.MatrixProperty));

            // Create a Storyboard to contain and apply the animation.
            Storyboard pathAnimationStoryboard = new Storyboard();
            pathAnimationStoryboard.Children.Add(matrixAnimation);

            pathAnimationStoryboard.Completed += pathAnimationStoryboardRangedMove_Completed;
            // Start the storyboard.
            AtkButton.IsEnabled = false;
            pathAnimationStoryboard.Begin(this);
        }
示例#11
0
        private void animateMonsterMove()
        {

            NameScope.SetNameScope(this, new NameScope());

            MatrixTransform buttonMatrixTransform = new MatrixTransform();
            Monster.RenderTransform = buttonMatrixTransform;

            this.RegisterName("PlayerMatrixTransform", buttonMatrixTransform);

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();
            pFigure.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment = new PolyBezierSegment();
            pBezierSegment.Points.Add(new Point(-500, 0));
            pBezierSegment.Points.Add(new Point(-175, 0));
            pBezierSegment.Points.Add(new Point(-175, 0));
            pBezierSegment.Points.Add(new Point(-500, 0));
            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the 
            // button along the path by animating 
            // its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(1);
            matrixAnimation.AutoReverse = true;

            // Set the animation to target the Matrix property 
            // of the MatrixTransform named "ButtonMatrixTransform".
            Storyboard.SetTargetName(matrixAnimation, "PlayerMatrixTransform");
            Storyboard.SetTargetProperty(matrixAnimation,
                new PropertyPath(MatrixTransform.MatrixProperty));

            // Create a Storyboard to contain and apply the animation.
            Storyboard pathAnimationStoryboard = new Storyboard();
            pathAnimationStoryboard.Children.Add(matrixAnimation);

            pathAnimationStoryboard.Completed += pathAnimationStoryboardMMove_Completed;
            // Start the storyboard.
            pathAnimationStoryboard.Begin(this);
        }
示例#12
0
文件: Train.cs 项目: M0N3/Subway
 internal void Animate(Subway subway)
 {
     pathAnimationStoryboard = new Storyboard();
     Start = true;
     MatrixTransform buttonMatrixTransform = new MatrixTransform();
     this.TrainPath.RenderTransform = buttonMatrixTransform;
     NameScope.SetNameScope(this, new NameScope());
     RectangleGeometry rc = TrainPath.Data as RectangleGeometry;
     EllipseGeometry e = subway.GetRailways.ElementAt(lineNumber).GetStations.ElementAt(id).ellipsePath.Data as EllipseGeometry;
     Point c = e.Center;
     rc.Rect = new Rect(c.X, c.Y, 30, 30);
     this.RegisterName("ButtonMatrixTransform", buttonMatrixTransform);
     PathGeometry animationPath = new PathGeometry();
     if (Back)
     {
         animationPath = subway.GetRailways.ElementAt(lineNumber).GetStations.ElementAt(id).endLinePath.Data as PathGeometry;
     }
     else
     {
         if (subway.GetRailways.ElementAt(lineNumber).GetStations.ElementAt(id).startLinePath != null)
         {
             animationPath = subway.GetRailways.ElementAt(lineNumber).GetStations.ElementAt(id).startLinePath.Data as PathGeometry;
         }
     }
     Point p = subway.GetRailways.ElementAt(lineNumber).GetStations.ElementAt(id).Coordinate;
     rc.Rect = new Rect(rc.Rect.X - p.X - 15, rc.Rect.Y - p.Y - 15, 30, 30);
     MatrixAnimationUsingPath matrixAnimation =
         new MatrixAnimationUsingPath();
     matrixAnimation.PathGeometry = animationPath;
     matrixAnimation.Duration = TimeSpan.FromSeconds(travelTime);
     matrixAnimation.DoesRotateWithTangent = true;
     Storyboard.SetTargetName(matrixAnimation, "ButtonMatrixTransform");
     Storyboard.SetTargetProperty(matrixAnimation,
         new PropertyPath(MatrixTransform.MatrixProperty));
     pathAnimationStoryboard.Children.Add(matrixAnimation);
     pathAnimationStoryboard.Begin(this);
 }