Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></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 gfx, XBezier bezier, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
        {
            var _gfx = gfx as Graphics;

            Brush brush = ToSolidBrush(bezier.Style.Fill);
            Pen pen = ToPen(bezier.Style, _scaleToPage);

            var path = new GraphicsPath();
            path.AddBezier(
                new PointF(
                    _scaleToPage(bezier.Point1.X),
                    _scaleToPage(bezier.Point1.Y)),
                new PointF(
                    _scaleToPage(bezier.Point2.X),
                    _scaleToPage(bezier.Point2.Y)),
                new PointF(
                    _scaleToPage(bezier.Point3.X),
                    _scaleToPage(bezier.Point3.Y)),
                new PointF(
                    _scaleToPage(bezier.Point4.X),
                    _scaleToPage(bezier.Point4.Y)));

            if (bezier.IsFilled)
            {
                _gfx.FillPath(brush, path);
            }

            if (bezier.IsStroked)
            {
                _gfx.DrawPath(pen, path);
            }

            path.Dispose();
            brush.Dispose();
            pen.Dispose();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="qbezier"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, XQBezier qbezier, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
        {
            var _gfx = gfx as Graphics;

            Brush brush = ToSolidBrush(qbezier.Style.Fill);
            Pen pen = ToPen(qbezier.Style, _scaleToPage);

            double x1 = qbezier.Point1.X;
            double y1 = qbezier.Point1.Y;
            double x2 = qbezier.Point1.X + (2.0 * (qbezier.Point2.X - qbezier.Point1.X)) / 3.0;
            double y2 = qbezier.Point1.Y + (2.0 * (qbezier.Point2.Y - qbezier.Point1.Y)) / 3.0;
            double x3 = x2 + (qbezier.Point3.X - qbezier.Point1.X) / 3.0;
            double y3 = y2 + (qbezier.Point3.Y - qbezier.Point1.Y) / 3.0;
            double x4 = qbezier.Point3.X;
            double y4 = qbezier.Point3.Y;

            var path = new GraphicsPath();
            path.AddBezier(
                new PointF(
                    _scaleToPage(x1 + dx),
                    _scaleToPage(y1 + dy)),
                new PointF(
                    _scaleToPage(x2 + dx),
                    _scaleToPage(y2 + dy)),
                new PointF(
                    _scaleToPage(x3 + dx),
                    _scaleToPage(y3 + dy)),
                new PointF(
                    _scaleToPage(x4 + dx),
                    _scaleToPage(y4 + dy)));

            if (qbezier.IsFilled)
            {
                _gfx.FillPath(brush, path);
            }

            if (qbezier.IsStroked)
            {
                _gfx.DrawPath(pen, path);
            }

            path.Dispose();
            brush.Dispose();
            pen.Dispose();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="arc"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, XArc arc, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
        {
            var a = GdiArc.FromXArc(arc, dx, dy);
            if (a.Width <= 0.0 || a.Height <= 0.0)
                return;

            var _gfx = gfx as Graphics;

            Brush brush = ToSolidBrush(arc.Style.Fill);
            Pen pen = ToPen(arc.Style, _scaleToPage);

            if (arc.IsFilled)
            {
                var path = new GraphicsPath();
                path.AddArc(
                    _scaleToPage(a.X),
                    _scaleToPage(a.Y),
                    _scaleToPage(a.Width),
                    _scaleToPage(a.Height),
                    (float)a.StartAngle,
                    (float)a.SweepAngle);

                _gfx.FillPath(brush, path);

                if (arc.IsStroked)
                {
                    _gfx.DrawPath(pen, path);
                }

                path.Dispose();
            }
            else
            {
                if (arc.IsStroked)
                {
                    _gfx.DrawArc(
                        pen,
                        _scaleToPage(a.X),
                        _scaleToPage(a.Y),
                        _scaleToPage(a.Width),
                        _scaleToPage(a.Height),
                        (float)a.StartAngle,
                        (float)a.SweepAngle);
                }
            }

            brush.Dispose();
            pen.Dispose();
        }