private void DrawLineArrowsInternal(XGraphics gfx, LineShape line, double dx, double dy, out XPoint pt1, out XPoint pt2) { XSolidBrush fillStartArrow = ToXSolidBrush(line.Style.StartArrowStyle.Fill); XPen strokeStartArrow = ToXPen(line.Style.StartArrowStyle, _scaleToPage, _sourceDpi, _targetDpi); XSolidBrush fillEndArrow = ToXSolidBrush(line.Style.EndArrowStyle.Fill); XPen strokeEndArrow = ToXPen(line.Style.EndArrowStyle, _scaleToPage, _sourceDpi, _targetDpi); double _x1 = line.Start.X + dx; double _y1 = line.Start.Y + dy; double _x2 = line.End.X + dx; double _y2 = line.End.Y + dy; LineShapeExtensions.GetMaxLength(line, ref _x1, ref _y1, ref _x2, ref _y2); double x1 = _scaleToPage(_x1); double y1 = _scaleToPage(_y1); double x2 = _scaleToPage(_x2); double y2 = _scaleToPage(_y2); var sas = line.Style.StartArrowStyle; var eas = line.Style.EndArrowStyle; double a1 = Math.Atan2(y1 - y2, x1 - x2) * 180.0 / Math.PI; double a2 = Math.Atan2(y2 - y1, x2 - x1) * 180.0 / Math.PI; // Draw start arrow. pt1 = DrawLineArrowInternal(gfx, strokeStartArrow, fillStartArrow, x1, y1, a1, sas); // Draw end arrow. pt2 = DrawLineArrowInternal(gfx, strokeEndArrow, fillEndArrow, x2, y2, a2, eas); }
private void DrawLineCurveInternal(DrawingContext dc, double half, Pen pen, LineShape 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; LineShapeExtensions.GetCurvedLineBezierControlPoints( line.Style.LineStyle.CurveOrientation, line.Style.LineStyle.Curvature, line.Start.Alignment, line.End.Alignment, ref p1x, ref p1y, ref p2x, ref p2y); System.Windows.Media.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 System.Windows.Media.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 System.Windows.Media.PathGeometry(); pg.Figures.Add(pf); //pg.Freeze(); _curvedLineCache.Set(line, pg); } DrawPathGeometryInternal(dc, half, null, pen, line.IsStroked, false, pg); }
private static void DrawLineCurveInternal(XGraphics gfx, XPen pen, bool isStroked, ref XPoint pt1, ref XPoint pt2, double curvature, CurveOrientation orientation, Core2D.Shape.PointAlignment pt1a, Core2D.Shape.PointAlignment pt2a) { if (isStroked) { var path = new XGraphicsPath(); double p1x = pt1.X; double p1y = pt1.Y; double p2x = pt2.X; double p2y = pt2.Y; LineShapeExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt1a, pt2a, ref p1x, ref p1y, ref p2x, ref p2y); path.AddBezier( pt1.X, pt1.Y, p1x, p1y, p2x, p2y, pt2.X, pt2.Y); gfx.DrawPath(pen, path); } }
private SKPath CreateCurveGeometry(SKPoint p0, SKPoint p1, double curvature, CurveOrientation orientation, PointAlignment pt0a, PointAlignment pt1a) { var curveGeometry = new SKPath(); curveGeometry.MoveTo(new SKPoint((float)p0.X, (float)p0.Y)); double p0x = p0.X; double p0y = p0.Y; double p1x = p1.X; double p1y = p1.Y; LineShapeExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt0a, pt1a, ref p0x, ref p0y, ref p1x, ref p1y); var point1 = new SKPoint((float)p0x, (float)p0y); var point2 = new SKPoint((float)p1x, (float)p1y); var point3 = new SKPoint(p1.X, p1.Y); curveGeometry.CubicTo(point1, point2, point3); return(curveGeometry); }
private static void DrawLineCurveInternal(Graphics gfx, Pen pen, bool isStroked, ref PointF pt1, ref PointF pt2, double curvature, CurveOrientation orientation, PointAlignment pt1a, PointAlignment pt2a) { if (isStroked) { double p1x = pt1.X; double p1y = pt1.Y; double p2x = pt2.X; double p2y = pt2.Y; LineShapeExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt1a, pt2a, ref p1x, ref p1y, ref p2x, ref p2y); gfx.DrawBezier( pen, pt1.X, pt1.Y, (float)p1x, (float)p1y, (float)p2x, (float)p2y, pt2.X, pt2.Y); } }
private AM.StreamGeometry CreateCurveGeometry(A.Point p0, A.Point p1, double curvature, CurveOrientation orientation, PointAlignment pt0a, PointAlignment pt1a) { var curveGeometry = new AM.StreamGeometry(); using (var geometryContext = curveGeometry.Open()) { geometryContext.BeginFigure(new A.Point(p0.X, p0.Y), false); double p0x = p0.X; double p0y = p0.Y; double p1x = p1.X; double p1y = p1.Y; LineShapeExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt0a, pt1a, ref p0x, ref p0y, ref p1x, ref p1y); var point1 = new A.Point(p0x, p0y); var point2 = new A.Point(p1x, p1y); var point3 = new A.Point(p1.X, p1.Y); geometryContext.CubicBezierTo(point1, point2, point3); geometryContext.EndFigure(false); } return(curveGeometry); }
private static void DrawLineCurveInternal(AM.DrawingContext _dc, AM.Pen pen, bool isStroked, ref A.Point pt1, ref A.Point pt2, double curvature, CurveOrientation orientation, PointAlignment pt1a, PointAlignment pt2a) { if (isStroked) { var sg = new AM.StreamGeometry(); using (var sgc = sg.Open()) { sgc.BeginFigure(new A.Point(pt1.X, pt1.Y), false); double p1x = pt1.X; double p1y = pt1.Y; double p2x = pt2.X; double p2y = pt2.Y; LineShapeExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt1a, pt2a, ref p1x, ref p1y, ref p2x, ref p2y); sgc.CubicBezierTo( new A.Point(p1x, p1y), new A.Point(p2x, p2y), new A.Point(pt2.X, pt2.Y)); sgc.EndFigure(false); } _dc.DrawGeometry(null, pen, sg); } }
private void DrawLineCurveInternal(SKCanvas canvas, SKPaint pen, bool isStroked, ref SKPoint pt1, ref SKPoint pt2, double curvature, CurveOrientation orientation, PointAlignment pt1a, PointAlignment pt2a) { if (isStroked) { using (var path = new SKPath()) { path.MoveTo(pt1.X, pt1.Y); double p1x = pt1.X; double p1y = pt1.Y; double p2x = pt2.X; double p2y = pt2.Y; LineShapeExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt1a, pt2a, ref p1x, ref p1y, ref p2x, ref p2y); path.CubicTo( (float)p1x, (float)p1y, (float)p2x, (float)p2y, pt2.X, pt2.Y); canvas.DrawPath(path, pen); } } }
/// <inheritdoc/> public override void Draw(object dc, LineShape line, double dx, double dy, object db, object r) { if (!line.IsStroked) { return; } var dxf = dc as DxfDocument; double _x1 = line.Start.X + dx; double _y1 = line.Start.Y + dy; double _x2 = line.End.X + dx; double _y2 = line.End.Y + dy; LineShapeExtensions.GetMaxLength(line, ref _x1, ref _y1, ref _x2, ref _y2); // TODO: Draw line start arrow. // TODO: Draw line end arrow. // TODO: Draw line curve. DrawLineInternal(dxf, _currentLayer, line.Style, line.IsStroked, _x1, _y1, _x2, _y2); }