Exemple #1
0
        private Ellipse CreateEllipticalArc(Core2D.XArc arc, double dx, double dy)
        {
            var a = Core2D.GdiArc.FromXArc(arc, dx, dy);

            double _cx        = ToDxfX(a.X + a.Width / 2.0);
            double _cy        = ToDxfY(a.Y + a.Height / 2.0);
            double minor      = Math.Min(a.Height, a.Width);
            double major      = Math.Max(a.Height, a.Width);
            double startAngle = -a.EndAngle;
            double endAngle   = -a.StartAngle;
            double rotation   = 0;

            if (a.Height > a.Width)
            {
                startAngle += 90;
                endAngle   += 90;
                rotation    = -90;
            }

            return(new Ellipse()
            {
                Center = new Vector3(_cx, _cy, 0),
                MajorAxis = major,
                MinorAxis = minor,
                StartAngle = startAngle,
                EndAngle = endAngle,
                Rotation = rotation
            });
        }
Exemple #2
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, Core2D.XArc arc, double dx, double dy, ImmutableArray <Core2D.ShapeProperty> db, Core2D.Record r)
        {
            var _gfx = gfx as XGraphics;

            var a = Core2D.GdiArc.FromXArc(arc, dx, dy);

            if (arc.IsFilled)
            {
                var path = new XGraphicsPath();
                // NOTE: Not implemented in PdfSharp Core version.
                path.AddArc(
                    _scaleToPage(a.X),
                    _scaleToPage(a.Y),
                    _scaleToPage(a.Width),
                    _scaleToPage(a.Height),
                    a.StartAngle,
                    a.SweepAngle);

                if (arc.IsStroked)
                {
                    _gfx.DrawPath(
                        ToXPen(arc.Style, _scaleToPage),
                        ToXSolidBrush(arc.Style.Fill),
                        path);
                }
                else
                {
                    _gfx.DrawPath(
                        ToXSolidBrush(arc.Style.Fill),
                        path);
                }
            }
            else
            {
                if (arc.IsStroked)
                {
                    _gfx.DrawArc(
                        ToXPen(arc.Style, _scaleToPage),
                        _scaleToPage(a.X),
                        _scaleToPage(a.Y),
                        _scaleToPage(a.Width),
                        _scaleToPage(a.Height),
                        a.StartAngle,
                        a.SweepAngle);
                }
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="doc"></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 doc, Core2D.XArc arc, double dx, double dy, ImmutableArray <Core2D.ShapeProperty> db, Core2D.Record r)
        {
            var _doc  = doc as DxfDocument;
            var style = arc.Style;

            var dxfEllipse = CreateEllipticalArc(arc, dx, dy);

            if (arc.IsFilled)
            {
                var fill             = GetColor(style.Fill);
                var fillTransparency = GetTransparency(style.Fill);

                // TODO: The netDxf does not create hatch for Ellipse with end angle equal to 360.
                var bounds =
                    new List <HatchBoundaryPath>
                {
                    new HatchBoundaryPath(
                        new List <EntityObject>
                    {
                        (Ellipse)dxfEllipse.Clone()
                    })
                };

                var hatch = new Hatch(HatchPattern.Solid, bounds, false);
                hatch.Layer = _currentLayer;
                hatch.Color = fill;
                hatch.Transparency.Value = fillTransparency;

                _doc.AddEntity(hatch);
            }

            if (arc.IsStroked)
            {
                var stroke            = GetColor(style.Stroke);
                var strokeTansparency = GetTransparency(style.Stroke);
                var lineweight        = ThicknessToLineweight(style.Thickness);

                dxfEllipse.Layer = _currentLayer;
                dxfEllipse.Color = stroke;
                dxfEllipse.Transparency.Value = strokeTansparency;
                dxfEllipse.Lineweight.Value   = lineweight;

                _doc.AddEntity(dxfEllipse);
            }
        }