public override void Draw(StreamGeometryContext context, Connection connection)
        {
            if (connection.SourceConnectionPoint == null || connection.TargetConnectionPoint == null)
            {
                context.BeginFigure(connection.StartPoint, true, false);
                context.LineTo(connection.EndPoint, true, true);
            }
            else if(connection.Source == connection.Target)
            {
                Point startPoint = connection.SourceEndPoint.EndPoint;
                Point midPoint = connection.SourceConnectionPoint.LineAwayFromThisTo(startPoint, 50);

                context.BeginFigure(startPoint, true, true);
                context.ArcTo(midPoint, new Size(50, 50), 180, false, SweepDirection.Clockwise, true, true);
                context.ArcTo(startPoint, new Size(50, 50), 180, false, SweepDirection.Clockwise, true, true);
            }
            else
            {
                Point startPoint = connection.SourceEndPoint.EndPoint;
                Point endPoint = connection.TargetEndPoint.EndPoint;

                context.BeginFigure(startPoint, true, false);
                context.LineTo(endPoint, true, true);
            }
        }
 private static void AddCircleToGeometry(StreamGeometryContext streamGeometryContext, Point[] points, double pointSize)
 {
     foreach (Point point in points)
     {
         streamGeometryContext.BeginFigure(new Point(point.X - (pointSize / 2), point.Y - (pointSize / 2)), true, true);
         streamGeometryContext.ArcTo(new Point(point.X - (pointSize / 2) - 0.0001, point.Y - (pointSize / 2)),
             new Size(pointSize, pointSize), 360, true, SweepDirection.Clockwise, true, false);
     }
 }
示例#3
0
        private void DrawGeometry(StreamGeometryContext context, Point centre, float RotationAngle, float WedgeAngle, float Radius, float InnerRadius)
        {
            var innerArcStartPoint = ComputeCartesianCoordinate(RotationAngle, InnerRadius);
            innerArcStartPoint.Offset(centre.X, centre.Y);

            var innerArcEndPoint = ComputeCartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius);
            innerArcEndPoint.Offset(centre.X, centre.Y);

            var outerArcStartPoint = ComputeCartesianCoordinate(RotationAngle, Radius);
            outerArcStartPoint.Offset(centre.X, centre.Y);

            var outerArcEndPoint = ComputeCartesianCoordinate(RotationAngle + WedgeAngle, Radius);
            outerArcEndPoint.Offset(centre.X, centre.Y);

            var largeArc = WedgeAngle > 180.0;

            var outerArcSize = new Size(Radius, Radius);
            var innerArcSize = new Size(InnerRadius, InnerRadius);

            context.BeginFigure(innerArcStartPoint, true, true);
            context.LineTo(outerArcStartPoint, true, true);
            context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
            context.LineTo(innerArcEndPoint, true, true);
            context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true);
        }
示例#4
0
 /// <summary>
 /// SerializeData - Serialize the contents of this Segment to the provided context.
 /// </summary>
 internal override void SerializeData(StreamGeometryContext ctx)
 {
     ctx.ArcTo(Point, Size, RotationAngle, IsLargeArc, SweepDirection, IsStroked, IsSmoothJoin);
 }
示例#5
0
 /// <summary>
 /// SerializeData - Serialize the contents of this Segment to the provided context.
 /// </summary>
 internal override void SerializeData(StreamGeometryContext ctx)
 {
     ctx.ArcTo(Point, Size, RotationAngle, IsLargeArc, SweepDirection, IsStroked, IsSmoothJoin);
 }
        public static void AddArrow(StreamGeometryContext context,Point start,Point end, double thickness) {
            
            if(thickness > 1) {
                Point dir = end - start;
                Point h = dir;
                double dl = dir.Length;
                if(dl < 0.001)
                    return;
                dir /= dl;

                var s = new Point(-dir.Y,dir.X);
                double w = 0.5 * thickness;
                Point s0 = w * s;

                s *= h.Length * HalfArrowAngleTan;
                s += s0;

                double rad = w / HalfArrowAngleCos;

                context.BeginFigure(Common.WpfPoint(start + s),true,true);
                context.LineTo(Common.WpfPoint(start - s),true,false);
                context.LineTo(Common.WpfPoint(end - s0),true,false);
                context.ArcTo(Common.WpfPoint(end + s0),new Size(rad,rad),
                              Math.PI - ArrowAngle,false,SweepDirection.Clockwise,true,false);
            } else {
                Point dir = end - start;
                double dl = dir.Length;
                //take into account the widths
                double delta = Math.Min(dl / 2, thickness + thickness / 2);
                dir *= (dl - delta) / dl;
                end = start + dir;
                dir = dir.Rotate(Math.PI / 2);
                Point s = dir * HalfArrowAngleTan;

                context.BeginFigure(Common.WpfPoint(start + s),true,true);
                context.LineTo(Common.WpfPoint(end),true,true);
                context.LineTo(Common.WpfPoint(start - s),true,true);
            }
        }
        static internal void FillContextForICurve(StreamGeometryContext context,ICurve iCurve) {
            
            context.BeginFigure(Common.WpfPoint(iCurve.Start),false,false);

            var c = iCurve as Curve;
            if(c != null)
                FillContexForCurve(context,c);
            else {
                var cubicBezierSeg = iCurve as CubicBezierSegment;
                if(cubicBezierSeg != null)
                    context.BezierTo(Common.WpfPoint(cubicBezierSeg.B(1)),Common.WpfPoint(cubicBezierSeg.B(2)),
                                     Common.WpfPoint(cubicBezierSeg.B(3)),true,false);
                else {
                    var ls = iCurve as LineSegment;
                    if(ls != null)
                        context.LineTo(Common.WpfPoint(ls.End),true,false);
                    else {
                        var rr = iCurve as RoundedRect;
                        if(rr != null)
                            FillContexForCurve(context,rr.Curve);
                        else {
                            var poly = iCurve as Polyline;
                            if (poly != null)
                                FillContexForPolyline(context, poly);
                            else
                            {
                                var ellipse = iCurve as Ellipse;
                                if (ellipse != null) {
                                    //       context.LineTo(Common.WpfPoint(ellipse.End),true,false);
                                    double sweepAngle = EllipseSweepAngle(ellipse);
                                    bool largeArc = Math.Abs(sweepAngle) >= Math.PI;
                                    Rectangle box = ellipse.FullBox();
                                    context.ArcTo(Common.WpfPoint(ellipse.End),
                                                  new Size(box.Width/2, box.Height/2),
                                                  sweepAngle,
                                                  largeArc,
                                                  sweepAngle < 0
                                                      ? SweepDirection.Counterclockwise
                                                      : SweepDirection.Clockwise,
                                                  true, true);
                                } else {
                                    throw new NotImplementedException();
                                }
                            }
                        }
                    }
                }
            }
        }
示例#8
0
        /// <summary>
        /// Draws the pie piece
        /// </summary>
        private void DrawGeometry(StreamGeometryContext context)
        {
            var innerArcStartPoint = Utils.ComputeCartesianCoordinate(RotationAngle, InnerRadius);
            innerArcStartPoint.Offset(CentreX, CentreY);
            var innerArcEndPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius);
            innerArcEndPoint.Offset(CentreX, CentreY);
            var outerArcStartPoint = Utils.ComputeCartesianCoordinate(RotationAngle, Radius);
            outerArcStartPoint.Offset(CentreX, CentreY);
            var outerArcEndPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, Radius);
            outerArcEndPoint.Offset(CentreX, CentreY);
            var innerArcMidPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle * .5, InnerRadius);
            innerArcMidPoint.Offset(CentreX, CentreY);
            var outerArcMidPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle * .5, Radius);
            outerArcMidPoint.Offset(CentreX, CentreY);

            var largeArc = WedgeAngle > 180.0d;
            var requiresMidPoint = Math.Abs(WedgeAngle - 360) < .01;

            if (PushOut > 0 && !requiresMidPoint)
            {
                var offset = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle / 2, PushOut);
                innerArcStartPoint.Offset(offset.X, offset.Y);
                innerArcEndPoint.Offset(offset.X, offset.Y);
                outerArcStartPoint.Offset(offset.X, offset.Y);
                outerArcEndPoint.Offset(offset.X, offset.Y);
            }

            var outerArcSize = new Size(Radius, Radius);
            var innerArcSize = new Size(InnerRadius, InnerRadius);

            if (requiresMidPoint)
            {
                context.BeginFigure(innerArcStartPoint, true, true);
                context.LineTo(outerArcStartPoint, true, true);
                context.ArcTo(outerArcMidPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true);
                context.ArcTo(outerArcEndPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true);
                context.LineTo(innerArcEndPoint, true, true);
                context.ArcTo(innerArcMidPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true);
                context.ArcTo(innerArcStartPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true);
                return;
            }
            context.BeginFigure(innerArcStartPoint, true, true);
            context.LineTo(outerArcStartPoint, true, true);
            context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
            context.LineTo(innerArcEndPoint, true, true);
            context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true);
        }
示例#9
0
文件: Wedge.cs 项目: wshanshan/DDD
        /// <summary>
        /// Draws the primitive geometric components of the wedge.
        /// </summary>
        /// <param name="context">The context.</param>
        public void InternalDrawGeometry(StreamGeometryContext context)
        {
            Point startPoint = center;

            Point innerArcStartPoint = ComputeCartesianCoordinate(rotationAngle, innerRadius);
            innerArcStartPoint.Offset(center.X, center.Y);

            Point innerArcEndPoint = ComputeCartesianCoordinate(rotationAngle + sweep, innerRadius);
            innerArcEndPoint.Offset(center.X, center.Y);

            Point outerArcStartPoint = ComputeCartesianCoordinate(rotationAngle, /*innerRadius +*/ outerRadius);
            outerArcStartPoint.Offset(center.X, center.Y);

            Point outerArcEndPoint = ComputeCartesianCoordinate(rotationAngle + sweep, /*innerRadius +*/ outerRadius);
            outerArcEndPoint.Offset(center.X, center.Y);

            bool largeArc = sweep > 180.0;

           /*
                Point offset = ComputeCartesianCoordinate(rotationAngle + sweep / 2, PushOut);
                innerArcStartPoint.Offset(offset.X, offset.Y);
                innerArcEndPoint.Offset(offset.X, offset.Y);
                outerArcStartPoint.Offset(offset.X, offset.Y);
                outerArcEndPoint.Offset(offset.X, offset.Y);
            */

            Size outerArcSize = new Size(/*innerRadius +*/ outerRadius, /*innerRadius +*/ outerRadius);
            Size innerArcSize = new Size(innerRadius, innerRadius);

            context.BeginFigure(innerArcStartPoint, true, true);
            context.LineTo(outerArcStartPoint, true, true);
            context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
            context.LineTo(innerArcEndPoint, true, true);
            context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true);
        }
示例#10
0
      /// <summary>See <c>WpfExtensions</c> for details.</summary>
      public static void AddRectangleFigure(StreamGeometryContext ctx, Rect rect, bool fill, bool stroke, CornerRadius corners, CornerStyle cornerStyle) {
         double x0 = rect.Left, x1 = rect.Right, y0 = rect.Top, y1 = rect.Bottom;
         double TL = corners.TopLeft, TR = corners.TopRight, BL = corners.BottomLeft, BR = corners.BottomRight;
         var sweep = (cornerStyle == CornerStyle.Round ? SweepDirection.Counterclockwise : SweepDirection.Clockwise);
         var round = (cornerStyle != CornerStyle.Diagonal);

         // left side
         ctx.BeginFigure(new Point(x0, y0 + TL), fill, true);
         ctx.LineTo(new Point(x0, y1 - BL), stroke, false);

         // bottom-left corner
         if (BL > 0) {
            var bl = new Point(x0 + BL, y1);
            if (round) {
               ctx.ArcTo(bl, new Size(BL, BL), 0, false, sweep, stroke, false);
            } else {
               ctx.LineTo(bl, stroke, false);
            }
         }

         // bottom side
         ctx.LineTo(new Point(x1 - BR, y1), stroke, false);

         // bottom-right corner
         if (BR > 0) {
            var br = new Point(x1, y1 - BR);
            if (round) {
               ctx.ArcTo(br, new Size(BR, BR), 0, false, sweep, stroke, false);
            } else {
               ctx.LineTo(br, stroke, false);
            }
         }

         // right side
         ctx.LineTo(new Point(x1, y0 + TR), stroke, false);

         // top-right corner
         if (TR > 0) {
            var tr = new Point(x1 - TR, y0);
            if (round) {
               ctx.ArcTo(tr, new Size(TR, TR), 0, false, sweep, stroke, false);
            } else {
               ctx.LineTo(tr, stroke, false);
            }
         }

         // top side and top-left corner
         if (TL > 0) {
            ctx.LineTo(new Point(x0 + TL, y0), stroke, false);
            if (round) {
               ctx.ArcTo(new Point(x0, y0 + TL), new Size(TL, TL), 0, false, sweep, stroke, false);
            }
         }
      }
示例#11
0
        private void InternalDrawArrowGeometry(StreamGeometryContext context)
        {
            double theta;
            if (this.CurveDirection == CurveDirection.Concave)
                theta = Math.Atan2(Y1 - Y2, X1 - X2) + (Math.PI / 10);
            else
                theta = Math.Atan2(Y1 - Y2, X1 - X2) - (Math.PI / 10);

            double sint = Math.Sin(theta);
            double cost = Math.Cos(theta);

            Point pt1 = new Point(X1, this.Y1);
            Point pt2 = new Point(X2, this.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 ellipseSize = Math.Max(Math.Abs(X1 - X2), Math.Abs(Y1 - Y2)) * 1.7;

            context.BeginFigure(pt1, true, false);
            if (this.CurveDirection == CurveDirection.Concave)
                context.ArcTo(pt2, new Size(ellipseSize, ellipseSize), 45, false, SweepDirection.Clockwise, true, true);
            else
                context.ArcTo(pt2, new Size(ellipseSize, ellipseSize), 45, false, SweepDirection.Counterclockwise, true, true);
            //context.LineTo(pt2, true, true);
            context.LineTo(pt3, true, true);
            context.LineTo(pt2, true, true);
            context.LineTo(pt4, true, true);
            context.LineTo(pt2, true, true);
        }
示例#12
0
        private void InternalDrawArrowGeometry(StreamGeometryContext context)
        {
            Point pt1, pt2, pt3, pt4;
            if (ConnectionArrowType == ConnectionArrowType.Normal)
            {
                var theta = Math.Atan2(Y1 - Y2, X1 - X2);
                var sint = Math.Sin(theta);
                var cost = Math.Cos(theta);

                switch (ViewType)
                {
                    case 0: // прямая в центр
                        pt1 = new Point(X1, Y1);
                        pt2 = new Point(X2, Y2);

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

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

                        context.BeginFigure(pt1, true, false);
                        context.LineTo(pt2, true, true);
                        context.LineTo(pt3, true, true);
                        context.LineTo(pt2, true, true);
                        context.LineTo(pt4, true, true);
                        break;

                    case 1: // безье (слабое) в центр
                        pt1 = new Point(X1, Y1);
                        pt2 = new Point(X2, Y2);

                        var ptTemp1 = new Point(
                            X1 - (X1 - X2) / 2,
                            Y1 - (Y1 - Y2) / 3);

                        var ptTemp2 = new Point(
                            X1 - (X1 - X2) / 4 * 3,
                            Y1 - (Y1 - Y2) / 3 * 2);

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

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

                        context.BeginFigure(pt1, true, false);
                        context.BezierTo(ptTemp1, ptTemp2, pt2, true, true);
                        context.LineTo(pt3, true, true);
                        context.LineTo(pt2, true, true);
                        context.LineTo(pt4, true, true);
                        break;

                    case 2: // к ближайшему краю
                        var startPoint = GetBoundPoint(false);
                        X1 = startPoint.X;
                        Y1 = startPoint.Y;

                        var endPoint = GetBoundPoint(true);
                        X2 = endPoint.X;
                        Y2 = endPoint.Y;

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

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

                        context.BeginFigure(startPoint, true, false);
                        context.LineTo(endPoint, true, false);
                        context.LineTo(pt3, true, true);
                        context.LineTo(endPoint, true, true);
                        context.LineTo(pt4, true, true);
                        break;
                }
            }
            else if (ConnectionArrowType == ConnectionArrowType.Loopback)
            {
                pt1 = new Point(FromItem.Position.X - 5, FromItem.Position.Y + 83);
                pt2 = new Point(pt1.X + 10, pt1.Y - 10);

                pt3 = new Point(pt2.X - 4, pt2.Y + 9);
                pt4 = new Point(pt2.X - 6, pt2.Y + 16);

                context.BeginFigure(pt1, true, false);
                context.ArcTo(pt2, new Size(6, 6), 125, true, SweepDirection.Clockwise, true, true);
                context.ArcTo(pt1, new Size(6, 6), 125, true, SweepDirection.Clockwise, true, true);
                context.LineTo(pt3, true, true);
                context.LineTo(pt1, true, true);
                context.LineTo(pt4, true, true);
            }
            else
            {
                pt1 = new Point(X1 + 20, Y1 - 25);
                pt2 = new Point(pt1.X + 10, pt1.Y - 10);

                pt3 = new Point(pt2.X - 6, pt2.Y + 2);
                pt4 = new Point(pt2.X - 2, pt2.Y + 6);

                context.BeginFigure(pt1, true, false);
                context.LineTo(pt2, true, true);
                context.LineTo(pt3, true, true);
                context.LineTo(pt2, true, true);
                context.LineTo(pt4, true, true);
            }
        }
示例#13
0
        void AddArrow(Edge drawingEdge, StreamGeometryContext context, Point start, Point end, double lineWidthOfAttachedNode)
        {
            Point dir = end - start;
            double dl = dir.Length;

            double scaling = (dl<12? 1 : 12 / dl) / _scale;
            Point new_start = end - (end - start) * scaling;

            //take into account the widths
            double delta = Math.Min(dl / 2, drawingEdge.Attr.LineWidth + lineWidthOfAttachedNode / 2);
            //dir *= (dl - delta) / dl;
            end = start + dir;
            dir = dir.Rotate(Math.PI / 2);
            Point s = dir * HalfArrowAngleTan * scaling;

            context.BeginFigure(CommonX.WpfPoint(start), true, true);
            context.LineTo(CommonX.WpfPoint(new_start), true, true);

            if (_category == "References")
            {
                double r = dl * scaling / 2;
                context.ArcTo(CommonX.WpfPoint(end), new Size(r, r), 0, true, SweepDirection.Clockwise, true, true);
                context.ArcTo(CommonX.WpfPoint(new_start), new Size(r, r), 0, true, SweepDirection.Clockwise, true, true);
            }
            else
            {
                context.LineTo(CommonX.WpfPoint(new_start + s), true, true);
                context.LineTo(CommonX.WpfPoint(end), true, true);
                context.LineTo(CommonX.WpfPoint(new_start - s), true, true);
                context.LineTo(CommonX.WpfPoint(new_start), true, true);
            }
        }
        private void DrawGeometry(StreamGeometryContext context)
        {
            Size WaveSize = new Size(WaveHeight, WaveHeight);
            Point StartPoint;
            Point EndPoint;
            StartPoint = new Point(StartPointX, (PlayfieldHeight-50) * (RemainingLives / Game.STARTING_LIVES  ));
            EndPoint = new Point(EndPointX, (PlayfieldHeight - 50) * (RemainingLives / Game.STARTING_LIVES));
            if (RemainingLives == 0)
            {
                StartPoint = new Point(StartPointX, (PlayfieldHeight - 50));
                EndPoint = new Point(EndPointX, (PlayfieldHeight - 50));
            }
            Point BottomRight = new Point(EndPointX, PlayfieldHeight);
            Point BottomLeft = new Point(StartPointX, PlayfieldHeight);
            
            Point waveEndPoint = EndPoint;

            context.BeginFigure(BottomLeft, true, true);
            context.LineTo(StartPoint, true, true);
            for (int i = 1; i <= NUM_OF_WAVES; i++)
            {
                waveEndPoint.X = ((EndPoint.X - StartPoint.X) * ((double)i / NUM_OF_WAVES));
                context.ArcTo(waveEndPoint, WaveSize, 0, false, SweepDirection.Counterclockwise, true, true);
            }
            context.LineTo(BottomRight, false, true);

        }
    void _DrawArcToStream(StreamGeometryContext context) {

      var rotationAngle = 65F;
      var innerRadius = 0F;
      var centerX = _r;
      var centreY = _r;
      var wedgeAngle = 150F;

      Point startPoint = new Point(centerX, centreY);

      Point innerArcStartPoint = Tools.ComputeCartesianCoordinate(rotationAngle, innerRadius);
      innerArcStartPoint.Offset(centerX, centreY);


      Point outerArcStartPoint = Tools.ComputeCartesianCoordinate(rotationAngle, _r);
      outerArcStartPoint.Offset(centerX, centreY);

      Point outerArcEndPoint = Tools.ComputeCartesianCoordinate(rotationAngle + wedgeAngle, _r);
      outerArcEndPoint.Offset(centerX, centreY);

      bool largeArc = wedgeAngle > 180.0;

      Size outerArcSize = new Size(_r, _r);

      context.BeginFigure(innerArcStartPoint, true, true);
      
      context.LineTo(outerArcStartPoint, true, true);
      context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
    }
示例#16
0
		private void method_18(StreamGeometryContext streamGeometryContext_0)
		{
			Point point = new Point(this.method_10(), this.method_12());
			Point point2 = Utils.ComputeCartesianCoordinate(this.method_8(), this.method_4());
			point2.Offset(this.method_10(), this.method_12());
			Point point3 = Utils.ComputeCartesianCoordinate(this.method_8() + this.method_6(), this.method_4());
			point3.Offset(this.method_10(), this.method_12());
			Point point4 = Utils.ComputeCartesianCoordinate(this.method_8(), this.method_0());
			point4.Offset(this.method_10(), this.method_12());
			Point point5 = Utils.ComputeCartesianCoordinate(this.method_8() + this.method_6(), this.method_0());
			point5.Offset(this.method_10(), this.method_12());
			bool isLargeArc = this.method_6() > 180.0;
			if (this.method_2() > 0.0)
			{
				Point point6 = Utils.ComputeCartesianCoordinate(this.method_8() + this.method_6() / 2.0, this.method_2());
				point2.Offset(point6.X, point6.Y);
				point3.Offset(point6.X, point6.Y);
				point4.Offset(point6.X, point6.Y);
				point5.Offset(point6.X, point6.Y);
			}
			Size size = new Size(this.method_0(), this.method_0());
			Size size2 = new Size(this.method_4(), this.method_4());
			streamGeometryContext_0.BeginFigure(point2, true, true);
			streamGeometryContext_0.LineTo(point4, true, true);
			streamGeometryContext_0.ArcTo(point5, size, 0.0, isLargeArc, SweepDirection.Clockwise, true, true);
			streamGeometryContext_0.LineTo(point3, true, true);
			streamGeometryContext_0.ArcTo(point2, size2, 0.0, isLargeArc, SweepDirection.Counterclockwise, true, true);
		}
示例#17
0
		/// <summary>
		/// Draws the pie piece
		/// </summary>
		private void DrawGeometry(StreamGeometryContext context)
		{
			double centreX = Radius;
			double centreY = Radius;
			
			Point startPoint = new Point(centreX, centreY);

			Point innerArcStartPoint = Utils.ComputeCartesianCoordinate(RotationAngle, InnerRadius);
			innerArcStartPoint.Offset(centreX, centreY);

			Point innerArcEndPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius);
			innerArcEndPoint.Offset(centreX, centreY);

			Point outerArcStartPoint = Utils.ComputeCartesianCoordinate(RotationAngle, Radius);
			outerArcStartPoint.Offset(centreX, centreY);

			Point outerArcEndPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, Radius);
			outerArcEndPoint.Offset(centreX, centreY);

			bool largeArc = WedgeAngle>180.0;

			Size outerArcSize = new Size(Radius, Radius);
			Size innerArcSize = new Size(InnerRadius, InnerRadius);

			context.BeginFigure(innerArcStartPoint, true, true);
			context.LineTo(outerArcStartPoint, true, true);
			context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
			context.LineTo(innerArcEndPoint, true, true);
			context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true);
		}
示例#18
0
 // draws a circle at the tail
 private void _drawCircularTail(StreamGeometryContext c, Point p, Vector v, double r) {
    var p0 = p - v * 2 * r;
    c.BeginFigure(p, true, true);
    c.ArcTo(p0, new Size(r, r), 0, false, SweepDirection.Clockwise, true, false);
    c.ArcTo(p, new Size(r, r), 0, false, SweepDirection.Clockwise, true, false);
 }
        public static void DrawFigure(StreamGeometryContext ctx, PathFigure figure)
        {
            ctx.BeginFigure(figure.StartPoint, figure.IsFilled, figure.IsClosed);
            foreach (var segment in figure.Segments)
            {
                var lineSegment = segment as WpfLineSegment;
                if (lineSegment != null) { ctx.LineTo(lineSegment.Point, lineSegment.IsStroked, lineSegment.IsSmoothJoin); continue; }

                var bezierSegment = segment as BezierSegment;
                if (bezierSegment != null) { ctx.BezierTo(bezierSegment.Point1, bezierSegment.Point2, bezierSegment.Point3, bezierSegment.IsStroked, bezierSegment.IsSmoothJoin); continue; }

                var quadraticSegment = segment as QuadraticBezierSegment;
                if (quadraticSegment != null) { ctx.QuadraticBezierTo(quadraticSegment.Point1, quadraticSegment.Point2, quadraticSegment.IsStroked, quadraticSegment.IsSmoothJoin); continue; }

                var polyLineSegment = segment as PolyLineSegment;
                if (polyLineSegment != null) { ctx.PolyLineTo(polyLineSegment.Points, polyLineSegment.IsStroked, polyLineSegment.IsSmoothJoin); continue; }

                var polyBezierSegment = segment as PolyBezierSegment;
                if (polyBezierSegment != null) { ctx.PolyBezierTo(polyBezierSegment.Points, polyBezierSegment.IsStroked, polyBezierSegment.IsSmoothJoin); continue; }

                var polyQuadraticSegment = segment as PolyQuadraticBezierSegment;
                if (polyQuadraticSegment != null) { ctx.PolyQuadraticBezierTo(polyQuadraticSegment.Points, polyQuadraticSegment.IsStroked, polyQuadraticSegment.IsSmoothJoin); continue; }

                var arcSegment = segment as ArcSegment;
                if (arcSegment != null) { ctx.ArcTo(arcSegment.Point, arcSegment.Size, arcSegment.RotationAngle, arcSegment.IsLargeArc, arcSegment.SweepDirection, arcSegment.IsStroked, arcSegment.IsSmoothJoin); continue; }
            }
        }
示例#20
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        protected void DrawGeometry(StreamGeometryContext context)
        {
            Point offset = new Point(
                (double.IsNaN(CenterX)) ? Width / 2.0 : CenterX,
                (double.IsNaN(CenterY)) ? Height / 2.0 : CenterY);

            double angleSpan = Math.Abs(EndAngle - StartAngle);

            Point thrustPoint = PolarToCartesian(StartAngle + angleSpan/2.0, RadiusThrust, offset);
            Point outerArcStartPoint = PolarToCartesian(StartAngle, OuterRadius, offset);
            Point outerArcEndPoint = PolarToCartesian(EndAngle, OuterRadius, offset);

            //using LERP, calculate the innerArc points, sadly we shall be short changing
            Point innerArcStartPoint = PolarToCartesian(StartAngle, InnerRadius - RadiusThrust, thrustPoint);
            Point innerArcEndPoint = PolarToCartesian(EndAngle, InnerRadius - RadiusThrust, thrustPoint);

            bool largeArc = angleSpan > 180.0;

            double innerArcDim = Math.Max(0.0, InnerRadius - RadiusThrust);

            Size outerArcSize = new Size(OuterRadius, OuterRadius);
            Size innerArcSize = new Size(innerArcDim, innerArcDim);

            context.BeginFigure(outerArcStartPoint, true, true);
            //context.LineTo(outerArcStartPoint, true, true);
            context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
            context.LineTo(innerArcEndPoint, true, true);
            context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true);
        }
示例#21
0
        /// <summary>
        ///     Generates a StreamGeometry.
        /// </summary>
        /// <param name="ctx">An already opened StreamGeometryContext.</param>
        /// <param name="rect">Rectangle for geomentry conversion.</param>
        /// <param name="borderInfo">The core points of the border which needs to be used to create
        /// the geometry</param>
        /// <returns>Result geometry.</returns>
        private static void GenerateGeometry(StreamGeometryContext ctx, Rect rect, BorderInfo borderInfo)
        {
            //  compute the coordinates of the key points
            var leftTop = new Point(borderInfo.LeftTop, 0);
            var rightTop = new Point(rect.Width - borderInfo.RightTop, 0);
            var topRight = new Point(rect.Width, borderInfo.TopRight);
            var bottomRight = new Point(rect.Width, rect.Height - borderInfo.BottomRight);
            var rightBottom = new Point(rect.Width - borderInfo.RightBottom, rect.Height);
            var leftBottom = new Point(borderInfo.LeftBottom, rect.Height);
            var bottomLeft = new Point(0, rect.Height - borderInfo.BottomLeft);
            var topLeft = new Point(0, borderInfo.TopLeft);

            //  check keypoints for overlap and resolve by partitioning corners according to
            //  the percentage of each one.  

            //  top edge
            if (leftTop.X > rightTop.X)
            {
                var v = (borderInfo.LeftTop) / (borderInfo.LeftTop + borderInfo.RightTop) * rect.Width;
                leftTop.X = v;
                rightTop.X = v;
            }

            //  right edge
            if (topRight.Y > bottomRight.Y)
            {
                var v = (borderInfo.TopRight) / (borderInfo.TopRight + borderInfo.BottomRight) * rect.Height;
                topRight.Y = v;
                bottomRight.Y = v;
            }

            //  bottom edge
            if (leftBottom.X > rightBottom.X)
            {
                var v = (borderInfo.LeftBottom) / (borderInfo.LeftBottom + borderInfo.RightBottom) * rect.Width;
                rightBottom.X = v;
                leftBottom.X = v;
            }

            // left edge
            if (topLeft.Y > bottomLeft.Y)
            {
                var v = (borderInfo.TopLeft) / (borderInfo.TopLeft + borderInfo.BottomLeft) * rect.Height;
                bottomLeft.Y = v;
                topLeft.Y = v;
            }

            // Apply offset
            var offsetX = rect.TopLeft.X;
            var offsetY = rect.TopLeft.Y;
            var offset = new Vector(offsetX, offsetY);
            leftTop += offset;
            rightTop += offset;
            topRight += offset;
            bottomRight += offset;
            rightBottom += offset;
            leftBottom += offset;
            bottomLeft += offset;
            topLeft += offset;

            //  create the border geometry
            ctx.BeginFigure(leftTop, true /* is filled */, true /* is closed */);

            // Top line
            ctx.LineTo(rightTop, true /* is stroked */, false /* is smooth join */);

            // Upper-right corners
            var radiusX = rect.TopRight.X - rightTop.X;
            var radiusY = topRight.Y - rect.TopRight.Y;
            if (!radiusX.IsZero() || !radiusY.IsZero())
            {
                ctx.ArcTo(topRight, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }

            // Right line
            ctx.LineTo(bottomRight, true /* is stroked */, false /* is smooth join */);

            // Lower-right corners
            radiusX = rect.BottomRight.X - rightBottom.X;
            radiusY = rect.BottomRight.Y - bottomRight.Y;
            if (!radiusX.IsZero() || !radiusY.IsZero())
            {
                ctx.ArcTo(rightBottom, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }

            // Bottom line
            ctx.LineTo(leftBottom, true /* is stroked */, false /* is smooth join */);

            // Lower-left corners
            radiusX = leftBottom.X - rect.BottomLeft.X;
            radiusY = rect.BottomLeft.Y - bottomLeft.Y;
            if (!radiusX.IsZero() || !radiusY.IsZero())
            {
                ctx.ArcTo(bottomLeft, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }

            // Left line
            ctx.LineTo(topLeft, true /* is stroked */, false /* is smooth join */);

            // Upper-left corners
            radiusX = leftTop.X - rect.TopLeft.X;
            radiusY = topLeft.Y - rect.TopLeft.Y;
            if (!radiusX.IsZero() || !radiusY.IsZero())
            {
                ctx.ArcTo(leftTop, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }
        }
 static void FillContexForCurve(StreamGeometryContext context,Curve c) {
     foreach(ICurve seg in c.Segments) {
         var bezSeg = seg as CubicBezierSegment;
         if(bezSeg != null) {
             context.BezierTo(Common.WpfPoint(bezSeg.B(1)),
                              Common.WpfPoint(bezSeg.B(2)),Common.WpfPoint(bezSeg.B(3)),true,false);
         } else {
             var ls = seg as LineSegment;
             if(ls != null)
                 context.LineTo(Common.WpfPoint(ls.End),true,false);
             else {
                 var ellipse = seg as Ellipse;
                 if(ellipse != null) {
                     //       context.LineTo(Common.WpfPoint(ellipse.End),true,false);
                     double sweepAngle = EllipseSweepAngle(ellipse);
                     bool largeArc = Math.Abs(sweepAngle) >= Math.PI;
                     Rectangle box = ellipse.FullBox();
                     context.ArcTo(Common.WpfPoint(ellipse.End),
                                   new Size(box.Width / 2,box.Height / 2),
                                   sweepAngle,
                                   largeArc,
                                   sweepAngle < 0
                                       ? SweepDirection.Counterclockwise
                                       : SweepDirection.Clockwise,
                                   true,true);
                 } else
                     throw new NotImplementedException();
             }
         }
     }
 }
示例#23
0
文件: Pie.cs 项目: Ravnii/ATISv2
        /// <summary>
        /// Draws the pie chart
        /// </summary>
        /// <param name="context"></param>
        private void DrawGeometry(StreamGeometryContext context)
        {
            Point startPoint = new Point(CentreX, CentreY);

            Point outerArcStartPoint = ComputeCartesianCoordinate(Rotation, Radius);
            outerArcStartPoint.Offset(CentreX, CentreY);

            Point outerArcEndPoint = ComputeCartesianCoordinate(Rotation + Angle, Radius);
            outerArcEndPoint.Offset(CentreX, CentreY);

            bool largeArc = Angle > 180.0;
            Size outerArcSize = new Size(Radius, Radius);

            context.BeginFigure(startPoint, true, true);
            context.LineTo(outerArcStartPoint, true, true);
            context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);

            context.Close();
        }
示例#24
0
        /// <summary>
        /// Parse a PathFigureCollection string
        /// </summary>
        internal void ParseToGeometryContext(
            StreamGeometryContext context,
            string pathString,
            int startIndex)
        {
            // [BreakingChange] Dev10 Bug #453199
            // We really should throw an ArgumentNullException here for context and pathString.
            
            // From original code
            // This is only used in call to Double.Parse
            _formatProvider = System.Globalization.CultureInfo.InvariantCulture;
            
            _context         = context;
            _pathString      = pathString;
            _pathLength      = pathString.Length;
            _curIndex        = startIndex;
            
            _secondLastPoint = new Point(0, 0);
            _lastPoint       = new Point(0, 0);
            _lastStart       = new Point(0, 0);
            
            _figureStarted = false;
            
            bool  first = true;
            
            char last_cmd = ' ';

            while (ReadToken()) // Empty path is allowed in XAML
            {
                char cmd = _token;

                if (first)
                {
                    if ((cmd != 'M') && (cmd != 'm'))  // Path starts with M|m
                    {
                        ThrowBadToken();
                    }
            
                    first = false;
                }                    
                
                switch (cmd)
                {
                case 'm': case 'M':
                    // XAML allows multiple points after M/m
                    _lastPoint = ReadPoint(cmd, ! AllowComma);
                    
                    context.BeginFigure(_lastPoint, IsFilled, ! IsClosed);
                    _figureStarted = true;
                    _lastStart = _lastPoint;
                    last_cmd = 'M';
                    
                    while (IsNumber(AllowComma))
                    {
                        _lastPoint = ReadPoint(cmd, ! AllowComma);
                        
                        context.LineTo(_lastPoint, IsStroked, ! IsSmoothJoin);
                        last_cmd = 'L';
                    }
                    break;

                case 'l': case 'L':
                case 'h': case 'H':
                case 'v': case 'V':
                    EnsureFigure();

                    do
                    {
                        switch (cmd)
                        {
                        case 'l': _lastPoint    = ReadPoint(cmd, ! AllowComma); break;
                        case 'L': _lastPoint    = ReadPoint(cmd, ! AllowComma); break;
                        case 'h': _lastPoint.X += ReadNumber(! AllowComma); break;
                        case 'H': _lastPoint.X  = ReadNumber(! AllowComma); break; 
                        case 'v': _lastPoint.Y += ReadNumber(! AllowComma); break;
                        case 'V': _lastPoint.Y  = ReadNumber(! AllowComma); break;
                        }

                        context.LineTo(_lastPoint, IsStroked, ! IsSmoothJoin); 
                    }
                    while (IsNumber(AllowComma));

                    last_cmd = 'L';
                    break;

                case 'c': case 'C': // cubic Bezier
                case 's': case 'S': // smooth cublic Bezier
                    EnsureFigure();
                    
                    do
                    {
                        Point p;
                        
                        if ((cmd == 's') || (cmd == 'S'))
                        {
                            if (last_cmd == 'C')
                            {
                                p = Reflect();
                            }
                            else
                            {
                                p = _lastPoint;
                            }

                            _secondLastPoint = ReadPoint(cmd, ! AllowComma);
                        }
                        else
                        {
                            p = ReadPoint(cmd, ! AllowComma);

                            _secondLastPoint = ReadPoint(cmd, AllowComma);
                        }
                            
                        _lastPoint = ReadPoint(cmd, AllowComma);

                        context.BezierTo(p, _secondLastPoint, _lastPoint, IsStroked, ! IsSmoothJoin);
                        
                        last_cmd = 'C';
                    }
                    while (IsNumber(AllowComma));
                    
                    break;
                    
                case 'q': case 'Q': // quadratic Bezier
                case 't': case 'T': // smooth quadratic Bezier
                    EnsureFigure();
                    
                    do
                    {
                        if ((cmd == 't') || (cmd == 'T'))
                        {
                            if (last_cmd == 'Q')
                            {
                                _secondLastPoint = Reflect();
                            }
                            else
                            {
                                _secondLastPoint = _lastPoint;
                            }

                            _lastPoint = ReadPoint(cmd, ! AllowComma);
                        }
                        else
                        {
                            _secondLastPoint = ReadPoint(cmd, ! AllowComma);
                            _lastPoint = ReadPoint(cmd, AllowComma);
                        }

                        context.QuadraticBezierTo(_secondLastPoint, _lastPoint, IsStroked, ! IsSmoothJoin);
                        
                        last_cmd = 'Q';
                    }
                    while (IsNumber(AllowComma));
                    
                    break;
                    
                case 'a': case 'A':
                    EnsureFigure();
                    
                    do
                    {
                        // A 3,4 5, 0, 0, 6,7
                        double w        = ReadNumber(! AllowComma);
                        double h        = ReadNumber(AllowComma);
                        double rotation = ReadNumber(AllowComma);
                        bool large      = ReadBool();
                        bool sweep      = ReadBool();
                        
                        _lastPoint = ReadPoint(cmd, AllowComma);

                        context.ArcTo(
                            _lastPoint,
                            new Size(w, h),
                            rotation,
                            large,
#if PBTCOMPILER
                            sweep,
#else                            
                            sweep ? SweepDirection.Clockwise : SweepDirection.Counterclockwise,
#endif                             
                            IsStroked,
                            ! IsSmoothJoin
                            );
                    }
                    while (IsNumber(AllowComma));
                    
                    last_cmd = 'A';
                    break;
                    
                case 'z':
                case 'Z':
                    EnsureFigure();
                    context.SetClosedState(IsClosed);
                    
                    _figureStarted = false;
                    last_cmd = 'Z';
                    
                    _lastPoint = _lastStart; // Set reference point to be first point of current figure
                    break;
                    
                default:
                    ThrowBadToken();
                    break;
                }
            }
        }
示例#25
0
        //----------------------------------------------------------------------------//
        // Methods                                                                    //
        //----------------------------------------------------------------------------//
        ////////////////////////////////////////////////////////////////////////////////
        /// <summary> Draws the geometry. </summary>
        private void DrawGeometry(StreamGeometryContext context)
        {
            Point startPoint = new Point (CenterX, CenterY);

            Point innerArcStartPoint = ComputeCartesian (RotationAngle, InnerRadius);
            Point innerArcEndPoint   = ComputeCartesian (RotationAngle + WedgeAngle, InnerRadius);
            Point outerArcStartPoint = ComputeCartesian (RotationAngle, Radius);
            Point outerArcEndPoint   = ComputeCartesian (RotationAngle + WedgeAngle, Radius);

            innerArcStartPoint.Offset (CenterX, CenterY);
            innerArcEndPoint.Offset   (CenterX, CenterY);
            outerArcStartPoint.Offset (CenterX, CenterY);
            outerArcEndPoint.Offset   (CenterX, CenterY);

            bool largeArc = WedgeAngle > 180;

            if (PushOut > 0)
            {
                Point offset = ComputeCartesian (RotationAngle + WedgeAngle / 2, PushOut);

                innerArcStartPoint.Offset (offset.X, offset.Y);
                innerArcEndPoint.Offset   (offset.X, offset.Y);
                outerArcStartPoint.Offset (offset.X, offset.Y);
                outerArcEndPoint.Offset   (offset.X, offset.Y);

            }

            Size outerArcSize = new Size (Radius, Radius);
            Size innerArcSize = new Size (InnerRadius, InnerRadius);

            context.BeginFigure (innerArcStartPoint, true, true);

            context.LineTo (outerArcStartPoint, true, true);
            context.ArcTo  (outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
            context.LineTo (innerArcEndPoint, true, true);
            context.ArcTo  (innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true);
        }
示例#26
0
        /// <summary>
        /// Draws the pie piece
        /// </summary>
        private void DrawGeometry(StreamGeometryContext context)
        {
            Point startPoint = new Point(CentreX, CentreY);

            Point innerArcStartPoint = Utils.ComputeCartesianCoordinate(RotationAngle, InnerRadius);
            innerArcStartPoint.Offset(CentreX, CentreY);

            Point innerArcEndPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius);
            innerArcEndPoint.Offset(CentreX, CentreY);

            Point outerArcStartPoint = Utils.ComputeCartesianCoordinate(RotationAngle, Radius);
            outerArcStartPoint.Offset(CentreX, CentreY);

            Point outerArcEndPoint = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle, Radius);
            outerArcEndPoint.Offset(CentreX, CentreY);

            bool largeArc = WedgeAngle>180.0;

            if (PushOut > 0)
            {
                Point offset = Utils.ComputeCartesianCoordinate(RotationAngle + WedgeAngle / 2, PushOut);
                innerArcStartPoint.Offset(offset.X, offset.Y);
                innerArcEndPoint.Offset(offset.X, offset.Y);
                outerArcStartPoint.Offset(offset.X, offset.Y);
                outerArcEndPoint.Offset(offset.X, offset.Y);

            }

            Size outerArcSize = new Size(Radius, Radius);
            Size innerArcSize = new Size(InnerRadius, InnerRadius);
            Size endingsArcSize = new Size(5, 5);

            context.BeginFigure(innerArcStartPoint, true, true);
            // Use LineTo to draw a flat endings
            //context.LineTo(outerArcStartPoint, true, true);
            context.ArcTo(outerArcStartPoint, endingsArcSize, 0, false, SweepDirection.Counterclockwise, true, true);
            context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true);
            //context.LineTo(innerArcEndPoint, true, true);
            context.ArcTo(innerArcEndPoint, endingsArcSize, 0, false, SweepDirection.Counterclockwise, true, true);
            context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true);
        }
示例#27
0
        /// <summary>
        ///     Generates a StreamGeometry.
        /// </summary>
        /// <param name="ctx">An already opened StreamGeometryContext.</param>
        /// <param name="rect">Rectangle for geomentry conversion.</param>
        /// <param name="radii">Corner radii.</param>
        /// <returns>Result geometry.</returns>
        private static void GenerateGeometry(StreamGeometryContext ctx, Rect rect, Radii radii)
        {
            //
            //  compute the coordinates of the key points
            //

            Point topLeft = new Point(radii.LeftTop, 0);
            Point topRight = new Point(rect.Width - radii.RightTop, 0);
            Point rightTop = new Point(rect.Width, radii.TopRight);
            Point rightBottom = new Point(rect.Width, rect.Height - radii.BottomRight);
            Point bottomRight = new Point(rect.Width - radii.RightBottom, rect.Height);
            Point bottomLeft = new Point(radii.LeftBottom, rect.Height);
            Point leftBottom = new Point(0, rect.Height - radii.BottomLeft);
            Point leftTop = new Point(0, radii.TopLeft);

            //
            //  check keypoints for overlap and resolve by partitioning radii according to
            //  the percentage of each one.  
            //

            //  top edge is handled here
            if (topLeft.X > topRight.X)
            {
                double v = (radii.LeftTop) / (radii.LeftTop + radii.RightTop) * rect.Width;
                topLeft.X = v;
                topRight.X = v;
            }

            //  right edge
            if (rightTop.Y > rightBottom.Y)
            {
                double v = (radii.TopRight) / (radii.TopRight + radii.BottomRight) * rect.Height;
                rightTop.Y = v;
                rightBottom.Y = v;
            }

            //  bottom edge
            if (bottomRight.X < bottomLeft.X)
            {
                double v = (radii.LeftBottom) / (radii.LeftBottom + radii.RightBottom) * rect.Width;
                bottomRight.X = v;
                bottomLeft.X = v;
            }

            // left edge
            if (leftBottom.Y < leftTop.Y)
            {
                double v = (radii.TopLeft) / (radii.TopLeft + radii.BottomLeft) * rect.Height;
                leftBottom.Y = v;
                leftTop.Y = v;
            }

            //
            //  add on offsets
            //

            Vector offset = new Vector(rect.TopLeft.X, rect.TopLeft.Y);
            topLeft += offset;
            topRight += offset;
            rightTop += offset;
            rightBottom += offset;
            bottomRight += offset;
            bottomLeft += offset;
            leftBottom += offset;
            leftTop += offset;

            //
            //  create the border geometry
            //
            ctx.BeginFigure(topLeft, true /* is filled */, true /* is closed */);

            // Top line
            ctx.LineTo(topRight, true /* is stroked */, false /* is smooth join */);

            // Upper-right corner
            double radiusX = rect.TopRight.X - topRight.X;
            double radiusY = rightTop.Y - rect.TopRight.Y;
            if (!DoubleUtil.IsZero(radiusX)
                || !DoubleUtil.IsZero(radiusY))
            {
                ctx.ArcTo(rightTop, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }

            // Right line
            ctx.LineTo(rightBottom, true /* is stroked */, false /* is smooth join */);

            // Lower-right corner
            radiusX = rect.BottomRight.X - bottomRight.X;
            radiusY = rect.BottomRight.Y - rightBottom.Y;
            if (!DoubleUtil.IsZero(radiusX)
                || !DoubleUtil.IsZero(radiusY))
            {
                ctx.ArcTo(bottomRight, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }

            // Bottom line
            ctx.LineTo(bottomLeft, true /* is stroked */, false /* is smooth join */);

            // Lower-left corner
            radiusX = bottomLeft.X - rect.BottomLeft.X;
            radiusY = rect.BottomLeft.Y - leftBottom.Y;
            if (!DoubleUtil.IsZero(radiusX)
                || !DoubleUtil.IsZero(radiusY))
            {
                ctx.ArcTo(leftBottom, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }

            // Left line
            ctx.LineTo(leftTop, true /* is stroked */, false /* is smooth join */);

            // Upper-left corner
            radiusX = topLeft.X - rect.TopLeft.X;
            radiusY = leftTop.Y - rect.TopLeft.Y;
            if (!DoubleUtil.IsZero(radiusX)
                || !DoubleUtil.IsZero(radiusY))
            {
                ctx.ArcTo(topLeft, new Size(radiusX, radiusY), 0, false, SweepDirection.Clockwise, true, false);
            }
        }
示例#28
0
        /// <summary>
        /// Draws the pie piece
        /// </summary>
        private void DrawGeometry(StreamGeometryContext context)
        {
            if (AngleDelta <= 0)
            {
                return;
            }

            double outerStartAngle = StartAngle;
            double outerAngleDelta = AngleDelta;
            double innerStartAngle = StartAngle;
            double innerAngleDelta = AngleDelta;
            Point arcCenter = new Point(CenterX, CenterY);
            Size outerArcSize = new Size(OuterRadius, OuterRadius);
            Size innerArcSize = new Size(InnerRadius, InnerRadius);

            // If have to draw a full-circle, draws two semi-circles, because 'ArcTo()' can not draw a full-circle
            if (AngleDelta >= 360 && Padding <= 0)
            {
                Point outerArcTopPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle, OuterRadius + PushOut);
                Point outerArcBottomPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle + 180, OuterRadius + PushOut);
                Point innerArcTopPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle, InnerRadius + PushOut);
                Point innerArcBottomPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle + 180, InnerRadius + PushOut);

                context.BeginFigure(innerArcTopPoint, true, true);
                context.LineTo(outerArcTopPoint, true, true);
                context.ArcTo(outerArcBottomPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true);
                context.ArcTo(outerArcTopPoint, outerArcSize, 0, false, SweepDirection.Clockwise, true, true);
                context.LineTo(innerArcTopPoint, true, true);
                context.ArcTo(innerArcBottomPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true);
                context.ArcTo(innerArcTopPoint, innerArcSize, 0, false, SweepDirection.Counterclockwise, true, true);
            }
            // Else draws as always
            else
            {
                if (Padding > 0)
                {
                    // Offsets the angle by the padding
                    double outerAngleVariation = (180 * (Padding / OuterRadius)) / Math.PI;
                    double innerAngleVariation = (180 * (Padding / InnerRadius)) / Math.PI;

                    outerStartAngle += outerAngleVariation;
                    outerAngleDelta -= outerAngleVariation * 2;
                    innerStartAngle += innerAngleVariation;
                    innerAngleDelta -= innerAngleVariation * 2;
                }

                Point outerArcStartPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle, OuterRadius + PushOut);
                Point outerArcEndPoint = ComputeCartesianCoordinate(arcCenter, outerStartAngle + outerAngleDelta, OuterRadius + PushOut);
                Point innerArcStartPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle, InnerRadius + PushOut);
                Point innerArcEndPoint = ComputeCartesianCoordinate(arcCenter, innerStartAngle + innerAngleDelta, InnerRadius + PushOut);

                bool largeArcOuter = outerAngleDelta > 180.0;
                bool largeArcInner = innerAngleDelta > 180.0;

                context.BeginFigure(innerArcStartPoint, true, true);
                context.LineTo(outerArcStartPoint, true, true);
                context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArcOuter, SweepDirection.Clockwise, true, true);
                context.LineTo(innerArcEndPoint, true, true);
                context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArcInner, SweepDirection.Counterclockwise, true, true);
            }
        }
示例#29
0
        /// <summary>
        /// Private helper to render a path figure to the SGC
        /// </summary>
        private static void AddArcToFigureToStreamGeometryContext(StreamGeometryContext context, List<Point> abPoints, List<Point> dcPoints, List<Point> polyLinePoints)
        {
            Debug.Assert(context != null);
            Debug.Assert(abPoints != null && dcPoints != null);
            Debug.Assert(polyLinePoints != null);
            //Debug.Assert(abPoints.Count > 0 && dcPoints.Count > 0);
            if (abPoints.Count == 0 || dcPoints.Count == 0)
            {
                return;
            }

            context.BeginFigure(abPoints[0], //start point
                                        true,   //isFilled
                                        true);  //IsClosed

            for (int j = 0; j < 2; j++)
            {
                List<Point> points = j == 0 ? abPoints : dcPoints;
                int startIndex = j == 0 ? 1 : 0;
                for (int i = startIndex; i < points.Count; )
                {
                    Point next = points[i];
                    if (next == StrokeRenderer.ArcToMarker)
                    {
                        if (polyLinePoints.Count > 0)
                        {
                            //polyline first
                            context.PolyLineTo(  polyLinePoints,
                                                 true,      //isStroked
                                                 true);     //isSmoothJoin
                            polyLinePoints.Clear();
                        }
                        //we're arcing, pull out height, width and the arc to point
                        Debug.Assert(i + 2 < points.Count);
                        if (i + 2 < points.Count)
                        {
                            Point sizePoint = points[i + 1];
                            Size ellipseSize = new Size(sizePoint.X / 2/*width*/, sizePoint.Y / 2/*height*/);
                            Point arcToPoint = points[i + 2];

                            bool isLargeArc = false; //>= 180

                            context.ArcTo(  arcToPoint,
                                            ellipseSize,
                                            0d,             //rotation
                                            isLargeArc,     //isLargeArc
                                            SweepDirection.Clockwise,
                                            true,           //isStroked
                                            true);          //isSmoothJoin
                        }
                        i += 3; //advance past this arcTo block
                    }
                    else
                    {
                        //walk forward until we find an arc marker or the end
                        polyLinePoints.Add(next);
                        i++;
                    }
                }
                if (polyLinePoints.Count > 0)
                {
                    //polyline
                    context.PolyLineTo(polyLinePoints,
                                         true,      //isStroked
                                         true);     //isSmoothJoin
                    polyLinePoints.Clear();
                }
            }
        }
示例#30
0
		private void method18(StreamGeometryContext streamGeometryContext)
		{
			Point point = new Point(method10(), method12());
			Point point2 = Utils.ComputeCartesianCoordinate(method8(), method4());
			point2.Offset(method10(), method12());
			Point point3 = Utils.ComputeCartesianCoordinate(method8() + method6(), method4());
			point3.Offset(method10(), method12());
			Point point4 = Utils.ComputeCartesianCoordinate(method8(), method0());
			point4.Offset(method10(), method12());
			Point point5 = Utils.ComputeCartesianCoordinate(method8() + method6(), method0());
			point5.Offset(method10(), method12());
			bool isLargeArc = method6() > 180.0;

			if (method2() > 0.0)
			{
				Point point6 = Utils.ComputeCartesianCoordinate(method8() + method6() / 2.0, method2());
				point2.Offset(point6.X, point6.Y);
				point3.Offset(point6.X, point6.Y);
				point4.Offset(point6.X, point6.Y);
				point5.Offset(point6.X, point6.Y);
			}

			Size size = new Size(method0(), method0());
			Size size2 = new Size(method4(), method4());

			streamGeometryContext.BeginFigure(point2, true, true);
			streamGeometryContext.LineTo(point4, true, true);
			streamGeometryContext.ArcTo(point5, size, 0.0, isLargeArc, SweepDirection.Clockwise, true, true);
			streamGeometryContext.LineTo(point3, true, true);
			streamGeometryContext.ArcTo(point2, size2, 0.0, isLargeArc, SweepDirection.Counterclockwise, true, true);
		}
        public void DrawGeometry(StreamGeometryContext context)
        {
            const double LINE_MODIFIER = .7;

            Point EllipseStartPoint = new Point(CenterX - Radius, CenterY);
            Point HalfEllipseEndPoint = new Point(CenterX + Radius, CenterY);

            Point LeftLineStartPoint =      new Point(CenterX - Radius * (1 - LINE_MODIFIER), (CenterY - (Radius * LINE_MODIFIER)));
            Point LeftLineEndPoint =        new Point(CenterX - Radius * (1 - LINE_MODIFIER), (CenterY + (Radius * LINE_MODIFIER)));

            Point RightLineStartPoint2 =    new Point(CenterX + Radius * (1 - LINE_MODIFIER), (CenterY - (Radius * LINE_MODIFIER)));
            Point RightLineEndPoint2 =      new Point(CenterX + Radius * (1 - LINE_MODIFIER), (CenterY + (Radius * LINE_MODIFIER)));

            Size ArcSize = new Size(Radius, Radius);
            
            context.BeginFigure(EllipseStartPoint, true, false);
            context.ArcTo(HalfEllipseEndPoint, ArcSize, 0, false, SweepDirection.Counterclockwise, true, false);
            context.ArcTo(EllipseStartPoint, ArcSize, 0, false, SweepDirection.Counterclockwise, true, false);
            context.LineTo(LeftLineStartPoint, false, false);
            context.LineTo(LeftLineEndPoint, true, true);
            context.LineTo(RightLineEndPoint2, false, false);
            context.LineTo(RightLineStartPoint2, true, true);
            
        }