示例#1
0
        private void DrawGridInternal(XGraphics gfx, XPen stroke, ref Core2D.Math.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 XPoint(
                    _scaleToPage(x),
                    _scaleToPage(oy));
                var p1 = new XPoint(
                    _scaleToPage(x),
                    _scaleToPage(ey));
                DrawLineInternal(gfx, stroke, isStroked, ref p0, ref p1);
            }

            for (double y = sy; y < ey; y += cellHeight)
            {
                var p0 = new XPoint(
                    _scaleToPage(ox),
                    _scaleToPage(y));
                var p1 = new XPoint(
                    _scaleToPage(ex),
                    _scaleToPage(y));
                DrawLineInternal(gfx, stroke, isStroked, ref p0, ref p1);
            }
        }
示例#2
0
 private void DrawBackgroundInternal(XGraphics gfx, Core2D.Style.ArgbColor color, Core2D.Math.Rect2 rect)
 {
     gfx.DrawRectangle(
         null,
         ToXSolidBrush(color),
         _scaleToPage(rect.X),
         _scaleToPage(rect.Y),
         _scaleToPage(rect.Width),
         _scaleToPage(rect.Height));
 }
示例#3
0
        private void DrawEllipseInternal(DxfDocument dxf, Layer layer, bool isFilled, bool isStroked, Core2D.Style.BaseStyle style, ref Core2D.Math.Rect2 rect)
        {
            var dxfEllipse = CreateEllipse(rect.X, rect.Y, rect.Width, rect.Height);

            if (isFilled)
            {
                var fill             = ToColor(style.Fill);
                var fillTransparency = ToTransparency(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 = layer;
                hatch.Color = fill;
                hatch.Transparency.Value = fillTransparency;

                dxf.AddEntity(hatch);
            }

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

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

                dxf.AddEntity(dxfEllipse);
            }
        }
示例#4
0
        private void DrawGridInternal(DxfDocument dxf, Layer layer, Core2D.Style.ShapeStyle style, double offsetX, double offsetY, double cellWidth, double cellHeight, ref Core2D.Math.Rect2 rect)
        {
            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 gx = sx; gx < ex; gx += cellWidth)
            {
                DrawLineInternal(dxf, layer, style, true, gx, oy, gx, ey);
            }

            for (double gy = sy; gy < ey; gy += cellHeight)
            {
                DrawLineInternal(dxf, layer, style, true, ox, gy, ex, gy);
            }
        }
示例#5
0
        private void DrawRectangleInternal(DxfDocument dxf, Layer layer, bool isFilled, bool isStroked, Core2D.Style.BaseStyle style, ref Core2D.Math.Rect2 rect)
        {
            double x = rect.X;
            double y = rect.Y;
            double w = rect.Width;
            double h = rect.Height;

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

                var bounds =
                    new List <HatchBoundaryPath>
                {
                    new HatchBoundaryPath(
                        new List <EntityObject>
                    {
                        CreateLine(x, y, x + w, y),
                        CreateLine(x + w, y, x + w, y + h),
                        CreateLine(x + w, y + h, x, y + h),
                        CreateLine(x, y + h, x, y)
                    })
                };

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

                dxf.AddEntity(hatch);
            }

            if (isStroked)
            {
                DrawLineInternal(dxf, layer, style, true, x, y, x + w, y);
                DrawLineInternal(dxf, layer, style, true, x + w, y, x + w, y + h);
                DrawLineInternal(dxf, layer, style, true, x + w, y + h, x, y + h);
                DrawLineInternal(dxf, layer, style, true, x, y + h, x, y);
            }
        }