Ejemplo n.º 1
0
        public void DrawEllipse(object gfx, Core.IStyle style, Core.XEllipse ellipse)
        {
            double x      = ellipse.X - ellipse.RadiusX;
            double y      = ellipse.Y - ellipse.RadiusY;
            double width  = ellipse.RadiusX + ellipse.RadiusX;
            double height = ellipse.RadiusY + ellipse.RadiusY;

            if (ellipse.IsFilled)
            {
                (gfx as XGraphics).DrawEllipse(
                    ToXPen(style),
                    ToXSolidBrush(style.Fill),
                    ScaleToPage(x),
                    ScaleToPage(y),
                    ScaleToPage(width),
                    ScaleToPage(height));
            }
            else
            {
                (gfx as XGraphics).DrawEllipse(
                    ToXPen(style),
                    ScaleToPage(x),
                    ScaleToPage(y),
                    ScaleToPage(width),
                    ScaleToPage(height));
            }
        }
Ejemplo n.º 2
0
        private void RenderLayer(object gfx, IEnumerable <Core.IShape> shapes)
        {
            Core.IStyle overrideStyle = LayerStyleOverride;

            foreach (var shape in shapes)
            {
                shape.Render(
                    gfx,
                    this,
                    overrideStyle == null ? shape.Style : overrideStyle);

                if (EnablePinRendering)
                {
                    if (shape is Core.XBlock)
                    {
                        foreach (var pin in (shape as Core.XBlock).Pins)
                        {
                            pin.Render(
                                gfx,
                                this,
                                overrideStyle == null ? pin.Style : overrideStyle);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void DrawImage(object gfx, Core.IStyle style, Core.XImage image)
 {
     (gfx as XGraphics).DrawImage(
         XImage.FromFile(image.Path.LocalPath),
         ScaleToPage(image.X),
         ScaleToPage(image.Y),
         ScaleToPage(image.Width),
         ScaleToPage(image.Height));
 }
Ejemplo n.º 4
0
 public void DrawLine(object gfx, Core.IStyle style, Core.XLine line)
 {
     (gfx as XGraphics).DrawLine(
         ToXPen(style),
         ScaleToPage(line.X1),
         ScaleToPage(line.Y1),
         ScaleToPage(line.X2),
         ScaleToPage(line.Y2));
 }
Ejemplo n.º 5
0
 private XPen ToXPen(Core.IStyle style)
 {
     return(new XPen(
                ToXColor(style.Stroke),
                ScaleToPage(XUnit.FromMillimeter(style.Thickness).Value))
     {
         LineCap = XLineCap.Round
     });
 }
Ejemplo n.º 6
0
        private void RenderConatiner(object gfx, Core.IContainer container)
        {
            Core.IStyle overrideStyle = TemplateStyleOverride;

            foreach (var shape in container.Shapes)
            {
                shape.Render(
                    gfx,
                    this,
                    overrideStyle == null ? shape.Style : overrideStyle);
            }
        }
Ejemplo n.º 7
0
        public void DrawPin(object gfx, Core.IStyle style, Core.XPin pin)
        {
            double x      = pin.X - PinRadius;
            double y      = pin.Y - PinRadius;
            double width  = PinRadius + PinRadius;
            double height = PinRadius + PinRadius;

            (gfx as XGraphics).DrawEllipse(
                ToXPen(style),
                ToXSolidBrush(style.Fill),
                ScaleToPage(x),
                ScaleToPage(y),
                ScaleToPage(width),
                ScaleToPage(height));
        }
Ejemplo n.º 8
0
        public void DrawWire(object gfx, Core.IStyle style, Core.XWire wire)
        {
            var position = WirePosition.Calculate(
                wire,
                InvertSize,
                ShortenWire,
                ShortenSize);

            if (wire.InvertStart)
            {
                double x      = position.InvertX1 - InvertSize;
                double y      = position.InvertY1 - InvertSize;
                double width  = InvertSize + InvertSize;
                double height = InvertSize + InvertSize;

                (gfx as XGraphics).DrawEllipse(
                    ToXPen(style),
                    ScaleToPage(x),
                    ScaleToPage(y),
                    ScaleToPage(width),
                    ScaleToPage(height));
            }

            if (wire.InvertEnd)
            {
                double x      = position.InvertX2 - InvertSize;
                double y      = position.InvertY2 - InvertSize;
                double width  = InvertSize + InvertSize;
                double height = InvertSize + InvertSize;

                (gfx as XGraphics).DrawEllipse(
                    ToXPen(style),
                    ScaleToPage(x),
                    ScaleToPage(y),
                    ScaleToPage(width),
                    ScaleToPage(height));
            }

            (gfx as XGraphics).DrawLine(
                ToXPen(style),
                ScaleToPage(position.StartX),
                ScaleToPage(position.StartY),
                ScaleToPage(position.EndX),
                ScaleToPage(position.EndY));
        }
Ejemplo n.º 9
0
 public void DrawRectangle(object gfx, Core.IStyle style, Core.XRectangle rectangle)
 {
     if (rectangle.IsFilled)
     {
         (gfx as XGraphics).DrawRectangle(
             ToXPen(style),
             ToXSolidBrush(style.Fill),
             ScaleToPage(rectangle.X),
             ScaleToPage(rectangle.Y),
             ScaleToPage(rectangle.Width),
             ScaleToPage(rectangle.Height));
     }
     else
     {
         (gfx as XGraphics).DrawRectangle(
             ToXPen(style),
             ScaleToPage(rectangle.X),
             ScaleToPage(rectangle.Y),
             ScaleToPage(rectangle.Width),
             ScaleToPage(rectangle.Height));
     }
 }
Ejemplo n.º 10
0
        public void DrawText(object gfx, Core.IStyle style, Core.XText text)
        {
            XPdfFontOptions options = new XPdfFontOptions(
                PdfFontEncoding.Unicode,
                PdfFontEmbedding.Always);

            XFont font = new XFont(
                text.FontName,
                ScaleToPage(text.FontSize),
                XFontStyle.Regular,
                options);

            XRect rect = new XRect(
                ScaleToPage(text.X),
                ScaleToPage(text.Y),
                ScaleToPage(text.Width),
                ScaleToPage(text.Height));

            XStringFormat format = new XStringFormat();

            switch (text.HAlignment)
            {
            case Core.HAlignment.Left:
                format.Alignment = XStringAlignment.Near;
                break;

            case Core.HAlignment.Center:
                format.Alignment = XStringAlignment.Center;
                break;

            case Core.HAlignment.Right:
                format.Alignment = XStringAlignment.Far;
                break;
            }

            switch (text.VAlignment)
            {
            case Core.VAlignment.Top:
                format.LineAlignment = XLineAlignment.Near;
                break;

            case Core.VAlignment.Center:
                format.LineAlignment = XLineAlignment.Center;
                break;

            case Core.VAlignment.Bottom:
                format.LineAlignment = XLineAlignment.Far;
                break;
            }

            if (text.IsFilled)
            {
                (gfx as XGraphics).DrawRectangle(ToXSolidBrush(style.Fill), rect);
            }

            (gfx as XGraphics).DrawString(
                text.Bind(Database),
                font,
                ToXSolidBrush(style.Stroke),
                rect,
                format);
        }