Beispiel #1
0
        /// <summary>
        /// 通过点的集合获取三次贝赛尔曲线
        /// </summary>
        /// <param name="points"></param>
        /// <returns></returns>
        private SystemMedia.PathGeometry GetCurveGeometry(IEnumerable <Vector2D> points)
        {
            if (points == null)
            {
                throw new ArgumentNullException(nameof(points));
            }

            var screenPoints = points.Select(x => ConvertVectorToScreenPoint(x)).ToArray();
            var bezier       = new SystemMedia.PolyBezierSegment(screenPoints, true);
            var pathFigure   = new SystemMedia.PathFigure();
            var pathGeometry = new SystemMedia.PathGeometry();

            pathFigure.Segments.Add(bezier);
            pathGeometry.Figures.Add(pathFigure);

            if (screenPoints.Length >= 1)
            {
                pathFigure.StartPoint = screenPoints[0];

                //因为此处使用的三次贝塞尔曲线要求点的数量为3的倍数,所以在未能正处情况下,重复最后一项至下一个三的倍数;
                var repeatCount = (3 - (screenPoints.Length % 3)) % 3;

                var lastScreenPoint = screenPoints[screenPoints.Length - 1];
                for (int i = 0; i < repeatCount; i++)
                {
                    bezier.Points.Add(lastScreenPoint);
                }
            }

            return(pathGeometry);
        }
Beispiel #2
0
 public override void bezierTo(float c1x, float c1y, float c2x, float c2y, float x, float y)
 {
     PolyBezierSegment segment = new PolyBezierSegment();
     segment.Points.Add(new Point(c1x, c1y));
     segment.Points.Add(new Point(c2x, c2y));
     segment.Points.Add(new Point(x, y));
     _pathFigure.Segments.Add(segment);
 }
Beispiel #3
0
        public static PathGeometry GenerateBezierCurve(Point[] points)
        {
            PathFigure pathFigure = new PathFigure();
            PointCollection pointCollection = new PointCollection(points.Length);
            pathFigure.StartPoint = new Point(points[0].X, points[0].Y);

            PathGeometry myPathGeometry = new PathGeometry();
            PathSegment pathSegment;

            if (points.Length == 2)
            {
                pathSegment = new LineSegment();
                ((LineSegment)pathSegment).Point = new Point(points[1].X, points[1].Y);
            }
            else if (points.Length == 3)
            {
                pathSegment = new QuadraticBezierSegment();
                ((QuadraticBezierSegment)pathSegment).Point1 = new Point(points[1].X, points[1].Y);
                ((QuadraticBezierSegment)pathSegment).Point2 = new Point(points[2].X, points[2].Y);
            }
            else if (points.Length == 4)
            {
                for (int i = 1; i < points.Length; i++)
                {
                    pointCollection.Add(points[i]);
                }

                pathSegment = new PolyBezierSegment();
                ((PolyBezierSegment)pathSegment).Points = pointCollection;
            }
            else
            {
                return null;
            }

            PathSegmentCollection pathSegmentCollection = new PathSegmentCollection();
            pathSegmentCollection.Add(pathSegment);

            pathFigure.Segments = pathSegmentCollection;

            PathFigureCollection pathFigureCollection = new PathFigureCollection();
            pathFigureCollection.Add(pathFigure);

            myPathGeometry.Figures = pathFigureCollection;

            return myPathGeometry;
        }
Beispiel #4
0
 public static PathGeometry DrawPolyBezier(Point[] input)
 {
     PathGeometry pg = new PathGeometry();
     PathFigure pf = new PathFigure();
     pf.StartPoint = input[0];
     PolyBezierSegment pbs = new PolyBezierSegment();
     for (int i = 1; i < input.GetLength(0); i++)
         pbs.Points.Add(input[i]);
     pf.Segments.Add(pbs);
     pg.Figures.Add(pf);
     return pg;
 }
Beispiel #5
0
        /// <summary>
        /// Funkja przygotowywująca animację na podstawie rozmiaru obiektu canvas
        /// </summary>
        /// <param name="geometry">Aktualny obiekt geometry</param>
        private void PrepareAnimation(EllipseGeometry geometry)
        {
            double space = playField.ActualWidth / baloons;
            j += (int)space + 50;
            if (j > playField.ActualWidth)
            {
                j = Convert.ToInt32(j % playField.ActualWidth);
            }

            geometry.Center = new Point(j, -50);
            up = new PointAnimationUsingPath();
            pBezierSegment = new PolyBezierSegment();
            animationPath = new PathGeometry();
            pFigure = new PathFigure();

            pFigure.StartPoint = new Point(j, -50);
            for (int i = 0; (i < playField.ActualHeight); i += 25)
            {
                int randomSign = random.Next(1);
                if (randomSign == 0)
                {
                    pBezierSegment.Points.Add(new Point(j - random.Next(30), i));
                }
                else if (randomSign == 1)
                {
                    pBezierSegment.Points.Add(new Point(j + random.Next(30), i));
                }
            }
            pBezierSegment.Points.Add(new Point(j, playField.ActualHeight + 50));

            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);
            up.PathGeometry = animationPath;
            if (timesIndex != times.Count)
            {
                up.BeginTime = TimeSpan.FromSeconds(Convert.ToInt32(times[timesIndex]));
                timesIndex++;
            }

            up.Duration = TimeSpan.FromSeconds(10);
            up.SpeedRatio = 0.5;
            up.RepeatBehavior = RepeatBehavior.Forever;
            animationPath.Freeze();
            geometry.BeginAnimation(EllipseGeometry.CenterProperty, up);
        }
Beispiel #6
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);
        }
Beispiel #7
0
 public void PolyBezierTo(IList<Point> points, bool isStroked, bool isSmoothJoin) {
   CheckState();
   PolyBezierSegment seg = new PolyBezierSegment();
   PointCollection pts = new PointCollection();
   foreach (Point p in points) pts.Add(p);
   seg.Points = pts;
   _Fig.Segments.Add(seg);
 }
        private void BuildPath
        (
            PdfContents Contents,
            PaintOp PaintOperator
        )
        {
            // every figure is a separated subpath and contains some segments
            foreach (SysMedia.PathFigure SubPath in MediaPath.Figures)
            {
                // get start of sub-path point
                PointD CurPoint   = PathToDrawing(SubPath.StartPoint);
                PointD StartPoint = CurPoint;
                Contents.MoveTo(CurPoint);

                // process all points of one sub-path
                foreach (SysMedia.PathSegment Seg in SubPath.Segments)
                {
                    // line segment
                    if (Seg.GetType() == typeof(SysMedia.LineSegment))
                    {
                        CurPoint = PathToDrawing(((SysMedia.LineSegment)Seg).Point);
                        Contents.LineTo(CurPoint);
                    }

                    // polygon
                    else if (Seg.GetType() == typeof(SysMedia.PolyLineSegment))
                    {
                        SysMedia.PolyLineSegment LineSegArray = (SysMedia.PolyLineSegment)Seg;
                        foreach (SysWin.Point PolyPoint in LineSegArray.Points)
                        {
                            CurPoint = PathToDrawing(PolyPoint);
                            Contents.LineTo(CurPoint);
                        }
                    }

                    // cubic bezier segment
                    else if (Seg.GetType() == typeof(SysMedia.BezierSegment))
                    {
                        SysMedia.BezierSegment BezierSeg = (SysMedia.BezierSegment)Seg;
                        CurPoint = PathToDrawing(BezierSeg.Point3);
                        Contents.DrawBezier(PathToDrawing(BezierSeg.Point1), PathToDrawing(BezierSeg.Point2), CurPoint);
                    }

                    // cubic bezier multi segments
                    else if (Seg.GetType() == typeof(SysMedia.PolyBezierSegment))
                    {
                        SysMedia.PolyBezierSegment BezierSegArray = (SysMedia.PolyBezierSegment)Seg;
                        int Count = BezierSegArray.Points.Count;
                        for (int Index = 0; Index < Count; Index += 3)
                        {
                            CurPoint = PathToDrawing(BezierSegArray.Points[Index + 2]);
                            Contents.DrawBezier(PathToDrawing(BezierSegArray.Points[Index]), PathToDrawing(BezierSegArray.Points[Index + 1]), CurPoint);
                        }
                    }

                    // quadratic bezier segment
                    else if (Seg.GetType() == typeof(SysMedia.QuadraticBezierSegment))
                    {
                        SysMedia.QuadraticBezierSegment BezierSeg = (SysMedia.QuadraticBezierSegment)Seg;
                        PointD NextPoint = PathToDrawing(BezierSeg.Point2);
                        Contents.DrawBezier(new BezierD(CurPoint, PathToDrawing(BezierSeg.Point1), NextPoint), BezierPointOne.Ignore);
                        CurPoint = NextPoint;
                    }

                    // quadratic bezier multi segments
                    else if (Seg.GetType() == typeof(SysMedia.PolyQuadraticBezierSegment))
                    {
                        SysMedia.PolyQuadraticBezierSegment BezierSegArray = (SysMedia.PolyQuadraticBezierSegment)Seg;
                        int Count = BezierSegArray.Points.Count;
                        for (int Index = 0; Index < Count; Index += 2)
                        {
                            PointD NextPoint = PathToDrawing(BezierSegArray.Points[Index + 1]);
                            Contents.DrawBezier(new BezierD(CurPoint, PathToDrawing(BezierSegArray.Points[Index]), NextPoint), BezierPointOne.Ignore);
                            CurPoint = NextPoint;
                        }
                    }

                    // draw arc
                    else if (Seg.GetType() == typeof(SysMedia.ArcSegment))
                    {
                        SysMedia.ArcSegment Arc = (SysMedia.ArcSegment)Seg;
                        PointD  NextPoint       = PathToDrawing(Arc.Point);
                        ArcType ArcType;
                        if (Arc.SweepDirection == (PathYAxis == YAxisDirection.Down ? SysMedia.SweepDirection.Counterclockwise : SysMedia.SweepDirection.Clockwise))
                        {
                            ArcType = Arc.IsLargeArc ? ArcType.LargeCounterClockWise : ArcType.SmallCounterClockWise;
                        }
                        else
                        {
                            ArcType = Arc.IsLargeArc ? ArcType.LargeClockWise : ArcType.SmallClockWise;
                        }
                        Contents.DrawArc(CurPoint, NextPoint, SizeToDrawing(Arc.Size), Arc.RotationAngle, ArcType, BezierPointOne.Ignore);
                        CurPoint = NextPoint;
                    }

                    // should no happen
                    else
                    {
                        throw new ApplicationException("Windows Media path: unknown path segment.");
                    }
                }

                // for stroke set paint operator for each sub-path
                if (SubPath.IsClosed)
                {
                    Contents.SetPaintOp(PaintOp.CloseSubPath);
                }
            }

            // paint operator
            Contents.SetPaintOp(PaintOperator);
            return;
        }
        private void TerminalLoad(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.Cursor.Hide();
            //Debug.WriteLine("staaart!");
            int Width = SystemInformation.PrimaryMonitorSize.Width;
            int Height = SystemInformation.PrimaryMonitorSize.Height;
            DockPanel MainDockPanel = new DockPanel();
            this.MainGrid.Children.Add(MainDockPanel);
            MainDockPanel.VerticalAlignment = VerticalAlignment.Top;
            LinearGradientBrush GreenGradientBrush = new LinearGradientBrush();
            GreenGradientBrush.GradientStops.Add(new GradientStop(Colors.Green, 0.0));
            GreenGradientBrush.GradientStops.Add(new GradientStop(Colors.White, 0.5));
            GreenGradientBrush.GradientStops.Add(new GradientStop(Colors.Green, 1.0));
            this.Advertismen.Background = GreenGradientBrush;
            DockPanel.SetDock(this.Advertismen, Dock.Top);
            MainDockPanel.LastChildFill = true;
            MainDockPanel.Children.Add(this.Advertismen);
            this.Advertismen.Width = (double)Width;
            this.Advertismen.Height = (double)(Height / 10);
            DockPanel LeftGrid = new DockPanel();
            Grid RightGrid = new Grid();
            DockPanel.SetDock(LeftGrid, Dock.Left);
            DockPanel.SetDock(RightGrid, Dock.Right);
            LeftGrid.Background = GreenGradientBrush;
            RightGrid.Background = new ImageBrush
            {
                ImageSource = new BitmapImage(new Uri("sampleImages\\главная фоновое.jpg", UriKind.Relative))
            };
            this.MoveGridWidth = Width / 10 * 7;
            this.MoveGridHidth = Height / 10 * 9;
            this.RightInputGrid.Width = (double)(Width / 10 * 7 / 2);
            this.RightInputGrid.Height = (double)(Height / 10 * 9);
            this.RightInputGrid.Children.Add(this.Text);
            this.Text.TextWrapping = TextWrapping.Wrap;
            this.Text.FontSize = 20.0;
            this.RightInputGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            this.RightInputGrid.Background = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255));
            this.RightInputGridLeft.Width = (double)(Width / 10 * 7 / 2);
            this.RightInputGridLeft.Height = (double)(Height / 10 * 9);
            this.RightInputGridLeft.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            this.MoveGrid.Children.Add(this.RightInputGridLeft);
            MainDockPanel.Children.Add(LeftGrid);
            MainDockPanel.Children.Add(RightGrid);
            LeftGrid.Height = (double)(Height / 10 * 9);
            RightGrid.Height = (double)(Height / 10 * 9);
            LeftGrid.Width = (double)(Width / 10 * 3);
            RightGrid.Width = (double)(Width / 10 * 7);
            System.Windows.Controls.ListBox GroupList = new System.Windows.Controls.ListBox();
            LeftGrid.Children.Add(this.GroupGrid);
            LeftGrid.Children.Add(this.RecipeGrid);
            DockPanel.SetDock(this.GroupGrid, Dock.Top);
            DockPanel.SetDock(this.RecipeGrid, Dock.Bottom);
            this.GroupGrid.Height = LeftGrid.Height / 2.0;
            this.RecipeGrid.Height = LeftGrid.Height / 2.0;
            this.GroupGrid.Width = LeftGrid.Width;
            this.RecipeGrid.Width = LeftGrid.Width;
            AdvertismentTxt = new TextBlock();
            setAdvertismentText("Березинский биосферный заповедник");
            menuLevel = 0;
            //AdvertismentTxt.Text = "Березинский биосферный заповедник";
            //AdvertismentTxt.VerticalAlignment = VerticalAlignment.Center;
            //AdvertismentTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            //AdvertismentTxt.TextAlignment = TextAlignment.Center;
            //AdvertismentTxt.FontFamily = new FontFamily("Arial Black");
            //AdvertismentTxt.TextWrapping = TextWrapping.Wrap;

            //AdvertismentTxt.BitmapEffect = new BevelBitmapEffect();
            AdvertismentTxt.FontSize = 32.0;
            this.Advertismen.Children.Add(AdvertismentTxt);
            this.GroupGrid.Children.Add(this.GroupListBox);

            //TextBlock[] tb = new TextBlock[6];
            //for (int i = 0; i < 6; i++ )
            //{
            //    tb[i] = new TextBlock();
            //    tb[i].FontFamily = new FontFamily("Arial Black");
            //    tb[i].FontSize = 14;
            //}

            //MyListBoxItem itm = new MyListBoxItem(new FontFamily("Arial Black"), "О заповеднике");
            //itm.Style.
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Природные условия"));
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Деятельность заповедника"));
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Экологические маршруты"));
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Экологическое просвещение"));
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Туристические услуги"));
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Контактная информация"));
            //ListBoxItem itm;
            //Style st = new Style()

            //itm.Style
            //tb[0].Text = "О заповеднике";
            //this.GroupListBox.Items.Add(tb[0]);
            //tb[1].Text = "Природные условия";
            //this.GroupListBox.Items.Add(tb[1]);
            //tb[2].Text = "Деятельность заповедника";
            //this.GroupListBox.Items.Add(tb[2]);
            //tb[3].Text = "Экологические маршруты";
            //this.GroupListBox.Items.Add(tb[3]);
            //tb[4].Text = "Экологическое просвещение";
            //this.GroupListBox.Items.Add(tb[4]);
            //tb[5].Text = "Контактная информация";
            //this.GroupListBox.Items.Add(tb[5]);

            //System.Windows.Forms.ListView lv = new System.Windows.Forms.ListView;
            this.GroupListBox.Items.Add("О заповеднике");
            this.GroupListBox.Items.Add("Природные условия");
            this.GroupListBox.Items.Add("Деятельность заповедника");
            this.GroupListBox.Items.Add("Экологические маршруты");
            this.GroupListBox.Items.Add("Экологическое просвещение");
            this.GroupListBox.Items.Add("Туристические услуги");
            this.GroupListBox.Items.Add("Контактная информация");

            this.SmallImageListBox.Height = LeftGrid.Height / 2.0;
            this.SmallImageListBox.Width = LeftGrid.Width - 5.0;
            RightGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            this.SmallImageListBox.VerticalAlignment = VerticalAlignment.Top;
            this.SmallImageListBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            this.GroupListBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            this.GroupListBox.VerticalAlignment = VerticalAlignment.Top;
            this.GroupListBox.SelectionChanged += new SelectionChangedEventHandler(this.GroupListBox_SelectionChanged);
            this.SmallImageListBox.SelectionChanged += new SelectionChangedEventHandler(this.SmallImageListBox_SelectionChanged);
            RightGrid.Children.Add(this.MoveGrid);
            this.MoveGrid.Height = RightGrid.Height;
            this.MoveGrid.Width = RightGrid.Width;
            DoubleAnimation MoveAnimation = new DoubleAnimation();
            MoveAnimation.Duration = TimeSpan.FromSeconds(5.0);
            MoveAnimation.From = new double?((double)Width);
            MoveAnimation.To = new double?(base.Width + 100.0);
            MoveAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(500.0));
            TranslateTransform TransformMove = new TranslateTransform();
            MoveAnimation.By = new double?(0.2);
            this.MoveGrid.Children.Add(this.RightInputGrid);
            this.Img.Height = this.MoveGrid.Height;
            this.Img.Width = this.MoveGrid.Width;
            RotateTransform animatedRotateTransform = new RotateTransform();
            TranslateTransform animatedTranslateTransform = new TranslateTransform();
            base.RegisterName("AnimatedRotateTransform", animatedRotateTransform);
            base.RegisterName("AnimatedTranslateTransform", animatedTranslateTransform);
            TransformGroup tGroup = new TransformGroup();
            tGroup.Children.Add(animatedRotateTransform);
            tGroup.Children.Add(animatedTranslateTransform);
            this.MoveGrid.RenderTransform = tGroup;
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();
            pFigure.StartPoint = new Point(0.0, 0.0);
            PolyBezierSegment pBezierSegment = new PolyBezierSegment();
            pBezierSegment.Points.Add(new Point(RightGrid.Width, 0.0));
            pBezierSegment.Points.Add(new Point(300.0, 0.0));
            pBezierSegment.Points.Add(new Point(RightGrid.Width, 0.0));
            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);
            animationPath.Freeze();
            DoubleAnimationUsingPath angleAnimation = new DoubleAnimationUsingPath();
            angleAnimation.PathGeometry = animationPath;
            angleAnimation.Duration = TimeSpan.FromMilliseconds(500.0);
            angleAnimation.Source = PathAnimationSource.Angle;
            Storyboard.SetTargetName(angleAnimation, "AnimatedRotateTransform");
            Storyboard.SetTargetProperty(angleAnimation, new PropertyPath(RotateTransform.AngleProperty));
            DoubleAnimationUsingPath translateXAnimation = new DoubleAnimationUsingPath();
            translateXAnimation.PathGeometry = animationPath;
            translateXAnimation.Duration = TimeSpan.FromMilliseconds(500.0);
            translateXAnimation.Source = PathAnimationSource.X;
            Storyboard.SetTargetName(translateXAnimation, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateXAnimation, new PropertyPath(TranslateTransform.XProperty));
            DoubleAnimationUsingPath translateYAnimation = new DoubleAnimationUsingPath();
            translateYAnimation.PathGeometry = animationPath;
            translateYAnimation.Duration = TimeSpan.FromMilliseconds(500.0);
            translateYAnimation.Source = PathAnimationSource.Y;
            Storyboard.SetTargetName(translateYAnimation, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateYAnimation, new PropertyPath(TranslateTransform.YProperty));
            this.pathAnimationStoryboard.AutoReverse = true;
            this.pathAnimationStoryboard.Children.Add(angleAnimation);
            this.pathAnimationStoryboard.Children.Add(translateXAnimation);
            this.pathAnimationStoryboard.Children.Add(translateYAnimation);
            this.BattonPanel.Height = 150.0;
            this.BattonPanel.Width = 300.0;
            ImageBrush myBackBrush = new ImageBrush();
            myBackBrush.ImageSource = new BitmapImage(new Uri("sampleImages\\back.png", UriKind.Relative));
            this.BattonPanel.Background = myBackBrush;
            TextBlock InfoButtonText = new TextBlock();
            InfoButtonText.Text = "    НАЗАД";
            InfoButtonText.FontFamily = new FontFamily("Arial Black");
            InfoButtonText.TextWrapping = TextWrapping.Wrap;
            //InfoButtonText.BitmapEffect = new BevelBitmapEffect();
            InfoButtonText.FontSize = 32.0;
            this.BattonPanel.MouseDown += new MouseButtonEventHandler(this.InfoCloseButton_Click);
        }
Beispiel #10
0
        public static WMedia.Geometry ToWindows(this Geometry geometry)
        {
            WMedia.Geometry wGeometry = null;

            if (geometry is LineGeometry)
            {
                LineGeometry lineGeometry = geometry as LineGeometry;
                wGeometry = new WMedia.LineGeometry
                {
                    StartPoint = lineGeometry.StartPoint.ToWindows(),
                    EndPoint   = lineGeometry.EndPoint.ToWindows()
                };
            }
            else if (geometry is RectangleGeometry)
            {
                var rect = (geometry as RectangleGeometry).Rect;
                wGeometry = new WMedia.RectangleGeometry
                {
                    Rect = new WFoundation.Rect(rect.X, rect.Y, rect.Width, rect.Height)
                };
            }
            else if (geometry is EllipseGeometry)
            {
                EllipseGeometry ellipseGeometry = geometry as EllipseGeometry;
                wGeometry = new WMedia.EllipseGeometry
                {
                    Center  = ellipseGeometry.Center.ToWindows(),
                    RadiusX = ellipseGeometry.RadiusX,
                    RadiusY = ellipseGeometry.RadiusY
                };
            }
            else if (geometry is GeometryGroup)
            {
                GeometryGroup geometryGroup = geometry as GeometryGroup;
                wGeometry = new WMedia.GeometryGroup
                {
                    FillRule = ConvertFillRule(geometryGroup.FillRule)
                };

                foreach (Geometry children in geometryGroup.Children)
                {
                    WMedia.Geometry winChild = children.ToWindows();
                    (wGeometry as WMedia.GeometryGroup).Children.Add(winChild);
                }
            }
            else if (geometry is PathGeometry)
            {
                PathGeometry pathGeometry = geometry as PathGeometry;

                WMedia.PathGeometry wPathGeometry = new WMedia.PathGeometry
                {
                    FillRule = ConvertFillRule(pathGeometry.FillRule)
                };

                foreach (PathFigure xamPathFigure in pathGeometry.Figures)
                {
                    WMedia.PathFigure wPathFigure = new WMedia.PathFigure
                    {
                        StartPoint = xamPathFigure.StartPoint.ToWindows(),
                        IsFilled   = xamPathFigure.IsFilled,
                        IsClosed   = xamPathFigure.IsClosed
                    };
                    wPathGeometry.Figures.Add(wPathFigure);

                    foreach (PathSegment pathSegment in xamPathFigure.Segments)
                    {
                        // LineSegment
                        if (pathSegment is LineSegment)
                        {
                            LineSegment lineSegment = pathSegment as LineSegment;

                            WMedia.LineSegment winSegment = new WMedia.LineSegment
                            {
                                Point = lineSegment.Point.ToWindows()
                            };

                            wPathFigure.Segments.Add(winSegment);
                        }

                        // PolylineSegment
                        if (pathSegment is PolyLineSegment)
                        {
                            PolyLineSegment        polyLineSegment = pathSegment as PolyLineSegment;
                            WMedia.PolyLineSegment wSegment        = new WMedia.PolyLineSegment();

                            foreach (var point in polyLineSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }

                        // BezierSegment
                        if (pathSegment is BezierSegment)
                        {
                            BezierSegment bezierSegment = pathSegment as BezierSegment;

                            WMedia.BezierSegment wSegment = new WMedia.BezierSegment
                            {
                                Point1 = bezierSegment.Point1.ToWindows(),
                                Point2 = bezierSegment.Point2.ToWindows(),
                                Point3 = bezierSegment.Point3.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // PolyBezierSegment
                        else if (pathSegment is PolyBezierSegment)
                        {
                            PolyBezierSegment        polyBezierSegment = pathSegment as PolyBezierSegment;
                            WMedia.PolyBezierSegment wSegment          = new WMedia.PolyBezierSegment();

                            foreach (var point in polyBezierSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }

                        // QuadraticBezierSegment
                        if (pathSegment is QuadraticBezierSegment)
                        {
                            QuadraticBezierSegment quadraticBezierSegment = pathSegment as QuadraticBezierSegment;

                            WMedia.QuadraticBezierSegment wSegment = new WMedia.QuadraticBezierSegment
                            {
                                Point1 = quadraticBezierSegment.Point1.ToWindows(),
                                Point2 = quadraticBezierSegment.Point2.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // PolyQuadraticBezierSegment
                        else if (pathSegment is PolyQuadraticBezierSegment)
                        {
                            PolyQuadraticBezierSegment        polyQuadraticBezierSegment = pathSegment as PolyQuadraticBezierSegment;
                            WMedia.PolyQuadraticBezierSegment wSegment = new WMedia.PolyQuadraticBezierSegment();

                            foreach (var point in polyQuadraticBezierSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // ArcSegment
                        else if (pathSegment is ArcSegment)
                        {
                            ArcSegment arcSegment = pathSegment as ArcSegment;

                            WMedia.ArcSegment wSegment = new WMedia.ArcSegment
                            {
                                Size           = new WFoundation.Size(arcSegment.Size.Width, arcSegment.Size.Height),
                                RotationAngle  = arcSegment.RotationAngle,
                                IsLargeArc     = arcSegment.IsLargeArc,
                                SweepDirection = arcSegment.SweepDirection == SweepDirection.Clockwise ? WMedia.SweepDirection.Clockwise : WMedia.SweepDirection.Counterclockwise,
                                Point          = arcSegment.Point.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                    }
                }

                wGeometry = wPathGeometry;
            }

            return(wGeometry);
        }
Beispiel #11
0
        public static PolyBezierSegment ComputeCurve(Point startPoint, Point endPoint, Vector velocity)
        {
            PolyBezierSegment pBezierSegment = new PolyBezierSegment();
            // Compute path
            int divisions = 10; // The granularity of the path
            double[] xPoints = ComputeAcceleratePoints(velocity.X, endPoint.X - startPoint.X, divisions);
            double[] yPoints = ComputeAcceleratePoints(velocity.Y, endPoint.Y - startPoint.Y, divisions);

            for (int i = 0; i < divisions; i++)
            {
                pBezierSegment.Points.Add(new Point(startPoint.X + xPoints[i], startPoint.Y + yPoints[i]));
            }
            return pBezierSegment;
        }
Beispiel #12
0
        public static PathGeometry DrawPolyBezier(Point[] input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (input.Length == 0)
            {
                throw new InvalidOperationException();
            }

            PathGeometry pg = new PathGeometry();
            PathFigure pf = new PathFigure();
            pf.StartPoint = input[0];
            PolyBezierSegment pbs = new PolyBezierSegment();
            for (int i = 1; i < input.GetLength(0); i++)
                pbs.Points.Add(input[i]);
            pf.Segments.Add(pbs);
            pg.Figures.Add(pf);
            return pg;
        }
        public static IEnumerable<Telerik.Windows.Documents.Fixed.Model.Graphics.BezierSegment> ConvertPolyBezierSegments(PolyBezierSegment polyBezierSegment)
        {
            var points = polyBezierSegment.Points;

            for (int index = 2; index < points.Count; index += 3)
            {
                var pdfBezierSegment = new Telerik.Windows.Documents.Fixed.Model.Graphics.BezierSegment();
                pdfBezierSegment.Point1 = points[index - 2];
                pdfBezierSegment.Point2 = points[index - 1];
                pdfBezierSegment.Point3 = points[index];

                yield return pdfBezierSegment;
            }
        }
Beispiel #14
0
 public static PolyBezierSegment ClonePolyBezierSegment(this PolyBezierSegment source)
 {
     if (source == null)
         return (PolyBezierSegment)null;
     PolyBezierSegment polyBezierSegment = new PolyBezierSegment();
     foreach (Point point in source.Points)
         polyBezierSegment.Points.Add(point);
     return polyBezierSegment;
 }
        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);
            };



        }
Beispiel #16
0
        private PathGeometry GetPathGeometry(int upperConnection, int rightConnection, int bottomConnection, int leftConnection, double[] blankCoords, double[] tabCoords)
        {
            var upperPoints = new List<Point>();
            var rightPoints = new List<Point>();
            var bottomPoints = new List<Point>();
            var leftPoints = new List<Point>();

            for (var i = 0; i < (tabCoords.Length / 2); i++)
            {
                double[] upperCoords = (upperConnection == (int)ConnectionType.Blank) ? blankCoords : tabCoords;
                double[] rightCoords = (rightConnection == (int)ConnectionType.Blank) ? blankCoords : tabCoords;
                double[] bottomCoords = (bottomConnection == (int)ConnectionType.Blank) ? blankCoords : tabCoords;
                double[] leftCoords = (leftConnection == (int)ConnectionType.Blank) ? blankCoords : tabCoords;

                upperPoints.Add(new Point(upperCoords[i * 2], 0 + upperCoords[i * 2 + 1] * upperConnection));
                rightPoints.Add(new Point((100 * _Scale) - rightCoords[i * 2 + 1] * rightConnection, rightCoords[i * 2]));
                bottomPoints.Add(new Point((100 * _Scale) - bottomCoords[i * 2], (100 * _Scale) - bottomCoords[i * 2 + 1] * bottomConnection));
                leftPoints.Add(new Point(0 + leftCoords[i * 2 + 1] * leftConnection, (100 * _Scale) - leftCoords[i * 2]));
            }

            var upperSegment = new PolyBezierSegment(upperPoints, true);
            var rightSegment = new PolyBezierSegment(rightPoints, true);
            var bottomSegment = new PolyBezierSegment(bottomPoints, true);
            var leftSegment = new PolyBezierSegment(leftPoints, true);

            var pathFigure = new PathFigure()
            {
                IsClosed = false,
                StartPoint = new Point(0, 0)
            };
            pathFigure.Segments.Add(upperSegment);
            pathFigure.Segments.Add(rightSegment);
            pathFigure.Segments.Add(bottomSegment);
            pathFigure.Segments.Add(leftSegment);

            var pathGeometry = new PathGeometry();
            pathGeometry.Figures.Add(pathFigure);
            return pathGeometry;
        }
Beispiel #17
0
 /// <summary>
 /// Returns new PolyBezierSegment by easing startValue to endValue using a time percentage 0 -> 1.
 /// </summary>
 /// <example>XAML: Points="0,0 200,0 300,100 300,0 400,0 600,100"</example>
 /// <seealso cref="http://msdn.microsoft.com/en-us/library/system.windows.media.polybeziersegment.aspx"/>
 public static PolyBezierSegment EaseValue(PolyBezierSegment startValue, PolyBezierSegment endValue, double percent)
 {
     return new PolyBezierSegment
     {
         Points = EaseValue(startValue.Points, endValue.Points, percent),
     };
 }
        /// <summary>
        /// FinishSegment - called to completed any outstanding Segment which may be present.
        /// </summary> 
        private void FinishSegment()
        { 
            if (_currentSegmentPoints != null) 
            {
                Debug.Assert(_currentFigure != null); 

                int count = _currentSegmentPoints.Count;

                Debug.Assert(count > 0); 

                // Is this the first segment? 
                if (_segments == null) 
                {
                    // While we could always just retrieve _currentFigure.Segments (which would auto-promote) 
                    // it's more efficient to create the collection ourselves and set it explicitly.

                    _segments = new PathSegmentCollection();
                    _currentFigure.Segments = _segments; 
                }
 
                PathSegment segment; 

                switch (_currentSegmentType) 
                {
                    case MIL_SEGMENT_TYPE.MilSegmentPolyLine:
                        if (count == 1)
                        { 
                            LineSegment lSegment = new LineSegment();
                            lSegment.Point = _currentSegmentPoints[0]; 
                            segment = lSegment; 
                        }
                        else 
                        {
                            PolyLineSegment pSegment = new PolyLineSegment();
                            pSegment.Points = _currentSegmentPoints;
                            segment = pSegment; 
                        }
                        break; 
                    case MIL_SEGMENT_TYPE.MilSegmentPolyBezier: 
                        if (count == 3)
                        { 
                            BezierSegment bSegment = new BezierSegment();
                            bSegment.Point1 = _currentSegmentPoints[0];
                            bSegment.Point2 = _currentSegmentPoints[1];
                            bSegment.Point3 = _currentSegmentPoints[2]; 
                            segment = bSegment;
                        } 
                        else 
                        {
                            Debug.Assert(count % 3 == 0); 

                            PolyBezierSegment pSegment = new PolyBezierSegment();
                            pSegment.Points = _currentSegmentPoints;
                            segment = pSegment; 
                        }
                        break; 
                    case MIL_SEGMENT_TYPE.MilSegmentPolyQuadraticBezier: 
                        if (count == 2)
                        { 
                            QuadraticBezierSegment qSegment = new QuadraticBezierSegment();
                            qSegment.Point1 = _currentSegmentPoints[0];
                            qSegment.Point2 = _currentSegmentPoints[1];
                            segment = qSegment; 
                        }
                        else 
                        { 
                            Debug.Assert(count % 2 == 0);
 
                            PolyQuadraticBezierSegment pSegment = new PolyQuadraticBezierSegment();
                            pSegment.Points = _currentSegmentPoints;
                            segment = pSegment;
                        } 
                        break;
                    default: 
                        segment = null; 
                        Debug.Assert(false);
                        break; 
                }

                // Handle common PathSegment properties.
                if (_currentSegmentIsStroked != s_defaultValueForPathSegmentIsStroked) 
                {
                    segment.IsStroked  = _currentSegmentIsStroked; 
                } 

                if (_currentSegmentIsSmoothJoin != s_defaultValueForPathSegmentIsSmoothJoin) 
                {
                    segment.IsSmoothJoin  = _currentSegmentIsSmoothJoin;
                }
 
                _segments.Add(segment);
 
                _currentSegmentPoints = null; 
                _currentSegmentType = MIL_SEGMENT_TYPE.MilSegmentNone;
            } 
        }
Beispiel #19
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);
        }
        public static void MoveUIElement(StackPanel control, double displacement)
        {
            DoubleAnimationUsingPath da = new DoubleAnimationUsingPath();
            da.Duration = time;
            da.DecelerationRatio = acceleration;

            PathGeometry pg = new PathGeometry();
            PathFigure pf = new PathFigure();
            pf.StartPoint = new Point(control.Margin.Left, control.Margin.Top);
            PolyBezierSegment pbs = new PolyBezierSegment();

            for(int i = 0; i < displacement; i++)
                pbs.Points.Add(new Point(control.Margin.Left, control.Margin.Top - i));

            pf.Segments.Add(pbs);
            pg.Figures.Add(pf);

            da.PathGeometry = pg;
            da.Source = PathAnimationSource.X;

            Storyboard sb = new Storyboard();
            sb.Children.Add(da);
            sb.Begin(control);
        }
Beispiel #21
0
            internal unsafe void AddFigureToList(bool isFilled, bool isClosed, MilPoint2F *pPoints, UInt32 pointCount, byte *pSegTypes, UInt32 segmentCount)
            {
                if (pointCount >= 1 && segmentCount >= 1)
                {
                    PathFigure figure = new PathFigure();

                    figure.IsFilled   = isFilled;
                    figure.StartPoint = new Point(pPoints->X, pPoints->Y);

                    int pointIndex   = 1;
                    int sameSegCount = 0;

                    for (int segIndex = 0; segIndex < segmentCount; segIndex += sameSegCount)
                    {
                        byte segType = (byte)(pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegTypeMask);

                        sameSegCount = 1;

                        // Look for a run of same-type segments for a PolyXXXSegment.
                        while (((segIndex + sameSegCount) < segmentCount) &&
                               (pSegTypes[segIndex] == pSegTypes[segIndex + sameSegCount]))
                        {
                            sameSegCount++;
                        }

                        bool fStroked = (pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegIsAGap) == (byte)0;
                        bool fSmooth  = (pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegSmoothJoin) != (byte)0;

                        if (segType == (byte)MILCoreSegFlags.SegTypeLine)
                        {
                            if (pointIndex + sameSegCount > pointCount)
                            {
                                throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                            }

                            if (sameSegCount > 1)
                            {
                                PointCollection ptCollection = new PointCollection();
                                for (int i = 0; i < sameSegCount; i++)
                                {
                                    ptCollection.Add(new Point(pPoints[pointIndex + i].X, pPoints[pointIndex + i].Y));
                                }
                                ptCollection.Freeze();

                                PolyLineSegment polySeg = new PolyLineSegment(ptCollection, fStroked, fSmooth);
                                polySeg.Freeze();

                                figure.Segments.Add(polySeg);
                            }
                            else
                            {
                                Debug.Assert(sameSegCount == 1);
                                figure.Segments.Add(new LineSegment(new Point(pPoints[pointIndex].X, pPoints[pointIndex].Y), fStroked, fSmooth));
                            }

                            pointIndex += sameSegCount;
                        }
                        else if (segType == (byte)MILCoreSegFlags.SegTypeBezier)
                        {
                            int pointBezierCount = sameSegCount * 3;

                            if (pointIndex + pointBezierCount > pointCount)
                            {
                                throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                            }

                            if (sameSegCount > 1)
                            {
                                PointCollection ptCollection = new PointCollection();
                                for (int i = 0; i < pointBezierCount; i++)
                                {
                                    ptCollection.Add(new Point(pPoints[pointIndex + i].X, pPoints[pointIndex + i].Y));
                                }
                                ptCollection.Freeze();

                                PolyBezierSegment polySeg = new PolyBezierSegment(ptCollection, fStroked, fSmooth);
                                polySeg.Freeze();

                                figure.Segments.Add(polySeg);
                            }
                            else
                            {
                                Debug.Assert(sameSegCount == 1);

                                figure.Segments.Add(new BezierSegment(
                                                        new Point(pPoints[pointIndex].X, pPoints[pointIndex].Y),
                                                        new Point(pPoints[pointIndex + 1].X, pPoints[pointIndex + 1].Y),
                                                        new Point(pPoints[pointIndex + 2].X, pPoints[pointIndex + 2].Y),
                                                        fStroked,
                                                        fSmooth));
                            }

                            pointIndex += pointBezierCount;
                        }
                        else
                        {
                            throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                        }
                    }

                    if (isClosed)
                    {
                        figure.IsClosed = true;
                    }

                    figure.Freeze();
                    Figures.Add(figure);

                    // Do not bother adding empty figures.
                }
            }
Beispiel #22
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);
        }
Beispiel #23
0
        private void dealcards()
        {
            ////////////////////////////////////////////////
            //////// Deal card 1 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard9 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform", moveCard9);
            card9.RenderTransform = moveCard9;

            //create the path
            PathGeometry animationPath9 = new PathGeometry();
            PathFigure pFigure9 = new PathFigure();
            pFigure9.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment9 = new PolyBezierSegment();
            pBezierSegment9.Points.Add(new Point(30, 350));
            pBezierSegment9.Points.Add(new Point(30, 350));
            pBezierSegment9.Points.Add(new Point(30, 350));
            pFigure9.Segments.Add(pBezierSegment9);
            animationPath9.Figures.Add(pFigure9);

            //freeze path for performance benefits
            animationPath9.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation9 = new DoubleAnimationUsingPath();
            translateXAnimation9.PathGeometry = animationPath9;
            translateXAnimation9.PathGeometry = animationPath9;
            translateXAnimation9.Duration = TimeSpan.FromSeconds(.5);

            //set source property to x
            translateXAnimation9.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation9, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateXAnimation9, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation9 = new DoubleAnimationUsingPath();
            translateYAnimation9.PathGeometry = animationPath9;
            translateYAnimation9.Duration = TimeSpan.FromSeconds(.5);

            translateYAnimation9.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation9, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateYAnimation9, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation9, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateYAnimation9, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 2 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard8 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform8", moveCard8);
            card8.RenderTransform = moveCard8;

            //create the path
            PathGeometry animationPath8 = new PathGeometry();
            PathFigure pFigure8 = new PathFigure();
            pFigure8.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment8 = new PolyBezierSegment();
            pBezierSegment8.Points.Add(new Point(130, 350));
            pBezierSegment8.Points.Add(new Point(130, 350));
            pBezierSegment8.Points.Add(new Point(130, 350));
            pFigure8.Segments.Add(pBezierSegment8);
               // animationPath8.Figures.Add(pFigure7);
            animationPath8.Figures.Add(pFigure8);

            //freeze path for performance benefits
            animationPath8.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation8 = new DoubleAnimationUsingPath();
            translateXAnimation8.PathGeometry = animationPath8;
            translateXAnimation8.PathGeometry = animationPath8;
            translateXAnimation8.Duration = TimeSpan.FromSeconds(.5);

            //set source property to x
            translateXAnimation8.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation8, "AnimatedTranslateTransform8");
            Storyboard.SetTargetProperty(translateXAnimation8, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation8 = new DoubleAnimationUsingPath();
            translateYAnimation8.PathGeometry = animationPath8;
            translateYAnimation8.Duration = TimeSpan.FromSeconds(.5);

            translateYAnimation8.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation8, "AnimatedTranslateTransform8");
            Storyboard.SetTargetProperty(translateYAnimation8, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation8, "AnimatedTranslateTransform8");
            Storyboard.SetTargetProperty(translateYAnimation8, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 3 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard7 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform7", moveCard7);
            card7.RenderTransform = moveCard7;

            //create the path
            PathGeometry animationPath7 = new PathGeometry();
            PathFigure pFigure7 = new PathFigure();
            pFigure7.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment7 = new PolyBezierSegment();
            pBezierSegment7.Points.Add(new Point(710, 350));
            pBezierSegment7.Points.Add(new Point(710, 350));
            pBezierSegment7.Points.Add(new Point(710, 350));
            pFigure7.Segments.Add(pBezierSegment7);
            animationPath7.Figures.Add(pFigure7);

            //freeze path for performance benefits
            animationPath7.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation7 = new DoubleAnimationUsingPath();
            translateXAnimation7.PathGeometry = animationPath7;
            translateXAnimation7.PathGeometry = animationPath7;
            translateXAnimation7.Duration = TimeSpan.FromSeconds(.7);

            //set source property to x
            translateXAnimation7.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation7, "AnimatedTranslateTransform7");
            Storyboard.SetTargetProperty(translateXAnimation7, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation7 = new DoubleAnimationUsingPath();
            translateYAnimation7.PathGeometry = animationPath7;
            translateYAnimation7.Duration = TimeSpan.FromSeconds(.7);

            translateYAnimation7.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation7, "AnimatedTranslateTransform7");
            Storyboard.SetTargetProperty(translateYAnimation7, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation7, "AnimatedTranslateTransform7");
            Storyboard.SetTargetProperty(translateYAnimation7, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 4 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard6 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform6", moveCard6);
            card6.RenderTransform = moveCard6;

            //create the path
            PathGeometry animationPath6 = new PathGeometry();
            PathFigure pFigure6 = new PathFigure();
            pFigure6.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment6 = new PolyBezierSegment();
            pBezierSegment6.Points.Add(new Point(810, 350));
            pBezierSegment6.Points.Add(new Point(810, 350));
            pBezierSegment6.Points.Add(new Point(810, 350));
            pFigure6.Segments.Add(pBezierSegment6);
            animationPath6.Figures.Add(pFigure6);

            //freeze path for performance benefits
            animationPath6.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation6 = new DoubleAnimationUsingPath();
            translateXAnimation6.PathGeometry = animationPath6;
            translateXAnimation6.PathGeometry = animationPath6;
            translateXAnimation6.Duration = TimeSpan.FromSeconds(.6);

            //set source property to x
            translateXAnimation6.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation6, "AnimatedTranslateTransform6");
            Storyboard.SetTargetProperty(translateXAnimation6, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation6 = new DoubleAnimationUsingPath();
            translateYAnimation6.PathGeometry = animationPath6;
            translateYAnimation6.Duration = TimeSpan.FromSeconds(.6);

            translateYAnimation6.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation6, "AnimatedTranslateTransform6");
            Storyboard.SetTargetProperty(translateYAnimation6, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation6, "AnimatedTranslateTransform6");
            Storyboard.SetTargetProperty(translateYAnimation6, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 5 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard5 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform5", moveCard5);
            card5.RenderTransform = moveCard5;

            //create the path
            PathGeometry animationPath5 = new PathGeometry();
            PathFigure pFigure5 = new PathFigure();
            pFigure5.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment5 = new PolyBezierSegment();
            pBezierSegment5.Points.Add(new Point(240, -10));
            pBezierSegment5.Points.Add(new Point(240, -10));
            pBezierSegment5.Points.Add(new Point(240, -10));
            pFigure5.Segments.Add(pBezierSegment5);
            animationPath5.Figures.Add(pFigure5);

            //freeze path for performance benefits
            animationPath5.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation5 = new DoubleAnimationUsingPath();
            translateXAnimation5.PathGeometry = animationPath5;
            translateXAnimation5.PathGeometry = animationPath5;
            translateXAnimation5.Duration = TimeSpan.FromSeconds(.5);

            //set source property to x
            translateXAnimation5.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation5, "AnimatedTranslateTransform5");
            Storyboard.SetTargetProperty(translateXAnimation5, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation5 = new DoubleAnimationUsingPath();
            translateYAnimation5.PathGeometry = animationPath5;
            translateYAnimation5.Duration = TimeSpan.FromSeconds(.5);

            translateYAnimation5.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation5, "AnimatedTranslateTransform5");
            Storyboard.SetTargetProperty(translateYAnimation5, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation5, "AnimatedTranslateTransform5");
            Storyboard.SetTargetProperty(translateYAnimation5, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 6 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard4 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform4", moveCard4);
            card4.RenderTransform = moveCard4;

            //create the path
            PathGeometry animationPath4 = new PathGeometry();
            PathFigure pFigure4 = new PathFigure();
            pFigure4.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment4 = new PolyBezierSegment();
            pBezierSegment4.Points.Add(new Point(340, -10));
            pBezierSegment4.Points.Add(new Point(340, -10));
            pBezierSegment4.Points.Add(new Point(340, -10));
            pFigure4.Segments.Add(pBezierSegment4);
            animationPath4.Figures.Add(pFigure4);

            //freeze path for performance benefits
            animationPath4.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation4 = new DoubleAnimationUsingPath();
            translateXAnimation4.PathGeometry = animationPath4;
            translateXAnimation4.PathGeometry = animationPath4;
            translateXAnimation4.Duration = TimeSpan.FromSeconds(.4);

            //set source property to x
            translateXAnimation4.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation4, "AnimatedTranslateTransform4");
            Storyboard.SetTargetProperty(translateXAnimation4, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation4 = new DoubleAnimationUsingPath();
            translateYAnimation4.PathGeometry = animationPath4;
            translateYAnimation4.Duration = TimeSpan.FromSeconds(.4);

            translateYAnimation4.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation4, "AnimatedTranslateTransform4");
            Storyboard.SetTargetProperty(translateYAnimation4, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation4, "AnimatedTranslateTransform4");
            Storyboard.SetTargetProperty(translateYAnimation4, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 7 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard3 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform3", moveCard3);
            card3.RenderTransform = moveCard3;

            //create the path
            PathGeometry animationPath3 = new PathGeometry();
            PathFigure pFigure3 = new PathFigure();
            pFigure3.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment3 = new PolyBezierSegment();
            pBezierSegment3.Points.Add(new Point(440, -10));
            pBezierSegment3.Points.Add(new Point(440, -10));
            pBezierSegment3.Points.Add(new Point(440, -10));
            pFigure3.Segments.Add(pBezierSegment3);
            animationPath3.Figures.Add(pFigure3);

            //freeze path for performance benefits
            animationPath3.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation3 = new DoubleAnimationUsingPath();
            translateXAnimation3.PathGeometry = animationPath3;
            translateXAnimation3.PathGeometry = animationPath3;
            translateXAnimation3.Duration = TimeSpan.FromSeconds(.3);

            //set source property to x
            translateXAnimation3.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation3, "AnimatedTranslateTransform3");
            Storyboard.SetTargetProperty(translateXAnimation3, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation3 = new DoubleAnimationUsingPath();
            translateYAnimation3.PathGeometry = animationPath3;
            translateYAnimation3.Duration = TimeSpan.FromSeconds(.3);

            translateYAnimation3.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation3, "AnimatedTranslateTransform3");
            Storyboard.SetTargetProperty(translateYAnimation3, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation3, "AnimatedTranslateTransform3");
            Storyboard.SetTargetProperty(translateYAnimation3, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 8 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard2 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform2", moveCard2);
            card2.RenderTransform = moveCard2;

            //create the path
            PathGeometry animationPath2 = new PathGeometry();
            PathFigure pFigure2 = new PathFigure();
            pFigure2.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment2 = new PolyBezierSegment();
            pBezierSegment2.Points.Add(new Point(540, -10));
            pBezierSegment2.Points.Add(new Point(540, -10));
            pBezierSegment2.Points.Add(new Point(540, -10));
            pFigure2.Segments.Add(pBezierSegment2);
            animationPath2.Figures.Add(pFigure2);

            //freeze path for performance benefits
            animationPath2.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation2 = new DoubleAnimationUsingPath();
            translateXAnimation2.PathGeometry = animationPath2;
            translateXAnimation2.PathGeometry = animationPath2;
            translateXAnimation2.Duration = TimeSpan.FromSeconds(.2);

            //set source property to x
            translateXAnimation2.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation2, "AnimatedTranslateTransform2");
            Storyboard.SetTargetProperty(translateXAnimation2, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation2 = new DoubleAnimationUsingPath();
            translateYAnimation2.PathGeometry = animationPath2;
            translateYAnimation2.Duration = TimeSpan.FromSeconds(.2);

            translateYAnimation2.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation2, "AnimatedTranslateTransform2");
            Storyboard.SetTargetProperty(translateYAnimation2, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation2, "AnimatedTranslateTransform2");
            Storyboard.SetTargetProperty(translateYAnimation2, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 9 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard1 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform1", moveCard1);
            card1.RenderTransform = moveCard1;

            //create the path
            PathGeometry animationPath1 = new PathGeometry();
            PathFigure pFigure1 = new PathFigure();
            pFigure1.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment1 = new PolyBezierSegment();
            pBezierSegment1.Points.Add(new Point(640, -10));
            pBezierSegment1.Points.Add(new Point(640, -10));
            pBezierSegment1.Points.Add(new Point(640, -10));
            pFigure1.Segments.Add(pBezierSegment1);
            animationPath1.Figures.Add(pFigure1);

            //freeze path for performance benefits
            animationPath1.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation1 = new DoubleAnimationUsingPath();
            translateXAnimation1.PathGeometry = animationPath1;
            translateXAnimation1.PathGeometry = animationPath1;
            translateXAnimation1.Duration = TimeSpan.FromSeconds(.1);

            //set source property to x
            translateXAnimation1.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation1, "AnimatedTranslateTransform1");
            Storyboard.SetTargetProperty(translateXAnimation1, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation1 = new DoubleAnimationUsingPath();
            translateYAnimation1.PathGeometry = animationPath1;
            translateYAnimation1.Duration = TimeSpan.FromSeconds(.1);

            translateYAnimation1.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation1, "AnimatedTranslateTransform1");
            Storyboard.SetTargetProperty(translateYAnimation1, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation1, "AnimatedTranslateTransform1");
            Storyboard.SetTargetProperty(translateYAnimation1, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal the cards ///////////////////////////
            ////////////////////////////////////////////////
            Storyboard pathAnimationStoryboard = new Storyboard();
            pathAnimationStoryboard.Children.Add(translateXAnimation9);
            pathAnimationStoryboard.Children.Add(translateYAnimation9);

            pathAnimationStoryboard.Children.Add(translateXAnimation8);
            pathAnimationStoryboard.Children.Add(translateYAnimation8);

            pathAnimationStoryboard.Children.Add(translateXAnimation7);
            pathAnimationStoryboard.Children.Add(translateYAnimation7);

            pathAnimationStoryboard.Children.Add(translateXAnimation6);
            pathAnimationStoryboard.Children.Add(translateYAnimation6);

            pathAnimationStoryboard.Children.Add(translateXAnimation5);
            pathAnimationStoryboard.Children.Add(translateYAnimation5);

            pathAnimationStoryboard.Children.Add(translateXAnimation4);
            pathAnimationStoryboard.Children.Add(translateYAnimation4);

            pathAnimationStoryboard.Children.Add(translateXAnimation3);
            pathAnimationStoryboard.Children.Add(translateYAnimation3);

            pathAnimationStoryboard.Children.Add(translateXAnimation2);
            pathAnimationStoryboard.Children.Add(translateYAnimation2);

            pathAnimationStoryboard.Children.Add(translateXAnimation1);
            pathAnimationStoryboard.Children.Add(translateYAnimation1);

            pathAnimationStoryboard.Begin(this);

            //change the image source of the card. will be used to display actual cards dealt to players/dealer
            string sUri = @"Images\clubs-2-150.png";
            Uri src = new Uri(sUri, UriKind.RelativeOrAbsolute);
            BitmapImage bmp = new BitmapImage(src);
            card9.Source = bmp;
            card8.Source = bmp;
            card7.Source = bmp;
            card6.Source = bmp;
            card5.Source = bmp;
            card4.Source = bmp;
            card3.Source = bmp;
        }
            internal unsafe void AddFigureToList(bool isFilled, bool isClosed, MilPoint2F* pPoints, UInt32 pointCount, byte* pSegTypes, UInt32 segmentCount)
            {
                if (pointCount >=1 && segmentCount >= 1)
                {
                    PathFigure figure = new PathFigure();

                    figure.IsFilled = isFilled;
                    figure.StartPoint = new Point(pPoints->X, pPoints->Y);

                    int pointIndex = 1;
                    int sameSegCount = 0;

                    for (int segIndex=0; segIndex<segmentCount; segIndex += sameSegCount)
                    {
                        byte segType = (byte)(pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegTypeMask);

                        sameSegCount = 1;

                        // Look for a run of same-type segments for a PolyXXXSegment.
                        while (((segIndex + sameSegCount) < segmentCount) &&
                            (pSegTypes[segIndex] == pSegTypes[segIndex+sameSegCount]))
                        {
                            sameSegCount++;
                        }

                        bool fStroked = (pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegIsAGap) == (byte)0;
                        bool fSmooth = (pSegTypes[segIndex] & (byte)MILCoreSegFlags.SegSmoothJoin) != (byte)0;

                        if (segType == (byte)MILCoreSegFlags.SegTypeLine)
                        {
                            if (pointIndex+sameSegCount > pointCount)
                            {
                                throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                            }

                            if (sameSegCount>1)
                            {
                                PointCollection ptCollection = new PointCollection();
                                for (int i=0; i<sameSegCount; i++)
                                {
                                    ptCollection.Add(new Point(pPoints[pointIndex+i].X, pPoints[pointIndex+i].Y));
                                }
                                ptCollection.Freeze();

                                PolyLineSegment polySeg = new PolyLineSegment(ptCollection, fStroked, fSmooth);
                                polySeg.Freeze();

                                figure.Segments.Add(polySeg);
                            }
                            else
                            {
                                Debug.Assert(sameSegCount == 1);
                                figure.Segments.Add(new LineSegment(new Point(pPoints[pointIndex].X, pPoints[pointIndex].Y), fStroked, fSmooth));
                            }

                            pointIndex += sameSegCount;
                        }
                        else if (segType == (byte)MILCoreSegFlags.SegTypeBezier)
                        {
                            int pointBezierCount = sameSegCount*3;

                            if (pointIndex+pointBezierCount > pointCount)
                            {
                                throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                            }

                            if (sameSegCount>1)
                            {
                                PointCollection ptCollection = new PointCollection();
                                for (int i=0; i<pointBezierCount; i++)
                                {
                                    ptCollection.Add(new Point(pPoints[pointIndex+i].X, pPoints[pointIndex+i].Y));
                                }
                                ptCollection.Freeze();

                                PolyBezierSegment polySeg = new PolyBezierSegment(ptCollection, fStroked, fSmooth);
                                polySeg.Freeze();

                                figure.Segments.Add(polySeg);
                            }
                            else
                            {
                                Debug.Assert(sameSegCount == 1);

                                figure.Segments.Add(new BezierSegment(
                                    new Point(pPoints[pointIndex].X, pPoints[pointIndex].Y),
                                    new Point(pPoints[pointIndex+1].X, pPoints[pointIndex+1].Y),
                                    new Point(pPoints[pointIndex+2].X, pPoints[pointIndex+2].Y),
                                    fStroked,
                                    fSmooth));
                            }

                            pointIndex += pointBezierCount;
                        }
                        else
                        {
                            throw new System.InvalidOperationException(SR.Get(SRID.PathGeometry_InternalReadBackError));
                        }
                    }

                    if (isClosed)
                    {
                        figure.IsClosed = true;
                    }

                    figure.Freeze();
                    Figures.Add(figure);

                    // Do not bother adding empty figures.
                }
            }
Beispiel #25
0
        /*
         * Animation Helper Methods
         */
        private void moveCard(Image cardImage, int absoluteX, int absoluteY)
        {
            string transformName = "theTransform";
                int x = absoluteX - (int)cardImage.Margin.Left;
                int y = absoluteY - (int)cardImage.Margin.Top;

                if (x != 0 && y != 0)
                {
                    //create translateTransform
                    TranslateTransform moveCard9 = new TranslateTransform();
                    this.RegisterName(transformName, moveCard9);
                    cardImage.RenderTransform = moveCard9;

                    //create the path
                    PathGeometry animationPath9 = new PathGeometry();
                    PathFigure pFigure9 = new PathFigure();
                    pFigure9.StartPoint = new Point(0, 0);
                    PolyBezierSegment pBezierSegment9 = new PolyBezierSegment();
                    pBezierSegment9.Points.Add(new Point(x, y));
                    pBezierSegment9.Points.Add(new Point(x, y));
                    pBezierSegment9.Points.Add(new Point(x, y));
                    pFigure9.Segments.Add(pBezierSegment9);
                    animationPath9.Figures.Add(pFigure9);

                    //freeze path for performance benefits
                    animationPath9.Freeze();

                    //create the animation to move the card horizontally
                    DoubleAnimationUsingPath translateXAnimation9 = new DoubleAnimationUsingPath();
                    translateXAnimation9.PathGeometry = animationPath9;
                    translateXAnimation9.Duration = TimeSpan.FromSeconds(1);
                    translateXAnimation9.Source = PathAnimationSource.X;

                    Storyboard.SetTargetName(translateXAnimation9, transformName);
                    Storyboard.SetTargetProperty(translateXAnimation9, new PropertyPath(TranslateTransform.XProperty));

                    //create the animation to move the card vertically
                    DoubleAnimationUsingPath translateYAnimation9 = new DoubleAnimationUsingPath();
                    translateYAnimation9.PathGeometry = animationPath9;
                    translateYAnimation9.Duration = TimeSpan.FromSeconds(1);
                    translateYAnimation9.Source = PathAnimationSource.Y;

                    Storyboard.SetTargetName(translateYAnimation9, transformName);
                    Storyboard.SetTargetProperty(translateYAnimation9, new PropertyPath(TranslateTransform.YProperty));

                    //create a storyboard
                    Storyboard pathAnimationStoryboard = new Storyboard();
                    pathAnimationStoryboard.Children.Add(translateXAnimation9);
                    pathAnimationStoryboard.Children.Add(translateYAnimation9);

                    //begin the storyboard
                    pathAnimationStoryboard.Begin(this);
                    this.UnregisterName(transformName);
                }
        }
Beispiel #26
0
        /// <summary>
        /// FinishSegment - called to completed any outstanding Segment which may be present.
        /// </summary>
        private void FinishSegment()
        {
            if (_currentSegmentPoints != null)
            {
                Debug.Assert(_currentFigure != null);

                int count = _currentSegmentPoints.Count;

                Debug.Assert(count > 0);

                // Is this the first segment?
                if (_segments == null)
                {
                    // While we could always just retrieve _currentFigure.Segments (which would auto-promote)
                    // it's more efficient to create the collection ourselves and set it explicitly.

                    _segments = new PathSegmentCollection();
                    _currentFigure.Segments = _segments;
                }

                PathSegment segment;

                switch (_currentSegmentType)
                {
                case MIL_SEGMENT_TYPE.MilSegmentPolyLine:
                    if (count == 1)
                    {
                        LineSegment lSegment = new LineSegment();
                        lSegment.Point = _currentSegmentPoints[0];
                        segment        = lSegment;
                    }
                    else
                    {
                        PolyLineSegment pSegment = new PolyLineSegment();
                        pSegment.Points = _currentSegmentPoints;
                        segment         = pSegment;
                    }
                    break;

                case MIL_SEGMENT_TYPE.MilSegmentPolyBezier:
                    if (count == 3)
                    {
                        BezierSegment bSegment = new BezierSegment();
                        bSegment.Point1 = _currentSegmentPoints[0];
                        bSegment.Point2 = _currentSegmentPoints[1];
                        bSegment.Point3 = _currentSegmentPoints[2];
                        segment         = bSegment;
                    }
                    else
                    {
                        Debug.Assert(count % 3 == 0);

                        PolyBezierSegment pSegment = new PolyBezierSegment();
                        pSegment.Points = _currentSegmentPoints;
                        segment         = pSegment;
                    }
                    break;

                case MIL_SEGMENT_TYPE.MilSegmentPolyQuadraticBezier:
                    if (count == 2)
                    {
                        QuadraticBezierSegment qSegment = new QuadraticBezierSegment();
                        qSegment.Point1 = _currentSegmentPoints[0];
                        qSegment.Point2 = _currentSegmentPoints[1];
                        segment         = qSegment;
                    }
                    else
                    {
                        Debug.Assert(count % 2 == 0);

                        PolyQuadraticBezierSegment pSegment = new PolyQuadraticBezierSegment();
                        pSegment.Points = _currentSegmentPoints;
                        segment         = pSegment;
                    }
                    break;

                default:
                    segment = null;
                    Debug.Assert(false);
                    break;
                }

                // Handle common PathSegment properties.
                if (_currentSegmentIsStroked != s_defaultValueForPathSegmentIsStroked)
                {
                    segment.IsStroked = _currentSegmentIsStroked;
                }

                if (_currentSegmentIsSmoothJoin != s_defaultValueForPathSegmentIsSmoothJoin)
                {
                    segment.IsSmoothJoin = _currentSegmentIsSmoothJoin;
                }

                _segments.Add(segment);

                _currentSegmentPoints = null;
                _currentSegmentType   = MIL_SEGMENT_TYPE.MilSegmentNone;
            }
        }
Beispiel #27
0
 private PathGeometry CreateAreaCurveGeometry()
 {
     PathGeometry pathGeometry = new PathGeometry();
     PathFigure pathFigure = new PathFigure();
     pathGeometry.Figures.Add(pathFigure);
     
     Point[] catmullRomPoints = new Point[_childrenPositions.Count];
     _childrenPositions.CopyTo(catmullRomPoints, 0);
     Point[] bezierPoints = GeometryOperation.CatmullRom(catmullRomPoints);
     pathFigure.StartPoint = bezierPoints[0];
     PolyBezierSegment pbs = new PolyBezierSegment();
     for (int i = 1; i < bezierPoints.GetLength(0); i++)
         pbs.Points.Add(bezierPoints[i]);
     pathFigure.Segments.Add(pbs);
     if (AreaBrush != null)
     {
         pathFigure.Segments.Add(new LineSegment(new Point(_childrenPositions[_childrenPositions.Count - 1].X, GetHorizontalAxis(this)), false));
         pathFigure.Segments.Add(new LineSegment(new Point(_childrenPositions[0].X, GetHorizontalAxis(this)), false));
     }
     return pathGeometry;
 }
Beispiel #28
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);
        }