Пример #1
0
 public BezierSegment AssignTo(BezierSegment segment)
 {
     segment.Point1 = P1;
     segment.Point2 = P2;
     segment.Point3 = P3;
     return segment;
 }
Пример #2
0
        internal static PathGeometry GetPathGeometry(ConnectorInfo source, ConnectorInfo sink)
        {
            var rectSource = GetRectWithMargin(source, 0);
            var rectSink = GetRectWithMargin(sink, 13);

            var startPoint = GetOffsetPoint(source, rectSource);
            var endPoint = GetOffsetPoint(sink, rectSink);

            var midpoint = CalculateMidpoint(startPoint, new Point(endPoint.X, startPoint.Y));
            var distance = CalculateDistance(startPoint, midpoint);

            var p1 = CalculateEndpoint(startPoint, distance, GetAngel(source.Orientation));
            var p2 = CalculateEndpoint(endPoint, distance, GetAngel(sink.Orientation));
            var p3 = endPoint;

            var geometry = new PathGeometry();

            var pathFigure = new PathFigure();
            pathFigure.StartPoint = startPoint;
            geometry.Figures.Add(pathFigure);

            var bs = new BezierSegment(p1, p2, p3, true);
            pathFigure.Segments.Add(bs);

            return geometry;
        }
Пример #3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.canvas1 = ((System.Windows.Controls.Canvas)(target));
                return;

            case 2:
                this.bezierSegment = ((System.Windows.Media.BezierSegment)(target));
                return;

            case 3:
                this.path1 = ((System.Windows.Shapes.Path)(target));
                return;

            case 4:
                this.line1 = ((System.Windows.Media.LineGeometry)(target));
                return;

            case 5:
                this.ellipse1 = ((System.Windows.Media.EllipseGeometry)(target));
                return;

            case 6:
                this.line2 = ((System.Windows.Media.LineGeometry)(target));
                return;

            case 7:
                this.ellipse2 = ((System.Windows.Media.EllipseGeometry)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #4
0
        internal void DrawBezier(double thickness, Color color, Point startPoint, Point controlPoint, Point endPoint)
        {
            PathFigure myPathFigure = new PathFigure();
            myPathFigure.StartPoint = startPoint;

            BezierSegment myBezierSegment = new BezierSegment(startPoint, endPoint, controlPoint, true);

            PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
            myPathSegmentCollection.Add(myBezierSegment);

            myPathFigure.Segments = myPathSegmentCollection;

            PathFigureCollection myPathFigureCollection = new PathFigureCollection();
            myPathFigureCollection.Add(myPathFigure);

            PathGeometry myPathGeometry = new PathGeometry();
            myPathGeometry.Figures = myPathFigureCollection;

            DrawingContext drawingContext = drawingVisual.RenderOpen();

            mySolidColorBrush.Color = color;
            //ApplyColortool(color.A);
            pen.Brush = mySolidColorBrush;
            pen.Thickness = thickness;

            drawingContext.DrawGeometry(null, pen, myPathGeometry);

            drawingContext.Close();
            image.Render(drawingVisual);
        }
Пример #5
0
        public dynConnector(dynPort port, Canvas workBench, Point mousePt)
        {
            //don't allow connections to start at an input port
            if (port.PortType != PortType.INPUT)
            {
                //get start point
                //this.workBench = workBench;
                pStart = port;

                pStart.Connect(this);

                //Create a Bezier;
                connector = new Path();
                connector.Stroke = Brushes.Black;
                connector.StrokeThickness = STROKE_THICKNESS;
                connector.Opacity = .8;

                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(5); dashArray.Add(2);
                connector.StrokeDashArray = dashArray;

                PathGeometry connectorGeometry = new PathGeometry();
                connectorPoints = new PathFigure();
                connectorCurve = new BezierSegment();

                connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
                connectorCurve.Point1 = connectorPoints.StartPoint;
                connectorCurve.Point2 = connectorPoints.StartPoint;
                connectorCurve.Point3 = connectorPoints.StartPoint;

                connectorPoints.Segments.Add(connectorCurve);
                connectorGeometry.Figures.Add(connectorPoints);
                connector.Data = connectorGeometry;
                workBench.Children.Add(connector);

                isDrawing = true;

                //set this to not draggable
                Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
                Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

                //set the z order to the front
                Canvas.SetZIndex(this, 300);

                //register an event listener for the start port update
                //this will tell the connector to set the elements at either
                //end to be equal if pStart and pEnd are not null
                //pStart.Owner.Outputs[pStart.Index].dynElementUpdated += new Dynamo.Elements.dynElementUpdatedHandler(StartPortUpdated);
            }
            else
            {
                throw new InvalidPortException();
            }
        }
Пример #6
0
        public void DrawSelf(Canvas c, bool IsFirstdraw = false)
        {
            
            double rightY = RightOvLine.lnNumber *  OvCollection.divHeight;
            //leftPointY = LeftTvLine.Top;
            //switch (this.tblType)
            //{
            //    case TriBezierLines.Bot:
            //        leftPointY = LeftTvLine.Bottom;
            //        break;
            //    case TriBezierLines.Mid:
            //        leftPointY = LeftTvLine.Bottom - LeftTvLine.Height / 2.0;
            //        break;
            //    case TriBezierLines.Top:
            //        leftPointY = LeftTvLine.Top;
            //        break;
            //    default:
            //        break;
            //}

            Point LeftPoint = new Point(0.0, leftPointY);
            Point RightPoint = new Point(RightOvLine._bzCurvArea, rightY);
            
            Point CtrlPoint1 = new Point(RightOvLine._bzCurvArea / 2.0, leftPointY);
            Point CtrlPoint2 = new Point(RightOvLine._bzCurvArea / 2.0, rightY);

            PathFigure pf = new PathFigure();

            pf.StartPoint = LeftPoint;

            BezierSegment bs1 = new BezierSegment(CtrlPoint1, CtrlPoint2, RightPoint, true);
            //BezierSegment bs2 = new BezierSegment(MidPoint, CtrlPoint2, RightPoint, true);
            pf.Segments.Add(bs1);
            //pf.Segments.Add(bs2);
            PathGeometry pg = new PathGeometry();
            pg.Figures.Add(pf);


            //myPath = new Path();
            if (this.tblType == TriBezierLines.Hover)
            {
                myPath.Stroke = Brushes.DarkGray;
            }
            else
                myPath.Stroke = Brushes.CornflowerBlue;
            myPath.StrokeThickness = OvLine.lnStrokeTh;
            myPath.Data = pg;

            if (/*IsFirstdraw && */!c.Children.Contains(myPath))
                c.Children.Add(myPath);
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.wave_control = ((WaveProgress.UserControl.WaveProgressControl)(target));
                return;

            case 2:
                this.bs_Water = ((System.Windows.Media.BezierSegment)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #8
0
        public Wire()
        {
            InitializeComponent();

            flow = new LinearGradientBrush(Colors.White, Colors.Red, 0);
            flow.MappingMode = BrushMappingMode.Absolute;
            flow.SpreadMethod = GradientSpreadMethod.Repeat;

            pf = new PathFigure();
            bz = new BezierSegment();
            pf.Segments.Add(bz);
            PathGeometry pg = new PathGeometry(new PathFigure[]{pf});
            Inner.Data = pg;
            Outer.Data = pg;

            Inner.Stroke = Brushes.White;
        }
Пример #9
0
 protected override Geometry getGeometry(double left = 0.0f, double top = 0.0f)
 {
     Point p = new Point(left, top);
     Point p1 = _addpoint(p, Point1);
     Point p2 = _addpoint(p, Point2);
     Point p3 = _addpoint(p, Point3);
     Point p0 = _addpoint(p, Point0);
     PathSegment ps = new BezierSegment(p1, p2, p3, true);
     List<PathSegment> l = new List<PathSegment>();
     l.Clear();
     l.Add(ps);
     PathFigure pf = new PathFigure(p0, l, false);
     pf.Segments.Add(ps);
     PathGeometry pg = new PathGeometry();
     pg.Figures.Add(pf);
     return pg;
 }
Пример #10
0
 public ArrowControl()
 {
     endPt1 = new BezierSegment();
       endPt2 = new LineSegment();
       arrowPt1 = new LineSegment();
       arrowPt2 = new LineSegment();
       headPt = new LineSegment();
       startPt2 = new BezierSegment();
       startPt1 = new PathFigure()
       {
     Segments = new PathSegmentCollection() { endPt1, arrowPt1, headPt, arrowPt2, endPt2, startPt2 },
     IsClosed = true
       };
       Shape = new Path() { Data = new PathGeometry() { Figures = new PathFigureCollection() { startPt1 } } };
       Shape.Stroke = Brushes.Red;
       Shape.Fill = fillBrush;
 }
Пример #11
0
        public BezierSegmentFrame(UIElement child, PathFigure fig, BezierSegment bez)
            : base(child)
        {
            bezier = bez;
            figure = fig;

            previous = null;

            foreach (PathSegment segment in figure.Segments) {
                BezierSegment bs = segment as BezierSegment;
                if (segment == bezier)
                    break;
                previous = segment;
            }

            point1_line = CreateLine();
            point2_line = CreateLine();
        }
        private void CreateAutoShape(object sender, RoutedEventArgs e)
        {
            PathGeometry sendingPath = new PathGeometry(); 
            PathFigure pathFigure = new PathFigure();
            pathFigure.StartPoint = new Point(47.7778, 48.6667);
            pathFigure.IsClosed = true;
            LineSegment lineSegment1 = new LineSegment();
            lineSegment1.Point = new Point(198, 48.6667);
            pathFigure.Segments.Add(lineSegment1);
            LineSegment lineSegment2 = new LineSegment();
            lineSegment2.Point = new Point(198, 102);
            pathFigure.Segments.Add(lineSegment2);
            BezierSegment bezierSegment1 = new BezierSegment();
            bezierSegment1.Point1 = new Point(174.889, 91.3334);
            bezierSegment1.Point2 = new Point(157.111, 79.7778);
            bezierSegment1.Point3 = new Point(110.889, 114.444);
            pathFigure.Segments.Add(bezierSegment1);
            BezierSegment bezierSegment2 = new BezierSegment();
            bezierSegment2.Point1 = new Point(64.667, 149.111);
            bezierSegment2.Point2 = new Point(58.4444, 130.444);
            bezierSegment2.Point3 = new Point(47.7778, 118.889);
            pathFigure.Segments.Add(bezierSegment2);
            sendingPath.Figures.Add(pathFigure);

            PathGeometry pathGeometry = new PathGeometry();
            if (sendingPath.FillRule != null)
                pathGeometry.FillRule = sendingPath.FillRule;
            else pathGeometry.FillRule = FillRule.Nonzero;
            pathGeometry.Figures = sendingPath.Figures;

            var newThumb = new SandRibbonInterop.AutoShape();
            var safePathGeometry = (Geometry)(new GeometryConverter().ConvertFromString(pathGeometry.ToString()));
            var safePathData = new PathGeometry();
            safePathData.AddGeometry(safePathGeometry);
            newThumb.PathData = safePathData;
            newThumb.Background = Brushes.LightGreen;
            newThumb.Foreground = Brushes.Green;
            newThumb.StrokeThickness = 5;
            newThumb.Height = 100;
            newThumb.Width = 100;
            
            Commands.AddAutoShape.Execute(newThumb);
        }
Пример #13
0
 public ArrowControl()
 {
     _endPt1 = new BezierSegment();
     _endPt2 = new LineSegment();
     _arrowPt1 = new LineSegment();
     _arrowPt2 = new LineSegment();
     _headPt = new LineSegment();
     _startPt2 = new BezierSegment();
     _startPt1 = new PathFigure
                     {
                         Segments =
                             new PathSegmentCollection
                                 {_endPt1, _arrowPt1, _headPt, _arrowPt2, _endPt2, _startPt2},
                         IsClosed = true
                     };
     Shape = new Path
                 {
                     Data = new PathGeometry {Figures = new PathFigureCollection {_startPt1}},
                     Stroke = Brushes.Red,
                     Fill = FillBrush
                 };
 }
Пример #14
0
		/// <summary>
		/// Transforms the specified path segment and returns the result.
		/// </summary>
		/// <param name="pathSegment">The path segment.</param>
		/// <param name="transform">The transform.</param>
		/// <returns></returns>
        public static PathSegment Transform(this PathSegment pathSegment, TransformGroup transform)
		{
			PathSegment ret;
			if (pathSegment is LineSegment)
				ret = new LineSegment { Point = ((LineSegment)pathSegment).Point.Transform(transform) };
			else if (pathSegment is ArcSegment)
			{
				var arcSegment = (ArcSegment) pathSegment;
			    var scaleTransform = transform.Children.OfType<ScaleTransform>().FirstOrDefault();
                var rotateTransform = transform.Children.OfType<RotateTransform>().FirstOrDefault();
                var size = new Size { Height = arcSegment.Size.Height * scaleTransform.ScaleY, Width = arcSegment.Size.Width * scaleTransform.ScaleX };
                ret = new ArcSegment { Point = arcSegment.Point.Transform(transform), Size = size, IsLargeArc = arcSegment.IsLargeArc, RotationAngle = rotateTransform.Angle };
			}
			else if (pathSegment is BezierSegment)
			{
				var bezierSegment = (BezierSegment)pathSegment;
				ret = new BezierSegment
				{
					Point1 = bezierSegment.Point1.Transform(transform),
					Point2 = bezierSegment.Point2.Transform(transform),
					Point3 = bezierSegment.Point3.Transform(transform),
				};
			}
			else if (pathSegment is QuadraticBezierSegment)
			{
				var bezierSegment = (QuadraticBezierSegment)pathSegment;
				ret = new QuadraticBezierSegment
				{
					Point1 = bezierSegment.Point1.Transform(transform),
					Point2 = bezierSegment.Point2.Transform(transform),
				};
			}
			else
				throw new Exception("Transform To implement");
			return ret;
		}
Пример #15
0
        /// <summary>
        /// Returns a Windows Media Bezier Spline Path Geometry from a Rhinocommon Curve
        /// </summary>
        /// <param name="input">Rhinocommon Curve</param>
        /// <returns>System Windows Media Bezier Curve Path Geometry </returns>
        public static Sm.PathGeometry ToGeometry(this Rg.Curve input)
        {
            Rg.NurbsCurve nurbsCurve = input.ToNurbsCurve();
            nurbsCurve.MakePiecewiseBezier(true);
            Rg.BezierCurve[] bezier = Rg.BezierCurve.CreateCubicBeziers(nurbsCurve, 0, 0);

            Sm.PathFigure            figure            = new Sm.PathFigure();
            Sm.PathGeometry          geometry          = new Sm.PathGeometry();
            Sm.PathFigureCollection  figureCollection  = new Sm.PathFigureCollection();
            Sm.PathSegmentCollection segmentCollection = new Sm.PathSegmentCollection();

            figure.StartPoint = bezier[0].GetControlVertex3d(0).ToWindowsPoint();
            for (int i = 0; i < bezier.Count(); i++)
            {
                Sm.BezierSegment segment = new Sm.BezierSegment(bezier[i].GetControlVertex3d(1).ToWindowsPoint(), bezier[i].GetControlVertex3d(2).ToWindowsPoint(), bezier[i].GetControlVertex3d(3).ToWindowsPoint(), true);
                segmentCollection.Add(segment);
            }

            figure.Segments = segmentCollection;
            figureCollection.Add(figure);
            geometry.Figures = figureCollection;

            return(geometry);
        }
        /// <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;
            } 
        }
Пример #17
0
    /// <summary>
    /// Draws a series of Bézier splines from an array of points.
    /// </summary>
    public void DrawBeziers(XPen pen, XPoint[] points)
    {
      if (pen == null)
        throw new ArgumentNullException("pen");

      int count = points.Length;
      if (count == 0)
        return;

      if ((count - 1) % 3 != 0)
        throw new ArgumentException("Invalid number of points for bezier curves. Number must fulfil 4+3n.", "points");

      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
          this.gfx.DrawBeziers(pen.RealizeGdiPen(), MakePointFArray(points));
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
        {
#if !SILVERLIGHT
          PathFigure figure = new PathFigure();
          figure.StartPoint = new System.Windows.Point(points[0].x, points[0].y);
          for (int idx = 1; idx < count; idx += 3)
          {
            BezierSegment seg = new BezierSegment(
              new System.Windows.Point(points[idx].x, points[idx].y),
              new System.Windows.Point(points[idx + 1].x, points[idx + 1].y),
              new System.Windows.Point(points[idx + 2].x, points[idx + 2].y), true);
            figure.Segments.Add(seg);
          }
          PathGeometry geo = new PathGeometry();
          geo.Figures.Add(figure);
          this.dc.DrawGeometry(null, pen.RealizeWpfPen(), geo);
#else
          // AGHACK
#endif
        }
#endif
      }

      if (this.renderer != null)
        this.renderer.DrawBeziers(pen, points);
    }
Пример #18
0
    /// <summary>
    /// Draws a Bézier spline defined by four points.
    /// </summary>
    public void DrawBezier(XPen pen, double x1, double y1, double x2, double y2,
      double x3, double y3, double x4, double y4)
    {
      if (pen == null)
        throw new ArgumentNullException("pen");

      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
          this.gfx.DrawBezier(pen.RealizeGdiPen(), (float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4);
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
        {
#if !SILVERLIGHT
          BezierSegment seg = new BezierSegment(new System.Windows.Point(x2, y2), new System.Windows.Point(x3, y3), new System.Windows.Point(x4, y4), true);
          PathFigure figure = new PathFigure();
          figure.StartPoint = new System.Windows.Point(x1, y1);
          figure.Segments.Add(seg);
          PathGeometry geo = new PathGeometry();
          geo.Figures.Add(figure);
          this.dc.DrawGeometry(null, pen.RealizeWpfPen(), geo);
#else
          // AGHACK
#endif
        }
#endif
      }

      if (this.renderer != null)
        this.renderer.DrawBeziers(pen,
          new XPoint[4]{new XPoint(x1, y1), new XPoint(x2, y2), 
          new XPoint(x3, y3), new XPoint(x4, y4)});
    }
Пример #19
0
        /// <inheritdoc/>
        public override void Draw(object dc, XCubicBezier cubicBezier, double dx, double dy, ImmutableArray<XProperty> db, XRecord r)
        {
            var _dc = dc as DrawingContext;

            var style = cubicBezier.Style;
            if (style == null)
                return;

            double thickness = style.Thickness / _state.ZoomX;
            double half = thickness / 2.0;

            Tuple<Brush, Pen> styleCached = _styleCache.Get(style);
            Brush fill;
            Pen stroke;
            if (styleCached != null)
            {
                fill = styleCached.Item1;
                stroke = styleCached.Item2;
            }
            else
            {
                fill = CreateBrush(style.Fill);
                stroke = CreatePen(style, thickness);
                _styleCache.Set(style, Tuple.Create(fill, stroke));
            }

            PathGeometry pg = _cubicBezierCache.Get(cubicBezier);
            if (pg != null)
            {
                var pf = pg.Figures[0];
                pf.StartPoint = new Point(cubicBezier.Point1.X + dx, cubicBezier.Point1.Y + dy);
                pf.IsFilled = cubicBezier.IsFilled;
                var bs = pf.Segments[0] as BezierSegment;
                bs.Point1 = new Point(cubicBezier.Point2.X + dx, cubicBezier.Point2.Y + dy);
                bs.Point2 = new Point(cubicBezier.Point3.X + dx, cubicBezier.Point3.Y + dy);
                bs.Point3 = new Point(cubicBezier.Point4.X + dx, cubicBezier.Point4.Y + dy);
                bs.IsStroked = cubicBezier.IsStroked;
            }
            else
            {
                var pf = new PathFigure()
                {
                    StartPoint = new Point(cubicBezier.Point1.X + dx, cubicBezier.Point1.Y + dy),
                    IsFilled = cubicBezier.IsFilled
                };
                var bs = new BezierSegment(
                        new Point(cubicBezier.Point2.X + dx, cubicBezier.Point2.Y + dy),
                        new Point(cubicBezier.Point3.X + dx, cubicBezier.Point3.Y + dy),
                        new Point(cubicBezier.Point4.X + dx, cubicBezier.Point4.Y + dy),
                        cubicBezier.IsStroked);
                //bs.Freeze();
                pf.Segments.Add(bs);
                //pf.Freeze();
                pg = new PathGeometry();
                pg.Figures.Add(pf);
                //pg.Freeze();

                _cubicBezierCache.Set(cubicBezier, pg);
            }

            DrawPathGeometryInternal(_dc, half, fill, stroke, cubicBezier.IsStroked, cubicBezier.IsFilled, pg);
        }
Пример #20
0
        private void DrawLineCurveInternal(DrawingContext dc, double half, Pen pen, XLine line, ref Point pt1, ref Point pt2, double dx, double dy)
        {
            double p1x = pt1.X;
            double p1y = pt1.Y;
            double p2x = pt2.X;
            double p2y = pt2.Y;
            XLineExtensions.GetCurvedLineBezierControlPoints(
                line.Style.LineStyle.CurveOrientation,
                line.Style.LineStyle.Curvature,
                line.Start.Alignment,
                line.End.Alignment,
                ref p1x, ref p1y,
                ref p2x, ref p2y);

            PathGeometry pg = _curvedLineCache.Get(line);
            if (pg != null)
            {
                var pf = pg.Figures[0];
                pf.StartPoint = new Point(pt1.X + dx, pt1.Y + dy);
                pf.IsFilled = false;
                var bs = pf.Segments[0] as BezierSegment;
                bs.Point1 = new Point(p1x + dx, p1y + dy);
                bs.Point2 = new Point(p2x + dx, p2y + dy);
                bs.Point3 = new Point(pt2.X + dx, pt2.Y + dy);
                bs.IsStroked = line.IsStroked;
            }
            else
            {
                var pf = new PathFigure()
                {
                    StartPoint = new Point(pt1.X + dx, pt1.Y + dy),
                    IsFilled = false
                };
                var bs = new BezierSegment(
                        new Point(p1x + dx, p1y + dy),
                        new Point(p2x + dx, p2y + dy),
                        new Point(pt2.X + dx, pt2.Y + dy),
                        line.IsStroked);
                //bs.Freeze();
                pf.Segments.Add(bs);
                //pf.Freeze();
                pg = new PathGeometry();
                pg.Figures.Add(pf);
                //pg.Freeze();

                _curvedLineCache.Set(line, pg);
            }

            DrawPathGeometryInternal(dc, half, null, pen, line.IsStroked, false, pg);
        }
Пример #21
0
        void UpdateCurve(ThumbPosition thumbPosition, Point currentPosition)
        {
            Point startBezierPoint, endBezierPoint;

            switch (thumbPosition)
            {
                case ThumbPosition.Top:
                    startBezierPoint = new Point(startPoint.X, startPoint.Y - GridCanvas.BezierYOffset);
                    endBezierPoint = new Point(currentPosition.X, currentPosition.Y - GridCanvas.BezierYOffset);
                    break;

                default:
                case ThumbPosition.Bottom:
                    startBezierPoint = new Point(startPoint.X, startPoint.Y + GridCanvas.BezierYOffset);
                    endBezierPoint = new Point(currentPosition.X, currentPosition.Y - GridCanvas.BezierYOffset);
                    break;

                case ThumbPosition.Right:
                    startBezierPoint = new Point(startPoint.X + GridCanvas.BezierYOffset, startPoint.Y);
                    endBezierPoint = new Point(currentPosition.X - GridCanvas.BezierYOffset, currentPosition.Y);
                    break;

                case ThumbPosition.Left:
                    startBezierPoint = new Point(startPoint.X - GridCanvas.BezierYOffset, startPoint.Y);
                    endBezierPoint = new Point(currentPosition.X + GridCanvas.BezierYOffset, currentPosition.Y);
                    break;
            }

            BezierSegment bezierSegment = new BezierSegment(startBezierPoint, endBezierPoint, currentPosition, true);

            Path[] curves = ownerCanvas.Curves.Values.Where(
                path => path.Name.StartsWith(ownerElement.GetLink(thumbPosition).From)).ToArray();

            foreach (PathGeometry curveGeometry in curves.Select(curve => (PathGeometry)curve.Data))
            {
                if (curveGeometry.Figures[0].Segments.Count == 0)
                    curveGeometry.Figures[0].Segments.Add(bezierSegment);
                else
                    curveGeometry.Figures[0].Segments[0] = bezierSegment;
            }
        }
Пример #22
0
        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;
        }
Пример #23
0
        public void AdaugCampie()
        {
            Campie = new Path()
            {
                StrokeThickness = 2,
                Fill=new SolidColorBrush(Colors.Transparent),
                Cursor=Cursors.Hand
               
            };
            PathFigure PathFigureCampie = new PathFigure() { StartPoint = new Point(0, 400) };
            LineSegment l = new LineSegment() { Point = new Point(0, 505) };
            PathFigureCampie.Segments.Add(l);
            l = new LineSegment() { Point = new Point(canv.Width-1, canv.Height) };
            PathFigureCampie.Segments.Add(l);
            l = new LineSegment() { Point = new Point(canv.Width - 1, canv.Height-70) };
            PathFigureCampie.Segments.Add(l);
            BezierSegment bs = new BezierSegment() { Point1 = new Point(canv.Width - 1, canv.Height - 70), Point2 = new Point(690, 470), Point3 = new Point(655, 420) };
            PathFigureCampie.Segments.Add(bs);
            bs = new BezierSegment() { Point1 = new Point(655, 420), Point2 = new Point(655, 360), Point3 = new Point(565, 350) };
            PathFigureCampie.Segments.Add(bs);
            bs = new BezierSegment() { Point1 = new Point(565, 350), Point2 = new Point(520, 350), Point3 = new Point(465, 320) };
            PathFigureCampie.Segments.Add(bs);
            bs = new BezierSegment() { Point1 = new Point(465, 320), Point2 = new Point(380, 210), Point3 = new Point(320, 204) };
            PathFigureCampie.Segments.Add(bs);
            bs = new BezierSegment() { Point1 = new Point(320, 204), Point2 = new Point(200, 224), Point3 = new Point(180, 238) };
            PathFigureCampie.Segments.Add(bs);
            bs = new BezierSegment() { Point1 = new Point(180, 238), Point2 = new Point(100, 268), Point3 = new Point(97, 298) };
            PathFigureCampie.Segments.Add(bs);
            bs = new BezierSegment() { Point1 = new Point(97, 298), Point2 = new Point(140, 328), Point3 = new Point(0, 400) };
            PathFigureCampie.Segments.Add(bs);
            PathGeometry geometry = new PathGeometry();

            geometry.Figures.Add(PathFigureCampie);
            Campie.Data = geometry;
            canv.Children.Add(Campie);
            Campie.MouseEnter += new MouseEventHandler(Campie_MouseEnter);
            Campie.MouseLeave += new MouseEventHandler(Campie_MouseLeave);
            Campie.MouseLeftButtonDown += new MouseButtonEventHandler(Campie_MouseLeftButtonDown);
        }
		private void ConvertPart(PathThumb senderThumb, PathPartConvertType convertType)
		{
			if (senderThumb.PathPoint.ParentObject is PathFigure)
			{
				var pathFigure = senderThumb.PathPoint.ParentObject as PathFigure;
				var pathSegment = senderThumb.PathPoint.Object as PathSegment;

				var idx = pathFigure.Segments.IndexOf(pathSegment);

				var point = senderThumb.PathPoint.Point;

				if (pathSegment is PolyLineSegment) {
					var poly = pathSegment as PolyLineSegment;
					var lst = poly.Points.Take(senderThumb.PathPoint.PolyLineIndex);
					var lst2 = poly.Points.Skip(senderThumb.PathPoint.PolyLineIndex + 1);
					var p = poly.Points[senderThumb.PathPoint.PolyLineIndex];
					pathFigure.Segments.RemoveAt(idx);
					var p1 = new PolyLineSegment();
					p1.Points.AddRange(lst);
					pathFigure.Segments.Insert(idx, p1);
					pathSegment =  new LineSegment() {Point = p};
					pathFigure.Segments.Insert(idx+1, pathSegment);
					var p2 = new PolyLineSegment();
					p2.Points.AddRange(lst2);
					pathFigure.Segments.Insert(idx+2, p2);
					idx++;
				} else if (pathSegment is PolyBezierSegment) {
					//TODO
				} else if (pathSegment is PolyQuadraticBezierSegment) {
					//TODO
				}

				pathFigure.Segments.RemoveAt(idx);

				var midp = senderThumb.PathPoint.ParentPathPoint.Point - ((senderThumb.PathPoint.ParentPathPoint.Point - point) / 2);
				
				PathSegment newSegment = null;
				switch (convertType)
				{
					case PathPartConvertType.ToBezierSegment:
						newSegment = new BezierSegment() { Point1 = midp - new Vector(40, 40), Point2 = midp + new Vector(-40, 40), Point3 = point };
						break;
					case PathPartConvertType.ToQuadricBezierSegment:
						newSegment = new QuadraticBezierSegment() { Point1 = point - new Vector(40, 40), Point2 = point  };
						break;
					case PathPartConvertType.ToArcSegment:
						newSegment = new ArcSegment() { Point = point, Size = new Size(20, 20) };
						break;
					case PathPartConvertType.insertPoint:
						pathFigure.Segments.Insert(idx, pathSegment);
						newSegment = new LineSegment() { Point = midp, };
						break;
					default:
						newSegment = new LineSegment() { Point = point };
						break;
				}

				pathFigure.Segments.Insert(idx, newSegment);
			}

			this.ExtendedItem.ReapplyAllExtensions();
		}
Пример #25
0
        private static System.Windows.Point BezierSegmentPoint(BezierSegment quadraticBezier, System.Windows.Point startPoint, double t)
		{
			double t1 = 1 - t;
            return new System.Windows.Point
			       	{
			       		X = t1*t1*t1*startPoint.X + 3*t1*t1*t*quadraticBezier.Point1.X +
			       		    3*t1*t*t*quadraticBezier.Point2.X + t*t*t*quadraticBezier.Point3.X,
			       		Y = t1*t1*t1*startPoint.Y + 3*t1*t1*t*quadraticBezier.Point1.Y +
			       		    3*t1*t*t*quadraticBezier.Point2.Y + t*t*t*quadraticBezier.Point3.Y
			       	};
		}
Пример #26
0
        public pesteHarta(Canvas can, PlaneProjection p,Image img, Canvas md,MapLayers mapLayer,Map map)
        {
            ServiceReference1.TranzactiiClient tc = new ServiceReference1.TranzactiiClient(bind, endpoint);
            tc.GetHistoryPadureCompleted += new EventHandler<ServiceReference1.GetHistoryPadureCompletedEventArgs>(tc_GetHistoryPadureCompleted);
            tc.GetHistoryPadureAsync();
           // retine = md;
            this.mapLayer = mapLayer;
            this.map = map;
            this.md = md;
            this.p = p;
            this.img = img;

            // Alex code
            // Preia meniul de login din LoginForm
            // La intoarcerea din padure sau campie Meniu Dreapta contine MeniuAnimal sau MeniuPlanta
            // iar la intoarcere este necesar ca in Meniu Dreapta sa se afle PaginaUser

            // Nu mai e nevoie de toata partea asta
            /*UIElement[] array = LoginForm.getInstance().getMeniuDreapta();
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].GetType() == typeof(PaginaUser))
                {
                    Rember = (PaginaUser)array[i];
                    break;
                }
            }*/
            
            md.Children.Clear();

            // Preia instanta PaginaUser
            // Actualizeaza regiunea curenta
            Rember = PaginaUser.getInstance();
            Rember.updateCurrentRegion();

            // Adaug manual PaginaUser, altfel apare un bug in care nu am nici un
            // meniu in partea stanga
            // Verific daca are deja parinte sa nu dea eroare
            if (Rember.Parent == null)
            {
                this.md.Children.Add(Rember);
            }
            
            // End of Alex code

            verifica = null;
            tmr.Interval = new TimeSpan(0, 0, 0, 0, 200);
            tmr.Tick += new EventHandler(tmr_Tick);
            tmr.Start();
            #region Padure
            Padure = new Path()
            {
                StrokeThickness = 4,

            };
            Padure.MouseLeftButtonDown += new MouseButtonEventHandler(Padure_MouseLeftButtonDown);
            Padure.Cursor = Cursors.Hand;
            PathFigure PathFigurepadure = new PathFigure() { StartPoint = new Point(0, 2) };
            LineSegment l = new LineSegment() { Point = new Point(2, 333) };
            PathFigurepadure.Segments.Add(l);
            BezierSegment bs = new BezierSegment() { Point1 = new Point(14, 333), Point2 = new Point(30, 310), Point3 = new Point(30, 270) };
            PathFigurepadure.Segments.Add(bs);
            bs = new BezierSegment() { Point1 = new Point(30, 270), Point2 = new Point(30, 250), Point3 = new Point(50, 245) };
            PathFigurepadure.Segments.Add(bs);
            //bs = new BezierSegment() { Point1 = new Point(40, 250), Point2 = new Point(40, 254), Point3 = new Point(85, 235) };
            //PathFigurepadure.Segments.Add(bs);
            l = new LineSegment() { Point = new Point(400, 115) };
            PathFigurepadure.Segments.Add(l);
            bs = new BezierSegment() { Point1 = new Point(400, 115), Point2 = new Point(529, 65), Point3 = new Point(445, 2) };
            PathFigurepadure.Segments.Add(bs);
            l = new LineSegment() { Point = new Point(0, 2) };
            PathFigurepadure.Segments.Add(l);
           
            PathGeometry geometry = new PathGeometry();

            geometry.Figures.Add(PathFigurepadure);
            Padure.Data = geometry;

            Padure.Fill = new SolidColorBrush(Colors.Transparent);
            //  Padure.Stroke = new SolidColorBrush(Color.FromArgb(0xFF,0x00,0x00,0x00));
            Padure.MouseEnter += new MouseEventHandler(Padure_MouseEnter);
            Padure.MouseLeave += new MouseEventHandler(Padure_MouseLeave);

            can.Children.Add(Padure);
            #endregion
            canv = can;
            #region Raul miscator
            #region Sus
             el = new Path();
            BezierSegment b;
            PathFigure pf;
            PathGeometry j;
            el.Fill = new SolidColorBrush(Color.FromArgb(0x55, 0x0a, 0x76, 0xd1));
            //el.Fill = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00));
            el.Effect = hh;
            pf = new PathFigure() { StartPoint = new Point(500, 2) };
            b = new BezierSegment() { Point1 = new Point(500, 2), Point2 = new Point(600, 70), Point3 = new Point(430, 140) };

            pf.Segments.Add(b);
            LineSegment ls = new LineSegment() { Point = new Point(420, 130) };
            pf.Segments.Add(ls);
            b = new BezierSegment() { Point1 = new Point(420, 130), Point2 = new Point(550, 70), Point3 = new Point(480, 2) };
            pf.Segments.Add(b);
            j = new PathGeometry();
            j.Figures.Add(pf);
            el.Data = j;
            canv.Children.Add(el);
            #endregion
             mijloc = new Path();

            // mijloc.Fill = new SolidColorBrush(Color.FromArgb(0x55, 0x0a, 0x76, 0xd1));

            mijloc.StrokeThickness = 3;
            mijloc.Stroke = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00));
            //     mijloc.Fill = new SolidColorBrush(Color.FromArgb(0x99, 0x0d, 0x74, 0xd1));
            //        mijloc.Effect = hh;
            pf = new PathFigure() { StartPoint = new Point(370, 150) };
            b = new BezierSegment() { Point1 = new Point(370, 150), Point2 = new Point(400, 190), Point3 = new Point(330, 185) };

            pf.Segments.Add(b);
            ls = new LineSegment() { Point = new Point(320, 175) };
            pf.Segments.Add(ls);
            b = new BezierSegment() { Point1 = new Point(320, 175), Point2 = new Point(260, 170), Point3 = new Point(380, 150) };
            pf.Segments.Add(b);
            j = new PathGeometry();
            j.Figures.Add(pf);
            mijloc.Data = j;
            canv.Children.Add(mijloc);
            #endregion

            AdaugCampie();
        }
Пример #27
0
        public void Update()
        {
            double X1 = startPoint.X;
            double Y1 = startPoint.Y;
            double X2 = endPoint.X;
            double Y2 = endPoint.Y;
            double theta = Math.Atan2(Y1 - Y2, X1 - X2);
            double sint = Math.Sin(theta + 0.2);
            double cost = Math.Cos(theta + 0.2);

            Point pt1 = new Point(X1, Y1);
            Point pt2 = new Point(X2, Y2);

            Point pt3 = new Point(
                X2 + (HeadWidth * cost - HeadHeight * sint),
                Y2 + (HeadWidth * sint + HeadHeight * cost));

            Point pt4 = new Point(
                X2 + (HeadWidth * cost + HeadHeight * sint),
                Y2 - (HeadHeight * cost - HeadWidth * sint));

            double midLength = Math.Sqrt(Math.Pow(X2 - X1, 2) + Math.Pow(Y2 - Y1, 2)) / 2;

            Point ptx = new Point(pt1.X - midLength * Math.Cos(theta - 0.2), pt1.Y - midLength * Math.Sin(theta - 0.2));

            this.Connector.X1 = pt1.X;
            this.Connector.Y1 = pt1.Y;
            this.Connector.X2 = pt2.X;
            this.Connector.Y2 = pt2.Y;
            this.Cap1.X1 = pt2.X;
            this.Cap1.Y1 = pt2.Y;
            this.Cap1.X2 = pt3.X;
            this.Cap1.Y2 = pt3.Y;
            this.Cap2.X1 = pt2.X;
            this.Cap2.Y1 = pt2.Y;
            this.Cap2.X2 = pt4.X;
            this.Cap2.Y2 = pt4.Y;

            BezierSegment bs = new BezierSegment();
            bs.Point1 = pt1;
            bs.Point2 = ptx;
            bs.Point3 = pt2;
            PathFigure pf = new PathFigure();
            pf.StartPoint = pt1;
            pf.Segments.Add(bs);
            PathGeometry pg = new PathGeometry();
            pg.Figures.Add(pf);
            this.bezier.Data = pg;
            this.bezier.StrokeThickness = this.StrokeThickness;
            this.bezier.Stroke = this.Stroke;

            Cap1.StrokeThickness = this.StrokeThickness;
            Cap1.Stroke = this.Stroke;
            Cap2.StrokeThickness = this.StrokeThickness;
            Cap2.Stroke = this.Stroke;
        }
Пример #28
0
 /// <summary>
 /// Returns new BezierSegment  by easing startValue to endValue using a time percentage 0 -> 1.
 /// </summary>
 /// <example>XAML: Data="M 10,100 C 100,0 200,200 300,100"</example>
 /// <seealso cref="http://msdn.microsoft.com/en-us/library/system.windows.media.beziersegment.aspx"/>
 public static BezierSegment EaseValue(BezierSegment startValue, BezierSegment endValue, double percent)
 {
     return new BezierSegment 
     {
         Point1 = EaseValue(startValue.Point1, endValue.Point1, percent),
         Point2 = EaseValue(startValue.Point2, endValue.Point2, percent),
         Point3 = EaseValue(startValue.Point3, endValue.Point3, percent)
     };
 }
Пример #29
0
        public void AutoTurnPage(CornerOrigin fromCorner, int duration)
        {
            if (Status != PageStatus.None)
                return;

            Status = PageStatus.TurnAnimation;

            UIElement source = this as UIElement;

            this.BeginAnimation(BookPage.CornerPointProperty, null);

            Point startPoint = OriginToPoint(this, fromCorner);
            Point endPoint = OriginToOppositePoint(this, fromCorner);

            CornerPoint = startPoint;
            origin = fromCorner;

            BezierSegment bs =
                new BezierSegment(startPoint, new Point(endPoint.X + (startPoint.X - endPoint.X) / 3, 250), endPoint, true);

            PathGeometry path = new PathGeometry();
            PathFigure figure = new PathFigure();
            figure.StartPoint = startPoint;
            figure.Segments.Add(bs);
            figure.IsClosed = false;
            path.Figures.Add(figure);

            PointAnimationUsingPath anim =
                new PointAnimationUsingPath();
            anim.PathGeometry = path;
            anim.Duration = new Duration(TimeSpan.FromMilliseconds(duration));
            anim.AccelerationRatio = 0.6;

            anim.CurrentTimeInvalidated += new EventHandler(anim_CurrentTimeInvalidated);
            anim.Completed += new EventHandler(anim_Completed);
            this.BeginAnimation(BookPage.CornerPointProperty, anim);
        }
Пример #30
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.ExampleBeginStoryboard = ((System.Windows.Media.Animation.BeginStoryboard)(target));
                return;

            case 2:
                this.ExampleStoryboard = ((System.Windows.Media.Animation.Storyboard)(target));
                return;

            case 3:
                this.mySplineKeyFrame = ((System.Windows.Media.Animation.SplineDoubleKeyFrame)(target));
                return;

            case 4:
                this.myVector3DSplineKeyFrame = ((System.Windows.Media.Animation.SplineDoubleKeyFrame)(target));
                return;

            case 5:
                this.thePanel = ((System.Windows.Controls.StackPanel)(target));
                return;

            case 6:
                this.SliderControlPoint1X = ((System.Windows.Controls.Slider)(target));

            #line 404 "..\..\..\..\Examples\BezierTimeExample\BezierTimeExample.xaml"
                this.SliderControlPoint1X.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.OnSliderChanged);

            #line default
            #line hidden
                return;

            case 7:
                this.SliderControlPoint1Y = ((System.Windows.Controls.Slider)(target));

            #line 408 "..\..\..\..\Examples\BezierTimeExample\BezierTimeExample.xaml"
                this.SliderControlPoint1Y.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.OnSliderChanged);

            #line default
            #line hidden
                return;

            case 8:
                this.SliderControlPoint2X = ((System.Windows.Controls.Slider)(target));

            #line 412 "..\..\..\..\Examples\BezierTimeExample\BezierTimeExample.xaml"
                this.SliderControlPoint2X.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.OnSliderChanged);

            #line default
            #line hidden
                return;

            case 9:
                this.SliderControlPoint2Y = ((System.Windows.Controls.Slider)(target));

            #line 417 "..\..\..\..\Examples\BezierTimeExample\BezierTimeExample.xaml"
                this.SliderControlPoint2Y.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.OnSliderChanged);

            #line default
            #line hidden
                return;

            case 10:
                this.keySplineText = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 11:
                this.SplineIllustrationSegment = ((System.Windows.Media.BezierSegment)(target));
                return;

            case 12:
                this.SplineControlPoint1Marker = ((System.Windows.Media.EllipseGeometry)(target));
                return;

            case 13:
                this.SplineControlPoint2Marker = ((System.Windows.Media.EllipseGeometry)(target));
                return;

            case 14:
                this.SplineProgressTransform = ((System.Windows.Media.TranslateTransform)(target));
                return;

            case 15:
                this.TimeProgressTransform = ((System.Windows.Media.TranslateTransform)(target));
                return;

            case 16:
                this.myPerspectiveCamera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 17:
                this.myHorizontalRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 18:
                this.myVerticalRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 19:
                this.myTranslateTransform3D = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #31
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);
        }
Пример #32
0
        private void AnimateToRightSheet()
        {
            DoubleAnimation translateAnimation = new DoubleAnimation(-Width / 4, new Duration(TimeSpan.FromMilliseconds(500)));

            BezierSegment bs =
                new BezierSegment(new Point(0, 1), new Point(1, 0.5), new Point(2, 1), true);

            PathGeometry path = new PathGeometry();
            PathFigure figure = new PathFigure();
            figure.StartPoint = new Point(0, 1);
            figure.Segments.Add(bs);
            figure.IsClosed = false;
            path.Figures.Add(figure);

            DoubleAnimationUsingPath scaleAnimation = new DoubleAnimationUsingPath();
            scaleAnimation.PathGeometry = path;
            scaleAnimation.Source = PathAnimationSource.Y;
            scaleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(500));

            translate.BeginAnimation(TranslateTransform.XProperty, translateAnimation);
            scale.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            scale.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
        }
Пример #33
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dc"></param>
        /// <param name="bezier"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object dc, XBezier bezier, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
        {
            var _dc = dc as DrawingContext;

            var style = bezier.Style;
            if (style == null)
                return;

            double thickness = style.Thickness / _state.Zoom;
            double half = thickness / 2.0;

            Tuple<Brush, Pen> cache = null;
            Brush fill;
            Pen stroke;
            if (_enableStyleCache
                && _styleCache.TryGetValue(style, out cache))
            {
                fill = cache.Item1;
                stroke = cache.Item2;
            }
            else
            {
                fill = CreateBrush(style.Fill);
                stroke = CreatePen(style, thickness);
                if (_enableStyleCache)
                    _styleCache.Add(style, Tuple.Create(fill, stroke));
            }

            PathGeometry pg = null;
            if (_enableBezierCache
                && _bezierCache.TryGetValue(bezier, out pg))
            {
                var pf = pg.Figures[0];
                pf.StartPoint = new Point(bezier.Point1.X + dx, bezier.Point1.Y + dy);
                pf.IsFilled = bezier.IsFilled;
                var bs = pf.Segments[0] as BezierSegment;
                bs.Point1 = new Point(bezier.Point2.X + dx, bezier.Point2.Y + dy);
                bs.Point2 = new Point(bezier.Point3.X + dx, bezier.Point3.Y + dy);
                bs.Point3 = new Point(bezier.Point4.X + dx, bezier.Point4.Y + dy);
                bs.IsStroked = bezier.IsStroked;
            }
            else
            {
                var pf = new PathFigure()
                {
                    StartPoint = new Point(bezier.Point1.X + dx, bezier.Point1.Y + dy),
                    IsFilled = bezier.IsFilled
                };
                var bs = new BezierSegment(
                        new Point(bezier.Point2.X + dx, bezier.Point2.Y + dy),
                        new Point(bezier.Point3.X + dx, bezier.Point3.Y + dy),
                        new Point(bezier.Point4.X + dx, bezier.Point4.Y + dy),
                        bezier.IsStroked);
                //bs.Freeze();
                pf.Segments.Add(bs);
                //pf.Freeze();
                pg = new PathGeometry();
                pg.Figures.Add(pf);
                //pg.Freeze();

                if (_enableBezierCache)
                    _bezierCache.Add(bezier, pg);
            }

            DrawPathGeometryInternal(_dc, half, fill, stroke, bezier.IsStroked, bezier.IsFilled, pg);
        }
Пример #34
0
        public dynConnector(dynNodeUI start, dynNodeUI end, int startIndex, int endIndex, int portType, bool visible)
        {
            //don't try to create a connector with a bad start,
            //end, or if we're trying to connector the same
            //port to itself.
            if (start == null || end == null || start == end)
            {
                throw new Exception("Attempting to create connector with invalid start or end nodes.");
            }

            pStart = start.OutPorts[startIndex];

            dynPort endPort = null;

            if (portType == 0)
                endPort = end.InPorts[endIndex];

            //connect the two ports
            //get start point

            pStart.Connect(this);

            BrushConverter bc = new BrushConverter();
            strokeBrush = (Brush)bc.ConvertFrom("#313131");

            #region bezier creation
            connector = new Path();
            connector.Stroke = strokeBrush;
            connector.StrokeThickness = STROKE_THICKNESS;
            connector.Opacity = STROKE_OPACITY;

            connector.DataContext = this;
            Binding strokeBinding = new Binding("StrokeBrush");
            connector.SetBinding(Path.StrokeProperty, strokeBinding);

            DoubleCollection dashArray = new DoubleCollection();
            dashArray.Add(5); dashArray.Add(2);
            connector.StrokeDashArray = dashArray;

            PathGeometry connectorGeometry = new PathGeometry();
            connectorPoints = new PathFigure();
            connectorCurve = new BezierSegment();

            connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
            connectorCurve.Point1 = connectorPoints.StartPoint;
            connectorCurve.Point2 = connectorPoints.StartPoint;
            connectorCurve.Point3 = connectorPoints.StartPoint;

            connectorPoints.Segments.Add(connectorCurve);
            connectorGeometry.Figures.Add(connectorPoints);
            connector.Data = connectorGeometry;
            dynSettings.Workbench.Children.Add(connector);
            #endregion

            #region polyline creation
            plineConnector = new Path();
            plineConnector.Stroke = strokeBrush;
            plineConnector.StrokeThickness = STROKE_THICKNESS;
            plineConnector.Opacity = STROKE_OPACITY;
            plineConnector.StrokeDashArray = dashArray;

            PathGeometry plineGeometry = new PathGeometry();
            //http://msdn.microsoft.com/en-us/library/system.windows.media.polylinesegment(v=vs.85).aspx
            plineFigure = new PathFigure();
            plineFigure.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
            Point[] polyLinePointArray = new Point[] { connectorPoints.StartPoint,
                connectorPoints.StartPoint,
                connectorPoints.StartPoint};
            pline = new PolyLineSegment(polyLinePointArray, true);
            pline.Points = new PointCollection(polyLinePointArray);
            plineFigure.Segments.Add(pline);
            plineGeometry.Figures.Add(plineFigure);
            plineConnector.Data = plineGeometry;
            dynSettings.Workbench.Children.Add(plineConnector);
            #endregion

            endDot = new Ellipse();
            endDot.Height = 6;
            endDot.Width = 6;
            endDot.Fill = Brushes.Black;
            endDot.StrokeThickness = 2;
            endDot.Stroke = Brushes.Black;
            endDot.IsHitTestVisible = false;
            endDot.MouseDown +=new System.Windows.Input.MouseButtonEventHandler(endDot_MouseDown);
            Canvas.SetTop(endDot, connectorCurve.Point3.Y - END_DOT_SIZE / 2);
            Canvas.SetLeft(endDot, connectorCurve.Point3.X - END_DOT_SIZE / 2);
            dynSettings.Workbench.Children.Add(endDot);
            endDot.Opacity = STROKE_OPACITY;
            endDot.IsHitTestVisible = false;
            endDot.MouseDown += new System.Windows.Input.MouseButtonEventHandler(endDot_MouseDown);

            this.Visible = visible;

            connector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
            connector.MouseLeave += delegate { Unhighlight(); };
            plineConnector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
            plineConnector.MouseLeave += delegate { Unhighlight(); };

            isDrawing = true;

            //set this to not draggable
            Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
            Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

            //set the z order to the front
            //Canvas.SetZIndex(this, 300);
            Canvas.SetZIndex(this, 1);

            this.Connect(endPort);

            ConnectorType = dynSettings.Bench.ConnectorType;
        }
Пример #35
0
        public dynConnector(dynPort port, Canvas workBench, Point mousePt)
        {
            //don't allow connections to start at an input port
            if (port.PortType != PortType.INPUT)
            {
                //get start point
                //this.workBench = workBench;
                pStart = port;

                pStart.Connect(this);

                BrushConverter bc = new BrushConverter();
                strokeBrush = (Brush)bc.ConvertFrom("#313131");

                #region bezier creation
                connector = new Path();
                connector.Stroke = strokeBrush;
                connector.StrokeThickness = STROKE_THICKNESS;
                connector.Opacity = STROKE_OPACITY;

                connector.DataContext = this;
                Binding strokeBinding = new Binding("StrokeBrush");
                connector.SetBinding(Path.StrokeProperty, strokeBinding);

                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(5); dashArray.Add(2);
                connector.StrokeDashArray = dashArray;

                PathGeometry connectorGeometry = new PathGeometry();
                connectorPoints = new PathFigure();
                connectorCurve = new BezierSegment();

                connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
                connectorCurve.Point1 = connectorPoints.StartPoint;
                connectorCurve.Point2 = connectorPoints.StartPoint;
                connectorCurve.Point3 = connectorPoints.StartPoint;

                connectorPoints.Segments.Add(connectorCurve);
                connectorGeometry.Figures.Add(connectorPoints);
                connector.Data = connectorGeometry;
                workBench.Children.Add(connector);
                #endregion

                #region polyline creation
                plineConnector = new Path();
                plineConnector.Stroke = strokeBrush;
                plineConnector.StrokeThickness = STROKE_THICKNESS;
                plineConnector.Opacity = STROKE_OPACITY;
                plineConnector.StrokeDashArray = dashArray;

                PathGeometry plineGeometry = new PathGeometry();
                //http://msdn.microsoft.com/en-us/library/system.windows.media.polylinesegment(v=vs.85).aspx
                plineFigure = new PathFigure();
                plineFigure.StartPoint = connectorPoints.StartPoint;
                Point[] polyLinePointArray = new Point[] { connectorPoints.StartPoint,
                connectorPoints.StartPoint,
                connectorPoints.StartPoint};
                pline = new PolyLineSegment(polyLinePointArray, true);
                pline.Points = new PointCollection(polyLinePointArray);
                plineFigure.Segments.Add(pline);
                plineGeometry.Figures.Add(plineFigure);
                plineConnector.Data = plineGeometry;
                dynSettings.Workbench.Children.Add(plineConnector);
                #endregion

                endDot = new Ellipse();
                endDot.Height = 6;
                endDot.Width = 6;
                endDot.Fill = Brushes.Black;
                endDot.StrokeThickness = 2;
                endDot.Stroke = Brushes.Black;
                endDot.IsHitTestVisible = false;
                endDot.MouseDown += new System.Windows.Input.MouseButtonEventHandler(endDot_MouseDown);
                Canvas.SetTop(endDot, connectorCurve.Point3.Y - END_DOT_SIZE / 2);
                Canvas.SetLeft(endDot, connectorCurve.Point3.X - END_DOT_SIZE / 2);
                dynSettings.Workbench.Children.Add(endDot);
                endDot.Opacity = STROKE_OPACITY;

                connector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
                connector.MouseLeave += delegate { Unhighlight(); };
                plineConnector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
                plineConnector.MouseLeave += delegate { Unhighlight(); };

                isDrawing = true;

                //set this to not draggable
                Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
                Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

                //set the z order to the front
                Canvas.SetZIndex(connector, 0);
                Canvas.SetZIndex(endDot, 1);

                ConnectorType = dynSettings.Bench.ConnectorType;

            }
            else
            {
                throw new InvalidPortException();
            }
        }
Пример #36
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.path = ((System.Windows.Shapes.Path)(target));
     
     #line 11 "..\..\..\..\..\Interface\Designer\Connection.xaml"
     this.path.MouseEnter += new System.Windows.Input.MouseEventHandler(this.MouseEnter);
     
     #line default
     #line hidden
     
     #line 11 "..\..\..\..\..\Interface\Designer\Connection.xaml"
     this.path.MouseLeave += new System.Windows.Input.MouseEventHandler(this.MouseLeave);
     
     #line default
     #line hidden
     
     #line 11 "..\..\..\..\..\Interface\Designer\Connection.xaml"
     this.path.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.MouseUp);
     
     #line default
     #line hidden
     return;
     case 2:
     this.start = ((System.Windows.Media.EllipseGeometry)(target));
     return;
     case 3:
     this.end = ((System.Windows.Media.EllipseGeometry)(target));
     return;
     case 4:
     this.line = ((System.Windows.Media.PathFigure)(target));
     return;
     case 5:
     this.bezier = ((System.Windows.Media.BezierSegment)(target));
     return;
     case 6:
     this.PreviewWindow = ((ShaderComposer.Interface.Designer.PreviewWindow)(target));
     return;
     }
     this._contentLoaded = true;
 }
Пример #37
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;
            }
        }