Esempio n. 1
0
        /// <inheritdoc/>
        public override void Draw(object dc, Core2D.Shapes.XPath path, double dx, double dy, ImmutableArray <Core2D.Data.XProperty> db, Core2D.Data.Database.XRecord r)
        {
            var _gfx = dc as XGraphics;

            var gp = path.Geometry.ToXGraphicsPath(dx, dy, _scaleToPage);

            if (path.IsFilled && path.IsStroked)
            {
                _gfx.DrawPath(
                    ToXPen(path.Style, _scaleToPage, _sourceDpi, _targetDpi),
                    ToXSolidBrush(path.Style.Fill),
                    gp);
            }
            else if (path.IsFilled && !path.IsStroked)
            {
                _gfx.DrawPath(
                    ToXSolidBrush(path.Style.Fill),
                    gp);
            }
            else if (!path.IsFilled && path.IsStroked)
            {
                _gfx.DrawPath(
                    ToXPen(path.Style, _scaleToPage, _sourceDpi, _targetDpi),
                    gp);
            }
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public override void Draw(object dc, Core2D.Shapes.XPath path, double dx, double dy, ImmutableArray <Core2D.Data.XProperty> db, Core2D.Data.Database.XRecord r)
        {
            if (!path.IsStroked && !path.IsFilled)
            {
                return;
            }

            var dxf   = dc as DxfDocument;
            var style = path.Style;

            IList <HatchBoundaryPath>  bounds;
            ICollection <EntityObject> entities;

            CreateHatchBoundsAndEntitiess(path.Geometry, dx, dy, out bounds, out entities);
            if (entities == null || bounds == null)
            {
                return;
            }

            if (path.IsFilled)
            {
                var fill             = ToColor(style.Fill);
                var fillTransparency = ToTransparency(style.Fill);

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

                dxf.AddEntity(hatch);
            }

            if (path.IsStroked)
            {
                // TODO: Add support for Closed paths.

                var stroke            = ToColor(style.Stroke);
                var strokeTansparency = ToTransparency(style.Stroke);
                var lineweight        = ToLineweight(style.Thickness);

                foreach (var entity in entities)
                {
                    entity.Layer = _currentLayer;
                    entity.Color = stroke;
                    entity.Transparency.Value = strokeTansparency;
                    entity.Lineweight         = lineweight;
                    dxf.AddEntity(entity);
                }
            }
        }