private static void DrawEllipseInternal(AM.DrawingContext dc, AM.IBrush brush, AM.Pen pen, bool isStroked, bool isFilled, ref Rect2 rect) { if (!isFilled && !isStroked) return; var r = new A.Rect(rect.X, rect.Y, rect.Width, rect.Height); var g = new AM.EllipseGeometry(r); dc.DrawGeometry( isFilled ? brush : null, isStroked ? pen : null, g); }
private void DrawGridInternal(AM.DrawingContext dc, AM.Pen stroke, ref Rect2 rect, double offsetX, double offsetY, double cellWidth, double cellHeight, bool isStroked) { double ox = rect.X; double oy = rect.Y; double sx = ox + offsetX; double sy = oy + offsetY; double ex = ox + rect.Width; double ey = oy + rect.Height; for (double x = sx; x < ex; x += cellWidth) { var p0 = new A.Point( _scaleToPage(x), _scaleToPage(oy)); var p1 = new A.Point( _scaleToPage(x), _scaleToPage(ey)); DrawLineInternal(dc, stroke, isStroked, ref p0, ref p1); } for (double y = sy; y < ey; y += cellHeight) { var p0 = new A.Point( _scaleToPage(ox), _scaleToPage(y)); var p1 = new A.Point( _scaleToPage(ex), _scaleToPage(y)); DrawLineInternal(dc, stroke, isStroked, ref p0, ref p1); } }
private static void DrawRectangleInternal(AM.DrawingContext dc, AM.IBrush brush, AM.Pen pen, bool isStroked, bool isFilled, ref Rect2 rect) { if (!isStroked && !isFilled) return; var r = new A.Rect(rect.X, rect.Y, rect.Width, rect.Height); if (isFilled) { dc.FillRectangle(brush, r); } if (isStroked) { dc.DrawRectangle(pen, r); } }
private static A.Point DrawLineArrowInternal(AM.DrawingContext dc, AM.Pen pen, AM.IBrush brush, float x, float y, double angle, ArrowStyle style) { A.Point pt = default(A.Point); var rt = APAZ.MatrixHelper.Rotation(angle, new A.Vector(x, y)); double rx = style.RadiusX; double ry = style.RadiusY; double sx = 2.0 * rx; double sy = 2.0 * ry; switch (style.ArrowType) { default: case ArrowType.None: { pt = new A.Point(x, y); } break; case ArrowType.Rectangle: { pt = APAZ.MatrixHelper.TransformPoint(rt, new A.Point(x - (float)sx, y)); var rect = new Rect2(x - sx, y - ry, sx, sy); using (var d = dc.PushPreTransform(rt)) { DrawRectangleInternal(dc, brush, pen, style.IsStroked, style.IsFilled, ref rect); } } break; case ArrowType.Ellipse: { pt = APAZ.MatrixHelper.TransformPoint(rt, new A.Point(x - (float)sx, y)); using (var d = dc.PushPreTransform(rt)) { var rect = new Rect2(x - sx, y - ry, sx, sy); DrawEllipseInternal(dc, brush, pen, style.IsStroked, style.IsFilled, ref rect); } } break; case ArrowType.Arrow: { var pts = new A.Point[] { new A.Point(x, y), new A.Point(x - (float)sx, y + (float)sy), new A.Point(x, y), new A.Point(x - (float)sx, y - (float)sy), new A.Point(x, y) }; pt = APAZ.MatrixHelper.TransformPoint(rt, pts[0]); var p11 = APAZ.MatrixHelper.TransformPoint(rt, pts[1]); var p21 = APAZ.MatrixHelper.TransformPoint(rt, pts[2]); var p12 = APAZ.MatrixHelper.TransformPoint(rt, pts[3]); var p22 = APAZ.MatrixHelper.TransformPoint(rt, pts[4]); DrawLineInternal(dc, pen, style.IsStroked, ref p11, ref p21); DrawLineInternal(dc, pen, style.IsStroked, ref p12, ref p22); } break; } return pt; }
private void DrawLineArrowsInternal(AM.DrawingContext dc, XLine line, double dx, double dy, out A.Point pt1, out A.Point pt2) { AM.IBrush fillStartArrow = ToBrush(line.Style.StartArrowStyle.Fill); AM.Pen strokeStartArrow = ToPen(line.Style.StartArrowStyle, _scaleToPage); AM.IBrush fillEndArrow = ToBrush(line.Style.EndArrowStyle.Fill); AM.Pen strokeEndArrow = ToPen(line.Style.EndArrowStyle, _scaleToPage); double _x1 = line.Start.X + dx; double _y1 = line.Start.Y + dy; double _x2 = line.End.X + dx; double _y2 = line.End.Y + dy; line.GetMaxLength(ref _x1, ref _y1, ref _x2, ref _y2); float x1 = _scaleToPage(_x1); float y1 = _scaleToPage(_y1); float x2 = _scaleToPage(_x2); float y2 = _scaleToPage(_y2); var sas = line.Style.StartArrowStyle; var eas = line.Style.EndArrowStyle; double a1 = Math.Atan2(y1 - y2, x1 - x2); double a2 = Math.Atan2(y2 - y1, x2 - x1); // Draw start arrow. pt1 = DrawLineArrowInternal(dc, strokeStartArrow, fillStartArrow, x1, y1, a1, sas); // Draw end arrow. pt2 = DrawLineArrowInternal(dc, strokeEndArrow, fillEndArrow, x2, y2, a2, eas); }
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; XLineExtensions.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 static void DrawLineInternal(AM.DrawingContext dc, AM.Pen pen, bool isStroked, ref A.Point p0, ref A.Point p1) { if (isStroked) { dc.DrawLine(pen, p0, p1); } }