DrawRectangle() public method

Draws a rectangle.
public DrawRectangle ( XBrush brush, Rectangle rect ) : void
brush XBrush
rect Rectangle
return void
    void RenderTextAlignment(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XRect rect = new XRect(0, 0, 250, 140);

      XFont font = new XFont("Verdana", 10);
      XBrush brush = XBrushes.Purple;
      XStringFormat format = new XStringFormat();

      gfx.DrawRectangle(XPens.YellowGreen, rect);
      gfx.DrawLine(XPens.YellowGreen, rect.Width / 2, 0, rect.Width / 2, rect.Height);
      gfx.DrawLine(XPens.YellowGreen, 0, rect.Height / 2, rect.Width, rect.Height / 2);

#if true
      gfx.DrawString("TopLeft", font, brush, rect, format);

      format.Alignment = XStringAlignment.Center;
      gfx.DrawString("TopCenter", font, brush, rect, format);

      format.Alignment = XStringAlignment.Far;
      gfx.DrawString("TopRight", font, brush, rect, format);

      format.LineAlignment = XLineAlignment.Center;
      format.Alignment = XStringAlignment.Near;
      gfx.DrawString("CenterLeft", font, brush, rect, format);

      format.Alignment = XStringAlignment.Center;
      gfx.DrawString("Center", font, brush, rect, format);

      format.Alignment = XStringAlignment.Far;
      gfx.DrawString("CenterRight", font, brush, rect, format);

      format.LineAlignment = XLineAlignment.Far;
      format.Alignment = XStringAlignment.Near;
      gfx.DrawString("BottomLeft", font, brush, rect, format);

      format.Alignment = XStringAlignment.Center;
      gfx.DrawString("BottomCenter", font, brush, rect, format);

      format.Alignment = XStringAlignment.Far;
      gfx.DrawString("BottomRight", font, brush, rect, format);
#else
      format.Alignment = XStringAlignment.Far;
      gfx.DrawString("TopRight", font, brush, rect, format);
#endif
    }
    /// <summary>
    /// Demonstrates the use of XLinearGradientBrush.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      XRect rect;
      XLinearGradientBrush brush;
      Graphics grfx = gfx.Internals.Graphics;

      XLinearGradientBrush brush2 = 
        new XLinearGradientBrush(
        new XPoint(100, 100), 
        new XPoint(300, 300), 
        XColors.DarkRed, XColors.Yellow);

      //gfx.FillRectangle(brush, 0, 0, 600, 600);
      //gfx.TranslateTransform(35, 200);
      //gfx.RotateTransform(17);

      rect = new XRect(20, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.DarkRed, XColors.Yellow, XLinearGradientMode.Horizontal);
      gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(140, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.DarkRed, XColors.Yellow, XLinearGradientMode.Vertical);
        gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(260, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.DarkRed, XColors.Yellow, XLinearGradientMode.ForwardDiagonal);
        gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(380, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.DarkRed, XColors.Yellow, XLinearGradientMode.BackwardDiagonal);
        gfx.DrawRectangle(XPens.Red, brush, rect);


      gfx.TranslateTransform(80, 250);
      gfx.ScaleTransform(1.1);
      gfx.RotateTransform(20);

      rect = new XRect(20, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.Orange, XColors.DarkBlue, XLinearGradientMode.Horizontal);
      gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(140, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.Orange, XColors.DarkBlue, XLinearGradientMode.Vertical);
      gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(260, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.Orange, XColors.DarkBlue, XLinearGradientMode.ForwardDiagonal);
      gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(380, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.Orange, XColors.DarkBlue, XLinearGradientMode.BackwardDiagonal);
      gfx.DrawRectangle(XPens.Red, brush, rect);
    }
Example #3
1
    void RenderEllipses(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XPen pen = new XPen(XColors.Navy, Math.PI);

      gfx.DrawRectangle(pen, 10, 0, 100, 60);
      gfx.DrawRectangle(XBrushes.DarkOrange, 130, 0, 100, 60);
      gfx.DrawRectangle(pen, XBrushes.DarkOrange, 10, 80, 100, 60);
      gfx.DrawRectangle(pen, XBrushes.DarkOrange, 150, 80, 60, 60);
    }
Example #4
1
    /// <summary>
    /// Draws rectangles.
    /// </summary>
    void DrawRectangle(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawRectangle");

      XPen pen = new XPen(XColors.Navy, Math.PI);

      gfx.DrawRectangle(pen, 10, 0, 100, 60);
      gfx.DrawRectangle(XBrushes.DarkOrange, 130, 0, 100, 60);
      gfx.DrawRectangle(pen, XBrushes.DarkOrange, 10, 80, 100, 60);
      gfx.DrawRectangle(pen, XBrushes.DarkOrange, 150, 80, 60, 60);

      EndBox(gfx);
    }
Example #5
1
        /// <summary>
        /// Draws a sample box.
        /// </summary>
        public void BeginBox(XGraphics gfx, int number)
        {
            //obracene XY
            gfx.RotateAtTransform(90.0, new XPoint(height / 4, width / 4));
            gfx.TranslateTransform(+62, +63);
            //const int dEllipse = 15;
            XRect rect = new XRect(0, 0, height /2 -2, width/2 -2);

            if (number % 2 == 0)
                rect.X += height/2 +2;
            rect.Y =  ((number - 1) / 2) * (-width/2 - 3);
            //rect.Inflate(-10, -10);
            //XRect rect2 = rect;

            XPen pen = new XPen(XColors.Black, 1);

            gfx.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);

            //rect2.Offset(this.borderWidth, this.borderWidth);
            //gfx.DrawRoundedRectangle(new XSolidBrush(this.shadowColor), rect2, new XSize(dEllipse + 8, dEllipse + 8));
            //XLinearGradientBrush brush = new XLinearGradientBrush(rect, this.backColor, this.backColor2, XLinearGradientMode.Vertical);
            //gfx.DrawRoundedRectangle(this.borderPen, brush, rect, new XSize(dEllipse, dEllipse));
            //rect.Inflate(-5, -5);

            //rect.Inflate(-10, -5);
            //rect.Y += 20;
            //rect.Height -= 20;
            ////gfx.DrawRectangle(XPens.Red, rect);

            //    gfx.TranslateTransform(rect.X, rect.Y);

            this.state = gfx.Save();
        }
Example #6
0
    public override void RenderPage(XGraphics gfx)
    {
      //base.RenderPage(gfx);

      XTextFormatter tf = new XTextFormatter(gfx);
      XRect rect;
      string text = this.properties.Font1.Text;
      //text = "First\nSecond Line\nlaksdjf 234 234";

      rect = new XRect(40, 100, 250, 200);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      //tf.Alignment = ParagraphAlignment.Left;
      tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush, 
        rect, XStringFormats.TopLeft);

      rect = new XRect(310, 100, 250, 200);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.Alignment = XParagraphAlignment.Right;
      tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
        rect, XStringFormats.TopLeft);

      rect = new XRect(40, 400, 250, 200);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.Alignment = XParagraphAlignment.Center;
      tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
        rect, XStringFormats.TopLeft);

      rect = new XRect(310, 400, 250, 200);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.Alignment = XParagraphAlignment.Justify;
      tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
        rect, XStringFormats.TopLeft);
    }
Example #7
0
    void RenderMeasureText(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XFontStyle style = XFontStyle.Regular;
      XFont font = new XFont("Times New Roman", 95, style);

      string text = "Hello";
      double x = 20, y = 100;
      XSize size = gfx.MeasureString(text, font);

      double lineSpace = font.GetHeight(gfx);
      int cellSpace = font.FontFamily.GetLineSpacing(style);
      int cellAscent = font.FontFamily.GetCellAscent(style);
      int cellDescent = font.FontFamily.GetCellDescent(style);
      int cellLeading = cellSpace - cellAscent - cellDescent;

      // Get effective ascent
      double ascent = lineSpace * cellAscent / cellSpace;
      gfx.DrawRectangle(XBrushes.Bisque, x, y - ascent, size.Width, ascent);

      // Get effective descent
      double descent = lineSpace * cellDescent / cellSpace;
      gfx.DrawRectangle(XBrushes.LightGreen, x, y, size.Width, descent);

      // Get effective leading
      double leading = lineSpace * cellLeading / cellSpace;
      gfx.DrawRectangle(XBrushes.Yellow, x, y + descent, size.Width, leading);

      // Draw text half transparent
      XColor color = XColors.DarkSlateBlue;
      color.A = 0.6;
      gfx.DrawString(text, font, new XSolidBrush(color), x, y);
    }
 private double DrawRightGuard(ref PdfSharp.Drawing.XGraphics g, double left)
 {
     g.DrawRectangle(null, XBrushes.Black, new XRect(Util.MillimeterToPoint(left + Left + offsetLeft), Util.MillimeterToPoint(offsetTop + Top), Util.MillimeterToPoint(BarWidth), Util.MillimeterToPoint(Height)));
     left += BarWidth;
     left += BarWidth;
     g.DrawRectangle(null, XBrushes.Black, new XRect(Util.MillimeterToPoint(left + Left + offsetLeft), Util.MillimeterToPoint(offsetTop + Top), Util.MillimeterToPoint(BarWidth), Util.MillimeterToPoint(Height)));
     left += BarWidth;
     return(left);
 }
Example #9
0
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      string text = "TgfÄÖÜWi9";
      if (this.properties.Font1.Text != "")
        text = this.properties.Font1.Text;
      float x = 100, y = 300;
      string familyName = properties.Font1.FamilyName;
      XFontStyle style = this.properties.Font1.Style;
      float emSize = this.properties.Font1.Size;

      //familyName = "Verdana";
      //style = XFontStyle.Regular;
      //emSize = 20;
      //text = "X";

      XFont font = CreateFont(familyName, emSize, style);
      //font = this.properties.Font1.Font;
      XSize size = gfx.MeasureString(text, font);

      double lineSpace = font.GetHeight(gfx);
      int cellSpace = font.FontFamily.GetLineSpacing(style);
      int cellAscent = font.FontFamily.GetCellAscent(style);
      int cellDescent = font.FontFamily.GetCellDescent(style);
      int cellLeading = cellSpace - cellAscent - cellDescent;

      double ascent = lineSpace * cellAscent / cellSpace;
      gfx.DrawRectangle(XBrushes.Bisque, x, y - ascent, size.Width, ascent);

      double descent = lineSpace * cellDescent / cellSpace;
      gfx.DrawRectangle(XBrushes.LightGreen, x, y, size.Width, descent);

      double leading = lineSpace * cellLeading / cellSpace;
      gfx.DrawRectangle(XBrushes.Yellow, x, y + descent, size.Width, leading);

      //gfx.DrawRectangle(this.properties.Brush1.Brush, x, y - size.Height, size.Width, size.Height);
      //gfx.DrawLine(this.properties.Pen2.Pen, x, y, x + size.Width, y);
      //gfx.DrawString("Hello", this.properties.Font1.Font, this.properties.Font1.Brush, 200, 200);

#if true_
      XPdfFontOptions pdfOptions = new XPdfFontOptions(false, true);
      font = new XFont("Tahoma", 8, XFontStyle.Regular, pdfOptions);
      text = "Hallo";
      text = chinese;
#endif
      gfx.DrawString(text, font, this.properties.Font1.Brush, x, y);

#if true
      XFont font2 = CreateFont(familyName, emSize, XFontStyle.Italic);
      gfx.DrawString(text, font2, this.properties.Font1.Brush, x, y+50);
#endif
      //gfx.DrawLine(XPens.Red, x, y + 10, x + 13.7, y + 10);
      //gfx.DrawString(text, font, this.properties.Font1.Brush, x, y + 20);
    }
Example #10
0
    /// <summary>
    /// Demonstrates the use of XGraphics.Transform.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      //XGraphicsState state = gfx.Save();

      gfx.Save();
      gfx.IntersectClip(new XRect(20, 20, 300, 500));
      gfx.DrawRectangle(XBrushes.Yellow, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);
      gfx.Restore();

      gfx.Save();
      gfx.IntersectClip(new XRect(100, 200, 300, 500));
      gfx.DrawRectangle(XBrushes.LightBlue, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);

      gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
      gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));


      Matrix matrix = new Matrix();
      //matrix.Scale(2f, 1.5f);
      //matrix.Translate(-200, -400);
      //matrix.Rotate(45);
      //matrix.Translate(200, 400);
      //gfx.Transform = matrix;
      //gfx.TranslateTransform(50, 30);

#if true
      gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
      gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
      gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
      gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
      gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
      gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
      bool id = matrix.IsIdentity;
      matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
      //matrix.Translate(30, -50);
      matrix.Rotate(15, MatrixOrder.Prepend);
      //Matrix mtx = gfx.Transform.ToGdiMatrix();
      //gfx.Transform = matrix;

      gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
      gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));

      gfx.Restore();

      gfx.DrawLine(XPens.Red, 0, 0, 1000, 1000);

      gfx.DrawPolygon(XPens.SandyBrown, GetPentagram(75, new PointF(150, 200)));

    }
    /// <summary>
    /// Demonstrates the use of XGraphics.DrawRectangle.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      // Stroke rectangle
      gfx.DrawRectangle(properties.Pen1.Pen, 50, 100, 450, 150);

      // Fill rectangle
      gfx.DrawRectangle(properties.Brush2.Brush, new Rectangle(50, 300, 450, 150));

      // Stroke and fill rectangle
      gfx.DrawRectangle(properties.Pen1.Pen, properties.Brush2.Brush, new RectangleF(50, 500, 450, 150));
    }
Example #12
0
    void Box1(XGraphics gfx, RectangleF rect, float startAngle, float sweepAngle)
    {
      float xc = rect.X + rect.Width / 2;
      float yc = rect.Y + rect.Height / 2;
      double a = startAngle * 0.0174532925199433;
      double b = (startAngle + sweepAngle) * 0.0174532925199433;

      gfx.DrawRectangle(XPens.Black, rect);

      //      for (float deg = 0; deg < 360; deg += 10)
      //        gfx.DrawLine(XPens.Yellow, xc, yc, 
      //          (float)(xc + rect.Width * Math.Cos(deg * 0.0174532925199433)), 
      //          (float)(yc + rect.Height * Math.Sin(deg * 0.0174532925199433)));

      float f = Math.Max(rect.Width, rect.Height) * 3 / 2;
      for (float deg = 0; deg < 360; deg += 10)
        gfx.DrawLine(XPens.Goldenrod, xc, yc, 
          (float)(xc + f * Math.Cos(deg * 0.0174532925199433)), 
          (float)(yc + f * Math.Sin(deg * 0.0174532925199433)));

      gfx.DrawLine(XPens.PaleGreen, xc, rect.Y, xc, rect.Y + rect.Height);
      gfx.DrawLine(XPens.PaleGreen, rect.X, yc, rect.X + rect.Width, yc);
      //gfx.DrawLine(XPens.DarkGray, xc, yc, (float)(xc + rect.Width / 2 * Math.Cos(a)), (float)(yc + rect.Height / 2 * Math.Sin(a)));
      //gfx.DrawLine(XPens.DarkGray, xc, yc, (float)(xc + rect.Width / 2 * Math.Cos(b)), (float)(yc + rect.Height / 2 * Math.Sin(b)));
    }
Example #13
0
        public void Draw(XGraphics gfx)
        {
            gfx.DrawRectangle(Pen, Brush, Rect);

            double yOffset = 5;

            //Print InputBox Title, Left Top corner
            if (!string.IsNullOrEmpty(Title))
            {
                var titleLabel = new Label(Rect.X + 5, Rect.Y, Title)
                    {
                        Brush = XBrushes.Black,
                        Font = new XFont(Font.FontFamily.Name, 8, XFontStyle.Bold, Font.PdfOptions),
                        Pen = XPens.Black
                    };
                titleLabel.Draw(gfx);
                yOffset = 15;
            }

            //Print InputBox Value
            if (!string.IsNullOrEmpty(Value))
            {
                var valLabel = new Label(new XRect(Rect.X + 10, Rect.Y + yOffset, Rect.Width, Rect.Height), Value)
                    {
                        Alignment = XParagraphAlignment.Left,
                        Brush = XBrushes.Black,
                        Font = new XFont(Font.FontFamily.Name, 12, XFontStyle.Regular, Font.PdfOptions),
                        Pen = XPens.Black,
                    };
                valLabel.Draw(gfx);
                yOffset += valLabel.Rect.Height;
            }
        }
        public override void Render(ref PdfSharp.Drawing.XGraphics gfx, double offsetLeft, double offsetTop, double scaleX, double scaleY)
        {
            PreRender(ref gfx, offsetLeft, offsetTop, scaleX, scaleY);
            if (SourceImage != null)
            {
                double widthScale  = (Width * scaleX) / SourceImage.Width;
                double heightScale = (Height * scaleY) / SourceImage.Height;

                double scale = Math.Min(widthScale, heightScale);

                double width  = SourceImage.Width * scale;
                double height = SourceImage.Height * scale;

                double offsetLeftImage = ((Width * scaleX) - width) / 2.0;
                double offsetTopImage  = ((Height * scaleY) - height) / 2.0;

                gfx.DrawImage(SourceImage,
                              Util.MillimeterToPoint(offsetLeft + Left + offsetLeftImage),
                              Util.MillimeterToPoint(offsetTop + Top + offsetTopImage),
                              Util.MillimeterToPoint(width),
                              Util.MillimeterToPoint(height));
            }
            else
            {
                gfx.DrawRectangle(XBrushes.White, new Rectangle(
                                      (int)Util.MillimeterToPoint(offsetLeft + Left),
                                      (int)Util.MillimeterToPoint(offsetTop + Top),
                                      (int)Util.MillimeterToPoint(Width * scaleX),
                                      (int)Util.MillimeterToPoint(Height * scaleY)));
            }

            base.Render(ref gfx, offsetLeft, offsetTop, scaleX, scaleY);
        }
Example #15
0
    void DrawCodePage(XGraphics gfx, XPoint origin)
    {
      const double dx = 25;
      const double dy = 25;
      XFont labelFont = new XFont("Verdana", 10, XFontStyle.Bold);
      //XFont font = new XFont("Bauhaus", 16);
      XFont font = this.properties.Font1.Font;
      //XFont labelFont = font;
      //font = new XFont("Symbol", 16);
      Encoding encoding = Encoding.GetEncoding(1252);
      double asdf = XColors.LightGray.GS;
      //XBrush lighter = new XSolidBrush(XColor.FromGrayScale(XColor.LightGray.GS * 1.1));
      XBrush lighter = new XSolidBrush(XColor.FromGrayScale(0.9));

      XFontStyle style = font.Style;
      double lineSpace = font.GetHeight(gfx);
      int cellSpace   = font.FontFamily.GetLineSpacing(style);
      int cellAscent  = font.FontFamily.GetCellAscent(style);
      int cellDescent = font.FontFamily.GetCellDescent(style);
      int cellLeading = cellSpace - cellAscent - cellDescent;

      double ascent  = lineSpace * cellAscent / cellSpace;
      double descent = lineSpace * cellDescent / cellSpace;
      double leading = lineSpace * cellLeading / cellSpace;

      double x = origin.X + dx;
      double y = origin.Y;
      //for (int idx = 0; idx < 16; idx++)
      //  gfx.DrawString("x" + idx.ToString("X"), labelFont, XBrushes.DarkGray, x + idx * dx, y);
      for (int row = 0; row < 16; row++)
      {
        x = origin.X;
        y += dy;
        //gfx.DrawString(row.ToString("X") + "x", labelFont, XBrushes.DarkGray, x, y);
        for (int clm = 0; clm < 16; clm++)
        {
          x += dx;
          string glyph = encoding.GetString(new byte[1]{Convert.ToByte(row * 16 + clm)});
          glyph += "!";
          XSize size = gfx.MeasureString(glyph, font);
          gfx.DrawRectangle(XBrushes.LightGray, x, y - size.Height + descent, size.Width, size.Height);
          gfx.DrawRectangle(lighter, x, y - size.Height + descent, size.Width, leading);
          gfx.DrawRectangle(lighter, x, y, size.Width, descent);
          gfx.DrawString(glyph, font, XBrushes.Black, x, y);
        }
      }
    }
Example #16
0
        public void Render(XGraphics gfx, FixedElement element)
        {
            var spec = (Backgrounded) element.Specification;

            if (spec.BackgroundColor != Colors.Transparent)
            {
                var backgroundBrush = new XSolidBrush(XColor.FromArgb(spec.BackgroundColor));
                gfx.DrawRectangle(backgroundBrush,
                                  element.InnerBox.Left.Points,
                                  element.InnerBox.Top.Points,
                                  element.InnerBox.Width.Points,
                                  element.InnerBox.Height.Points);
            }
        }
Example #17
0
    void RenderClipPath(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XGraphicsPath path = new XGraphicsPath();
      path.AddString("Clip!", new XFontFamily("Verdana"), XFontStyle.Bold, 90, new XRect(0, 0, 250, 140),
        XStringFormats.Center);

      gfx.IntersectClip(path);

      gfx.DrawRectangle(XBrushes.LightSalmon, new XRect(0, 0, 10000, 10000));
      // Draw a beam of dotted lines
      XPen pen = XPens.DarkRed.Clone();
      pen.DashStyle = XDashStyle.Dot;
      for (double r = 0; r <= 90; r += 0.5)
        gfx.DrawLine(pen, 0, 0, 1000 * Math.Cos(r / 90 * Math.PI), 1000 * Math.Sin(r / 90 * Math.PI));
    }
Example #18
0
    /// <summary>
    /// Renders the OMR code.
    /// </summary>
    protected internal override void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position)
    {
      XGraphicsState state = gfx.Save();

      switch (this.direction)
      {
        case CodeDirection.RightToLeft:
          gfx.RotateAtTransform(180, position);
          break;

        case CodeDirection.TopToBottom:
          gfx.RotateAtTransform(90, position);
          break;

        case CodeDirection.BottomToTop:
          gfx.RotateAtTransform(-90, position);
          break;
      }

      //XPoint pt = center - this.size / 2;
      XPoint pt = position - CodeBase.CalcDistance(AnchorType.TopLeft, this.anchor, this.size);
      uint value;
      uint.TryParse(this.text, out value);
#if true
      // HACK: Project Wallenwein: set LK
      value |= 1;
      this.synchronizeCode = true;
#endif
      if (this.synchronizeCode)
      {
        XRect rect = new XRect(pt.x, pt.y, this.makerThickness, this.size.height);
        gfx.DrawRectangle(brush, rect);
        pt.x += 2 * this.makerDistance;
      }
      for (int idx = 0; idx < 32; idx++)
      {
        if ((value & 1) == 1)
        {
          XRect rect = new XRect(pt.x + idx * this.makerDistance, pt.y, this.makerThickness, this.size.height);
          gfx.DrawRectangle(brush, rect);
        }
        value = value >> 1;
      }
      gfx.Restore(state);
    }
Example #19
0
        public void Draw(XGraphics gfx)
        {
            gfx.DrawRectangle(Pen, Brush, Rect);

            const double yOffset = 5;

            if (!string.IsNullOrEmpty(Value))
            {
                var valLabel = new Label(new XRect(Rect.X, Rect.Y + yOffset, Rect.Width, Rect.Height), Value)
                    {
                        Alignment = XParagraphAlignment.Center,
                        Brush = XBrushes.Black,
                        Font = new XFont(Font.FontFamily.Name, 12, XFontStyle.Regular, Font.PdfOptions),
                        Pen = XPens.Black,
                    };
                valLabel.Draw(gfx);
            }
        }
Example #20
0
    /// <summary>
    /// Shows how to align text in the layout rectangle.
    /// </summary>
    void DrawTextAlignment(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "Text Alignment");
      XRect rect = new XRect(0, 0, 250, 140);

      XFont font = new XFont("Verdana", 10);
      XBrush brush = XBrushes.Purple;
      XStringFormat format = new XStringFormat();

      gfx.DrawRectangle(XPens.YellowGreen, rect);
      gfx.DrawLine(XPens.YellowGreen, rect.Width / 2, 0, rect.Width / 2, rect.Height);
      gfx.DrawLine(XPens.YellowGreen, 0, rect.Height / 2, rect.Width, rect.Height / 2);

      gfx.DrawString("TopLeft", font, brush, rect, format);

      format.Alignment = XStringAlignment.Center;
      gfx.DrawString("TopCenter", font, brush, rect, format);

      format.Alignment = XStringAlignment.Far;
      gfx.DrawString("TopRight", font, brush, rect, format);

      format.LineAlignment = XLineAlignment.Center;
      format.Alignment = XStringAlignment.Near;
      gfx.DrawString("CenterLeft", font, brush, rect, format);

      format.Alignment = XStringAlignment.Center;
      gfx.DrawString("Center", font, brush, rect, format);

      format.Alignment = XStringAlignment.Far;
      gfx.DrawString("CenterRight", font, brush, rect, format);

      format.LineAlignment = XLineAlignment.Far;
      format.Alignment = XStringAlignment.Near;
      gfx.DrawString("BottomLeft", font, brush, rect, format);

      format.Alignment = XStringAlignment.Center;
      gfx.DrawString("BottomCenter", font, brush, rect, format);

      format.Alignment = XStringAlignment.Far;
      gfx.DrawString("BottomRight", font, brush, rect, format);

      EndBox(gfx);
    }
Example #21
0
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      XSize page = gfx.PageSize;

      XTextFormatter tf = new XTextFormatter(gfx);
      XRect rect;
      string text = this.properties.Font1.Text;
      text = "English: The quick brown fox jumps over the lazy dog.\n\n" +
        "Brazilian Portuguese: A rápida raposa marrom ataca o cão preguiçoso.\n\n" +
        "Czech: Příliš žluťoučký kůň úpěl ďábelské ódy.\n\n" +
        "Portuguese: A rápida raposa castanha salta em cima do cão lento.\n\n" +
        "German: Franz jagt im total verwahrlosten Taxi quer durch Bayern.\n\n" +
        "Hungarian: Árvíztűrő tükörfúrógép ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP.\n\n" +
        "Swedish: Flygande beckasiner söka hwila på mjuka tufvor.\n\n" +
        "Danish: Quizdeltagerne spiste jordbær med flød.\n\n" +
        "Russian: Съешь еще этих мягких французских булок, да выпей чаю.\n\n" +
        "Romanian: Agera vulpe maronie sare peste câinele cel leneş.\n\n" +
        "Spanish: El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja.\n\n";

      rect = new XRect(50, 100, page.Width - 100, page.Height - 300);
      //gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush, 
        rect, XStringFormats.TopLeft);

      if (!this.properties.Font1.Unicode)
      {
        rect = new XRect(50, page.Height - 200, page.Width - 100, 110);
        gfx.DrawRectangle(XBrushes.LightPink, rect);
        tf.Alignment = XParagraphAlignment.Center;
        tf.DrawString("\nBefore creating a PDF file go to the Font tab in the XGraphics Properties window and check the Unicode option.\n\n" + 
          "Otherwise Cyrillic characters will not be visible in the PDF file.",
          this.properties.Font1.Font, this.properties.Font1.Brush, 
          rect, XStringFormats.TopLeft);
      }
    }
Example #22
0
    void Box(XGraphics gfx, XRect rect, double startAngle, double sweepAngle)
    {
      double xc = rect.X + rect.Width / 2;
      double yc = rect.Y + rect.Height / 2;
      double a = startAngle * Deg2Rad;
      double b = (startAngle + sweepAngle) * Deg2Rad;

      XGraphicsState state = gfx.Save();
      gfx.IntersectClip(rect);

      double f = Math.Max(rect.Width / 2, rect.Height / 2);
      for (double deg = 0; deg < 360; deg += 10)
        gfx.DrawLine(XPens.Goldenrod, xc, yc, 
          (xc + f * Math.Cos(deg * 0.0174532925199433)), 
          (yc + f * Math.Sin(deg * 0.0174532925199433)));

      gfx.DrawLine(XPens.PaleGreen, xc, rect.Y, xc, rect.Y + rect.Height);
      gfx.DrawLine(XPens.PaleGreen, rect.X, yc, rect.X + rect.Width, yc);
      //gfx.DrawLine(XPens.DarkGray, xc, yc, (double)(xc + rect.Width / 2 * Math.Cos(a)), (double)(yc + rect.Height / 2 * Math.Sin(a)));
      //gfx.DrawLine(XPens.DarkGray, xc, yc, (double)(xc + rect.Width / 2 * Math.Cos(b)), (double)(yc + rect.Height / 2 * Math.Sin(b)));

      gfx.Restore(state);
      gfx.DrawRectangle(properties.Pen1.Pen, rect);
    }
        void DrawFigures(XGraphics gfx, double W, double H)
        {

            /* COWARD'S TRIANGLE */

            XPen pen = new XPen(XColors.Black, 1);
            pen.LineJoin = XLineJoin.Round;
            XFont T10R = new XFont("Times New Roman", 10, XFontStyle.Regular);
            XTextFormatter tf = new XTextFormatter(gfx);
            tf.Alignment = XParagraphAlignment.Center;

            //Triangles
            XPoint[] polygon = new XPoint[] { new XPoint(84, 550), new XPoint(84, 685), new XPoint(284, 685) };
            gfx.DrawPolygon(pen, XBrushes.Green, polygon, XFillMode.Alternate);

            polygon = new XPoint[] { new XPoint(Hx, Hy), new XPoint(Nx, Ny), new XPoint(Fx, Fy), new XPoint(284, 685) };
            gfx.DrawPolygon(pen, XBrushes.Yellow, polygon, XFillMode.Alternate);

            polygon = new XPoint[] { new XPoint(84, 550), new XPoint(Nx, Ny), new XPoint(Lx, Ly) };
            gfx.DrawPolygon(pen, XBrushes.DarkOrange, polygon, XFillMode.Alternate);

            polygon = new XPoint[] { new XPoint(Hx, Hy), new XPoint(Nx, Ny), new XPoint(Lx, Ly) };
            gfx.DrawPolygon(pen, XBrushes.Red, polygon, XFillMode.Alternate);

            //Point
            gfx.DrawEllipse(pen, XBrushes.White, Cx, Cy, 6, 6);

            //Texts
            XRect rect = new XRect(72, 550, 10, 10);
            tf.DrawString("21", T10R, XBrushes.Red, rect);

            rect = new XRect(72, 687, 10, 10);
            tf.DrawString("0", T10R, XBrushes.Red, rect);

            rect = new XRect(150, 687, 50, 10);
            tf.DrawString("Methane %", T10R, XBrushes.Red, rect);

            rect = new XRect(270, 687, 15, 10);
            tf.DrawString("100", T10R, XBrushes.Red, rect);

            /* ELLICOTT DIAGRAM */

            rect = new XRect(297, 550, 112, 75);
            gfx.DrawRectangle(XPens.Black, XBrushes.DarkOrange, rect);

            rect = new XRect(409, 550, 112, 75);
            gfx.DrawRectangle(XPens.Black, XBrushes.Red, rect);

            rect = new XRect(297, 625, 112, 75);
            gfx.DrawRectangle(XPens.Black, XBrushes.Green, rect);

            rect = new XRect(409, 625, 112, 75);
            gfx.DrawRectangle(XPens.Black, XBrushes.Yellow, rect);

            //Arrows & Texts
            pen.LineCap = XLineCap.Round;
            gfx.DrawLine(pen, 409, 625, 381, 606);
            gfx.DrawLine(pen, 382, 610, 381, 606);
            gfx.DrawLine(pen, 385, 606, 381, 606);
            gfx.DrawString("Lean", T10R, XBrushes.Black, 372, 600);

            gfx.DrawLine(pen, 409, 625, 437, 644);
            gfx.DrawLine(pen, 436, 640, 437, 644);
            gfx.DrawLine(pen, 433, 644, 437, 644);
            gfx.DrawString("Rich", T10R, XBrushes.Black, 430, 655);

            gfx.DrawLine(pen, 409, 625, 381, 644);
            gfx.DrawLine(pen, 382, 640, 381, 644);
            gfx.DrawLine(pen, 385, 644, 381, 644);
            gfx.DrawString("Inert", T10R, XBrushes.Black, 372, 655);

            //Point
        }
        public static void Test(PdfSharp.Drawing.XGraphics gfx)
        {
            XRect  rect;
            XPen   pen;
            double x = 50, y = 100;
            XFont  fontH1     = new XFont("Times", 18, XFontStyle.Bold);
            XFont  font       = new XFont("Times", 12);
            XFont  fontItalic = new XFont("Times", 12, XFontStyle.BoldItalic);
            double ls         = font.GetHeight(gfx);

            // Draw some text
            gfx.DrawString("Create PDF on the fly with PDFsharp",
                           fontH1, XBrushes.Black, x, x);
            gfx.DrawString("With PDFsharp you can use the same code to draw graphic, " +
                           "text and images on different targets.", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("The object used for drawing is the XGraphics object.",
                           font, XBrushes.Black, x, y);
            y += 2 * ls;

            // Draw an arc
            pen           = new XPen(XColors.Red, 4);
            pen.DashStyle = XDashStyle.Dash;
            gfx.DrawArc(pen, x + 20, y, 100, 60, 150, 120);

            // Draw a star
            XGraphicsState gs = gfx.Save();

            gfx.TranslateTransform(x + 140, y + 30);
            for (int idx = 0; idx < 360; idx += 10)
            {
                gfx.RotateTransform(10);
                gfx.DrawLine(XPens.DarkGreen, 0, 0, 30, 0);
            }
            gfx.Restore(gs);

            // Draw a rounded rectangle
            rect = new XRect(x + 230, y, 100, 60);
            pen  = new XPen(XColors.DarkBlue, 2.5);
            XColor color1 = XColor.FromKnownColor(System.Drawing.KnownColor.DarkBlue);
            XColor color2 = XColors.Red;
            XLinearGradientBrush lbrush = new XLinearGradientBrush(rect, color1, color2,
                                                                   XLinearGradientMode.Vertical);

            gfx.DrawRoundedRectangle(pen, lbrush, rect, new XSize(10, 10));

            // Draw a pie
            pen           = new XPen(XColors.DarkOrange, 1.5);
            pen.DashStyle = XDashStyle.Dot;
            gfx.DrawPie(pen, XBrushes.Blue, x + 360, y, 100, 60, -130, 135);

            // Draw some more text
            y += 60 + 2 * ls;
            gfx.DrawString("With XGraphics you can draw on a PDF page as well as " +
                           "on any System.Drawing.Graphics object.", font, XBrushes.Black, x, y);
            y += ls * 1.1;
            gfx.DrawString("Use the same code to", font, XBrushes.Black, x, y);
            x += 10;
            y += ls * 1.1;
            gfx.DrawString("• draw on a newly created PDF page", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw above or beneath of the content of an existing PDF page",
                           font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw in a window", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw on a printer", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw in a bitmap image", font, XBrushes.Black, x, y);
            x -= 10;
            y += ls * 1.1;
            gfx.DrawString("You can also import an existing PDF page and use it like " +
                           "an image, e.g. draw it on another PDF page.", font, XBrushes.Black, x, y);
            y += ls * 1.1 * 2;
            gfx.DrawString("Imported PDF pages are neither drawn nor printed; create a " +
                           "PDF file to see or print them!", fontItalic, XBrushes.Firebrick, x, y);
            y += ls * 1.1;
            gfx.DrawString("Below this text is a PDF form that will be visible when " +
                           "viewed or printed with a PDF viewer.", fontItalic, XBrushes.Firebrick, x, y);
            y += ls * 1.1;
            XGraphicsState state   = gfx.Save();
            XRect          rcImage = new XRect(100, y, 100, 100 * System.Math.Sqrt(2));

            gfx.DrawRectangle(XBrushes.Snow, rcImage);
            gfx.DrawImage(XPdfForm.FromFile("../../../../../PDFs/SomeLayout.pdf"), rcImage);
            gfx.Restore(state);
        }
Example #25
0
        public override void PaintPdf(PdfSharp.Drawing.XGraphics g2D, int pageNo, PointF pageStart, Ctx ctx, bool isView)
        {
            if (m_item == null)
            {
                return;
            }
            //
            //System.Drawing.SolidBrush g2Dpen = new System.Drawing.SolidBrush(m_color);
            XSolidBrush g2Dpen = new XSolidBrush(XColor.FromArgb(m_color));
            XPen        pen    = new XPen(XColor.FromArgb(m_color));

            pen.DashStyle = PdfSharp.Drawing.XDashStyle.Solid;
            //
            PointF location = GetAbsoluteLocation(pageStart);
            int    x        = (int)location.X;
            int    y        = (int)location.Y;

            int width  = m_item.GetMaxWidth();
            int height = m_item.GetMaxHeight();

            if (m_item.GetPrintFormatType().Equals(MPrintFormatItem.PRINTFORMATTYPE_Line))
            {
                g2D.DrawLine(pen, (double)x, (double)y, (double)x + width, (double)y + height);
            }
            else
            {
                String type = m_item.GetShapeType();
                if (type == null)
                {
                    type = "";
                }
                if (m_item.IsFilledRectangle())
                {
                    if (type.Equals(MPrintFormatItem.SHAPETYPE_3DRectangle))
                    {
                        g2D.DrawRectangle(g2Dpen, (double)x, (double)y, (double)width, (double)height);
                    }
                    else if (type.Equals(MPrintFormatItem.SHAPETYPE_Oval))
                    {
                        g2D.DrawRectangle(g2Dpen, (double)x, (double)y, (double)width, (double)height);
                    }
                    else if (type.Equals(MPrintFormatItem.SHAPETYPE_RoundRectangle))
                    {
                        g2D.DrawRectangle(g2Dpen, (double)x, (double)y, (double)width, (double)height); //, m_item.getArcDiameter(), m_item.getArcDiameter());
                    }
                    else
                    {
                        g2D.DrawRectangle(g2Dpen, (double)x, (double)y, (double)width, (double)height);
                    }
                }
                else
                {
                    if (type.Equals(MPrintFormatItem.SHAPETYPE_3DRectangle))
                    {
                        g2D.DrawRectangle(pen, (double)x, (double)y, (double)width, (double)height);
                    }
                    else if (type.Equals(MPrintFormatItem.SHAPETYPE_Oval))
                    {
                        g2D.DrawEllipse(pen, (double)x, (double)y, (double)width, (double)height);
                    }
                    else if (type.Equals(MPrintFormatItem.SHAPETYPE_RoundRectangle))
                    {
                        g2D.DrawRectangle(pen, (double)x, (double)y, (double)width, (double)height); //, m_item.getArcDiameter(), m_item.getArcDiameter());
                    }
                    else
                    {
                        g2D.DrawRectangle(pen, (double)x, (double)y, (double)width, (double)height);
                    }

                    //PrintElement
                }
            }
        }
Example #26
0
 //        public static void DrawRectangle (IExportColumn column, XGraphics graphics) {
 //            FillRectangle(column.DisplayRectangle,column.FrameColor,graphics);
 //        }
 public static void FillRectangle(XRect rect,Color color,XGraphics graphics)
 {
     graphics.DrawRectangle(new XSolidBrush(ToXColor(color)),rect);
 }
Example #27
0
 public static void DrawBorder(XRect rect,IExportColumn column,XGraphics graphics)
 {
     var pen = 	new XPen(ToXColor(column.ForeColor),1);
     rect.Inflate(new XSize(2,2));
     graphics.DrawRectangle(pen,rect);
 }
Example #28
0
 static void DrawRectangle(XGraphics gfx, int x, int y, int width, int height)
 {
     XPen pen = new XPen(XColors.Black, Math.PI);
     
     gfx.DrawRectangle(pen, x, y, width, height);
 }
Example #29
0
 public void GenerateDivider(PdfPage page, XGraphics gfx, double currentWidth, double currentLine)
 {
     XRect rect = new XRect(20, currentLine, page.Width - currentWidth * 2, 1);
     gfx.DrawRectangle(PropspectBrush, rect);
 }
Example #30
0
 public void GenerateHeadingBlock(string title, PdfPage page, XGraphics gfx, double currentWidth, double currentLine)
 {
     XRect headerRect = new XRect(currentWidth, currentLine, page.Width - currentWidth * 2, 17);
     gfx.DrawRectangle(PropspectBrush, currentWidth, currentLine, page.Width - currentWidth * 2, 18);
     gfx.DrawString(title, Font16Bold, XBrushes.White, headerRect, XStringFormats.Center);
 }
        public override void Render(ref PdfSharp.Drawing.XGraphics gfx, double offsetLeft, double offsetTop, double scaleX, double scaleY)
        {
            PreRender(ref gfx, offsetLeft, offsetTop, scaleX, scaleY);
            double borderWidth = Util.MillimeterToPoint(BorderWidth);
            double radiusx     = Math.Min(Util.MillimeterToPoint(Width), Util.MillimeterToPoint(BorderRadius)) * 2.0;
            double radiusy     = Math.Min(Util.MillimeterToPoint(Height), Util.MillimeterToPoint(BorderRadius)) * 2.0;

            XPen pen = new XPen(BorderColor, borderWidth);

            if (BorderRadius == 0.0)
            {
                gfx.DrawRectangle(FillColor,
                                  Util.MillimeterToPoint(offsetLeft + Left),
                                  Util.MillimeterToPoint(offsetTop + Top),
                                  Util.MillimeterToPoint(Width * scaleX),
                                  Util.MillimeterToPoint(Height * scaleY));

                gfx.DrawRectangle(pen,
                                  Util.MillimeterToPoint(offsetLeft + Left + (BorderWidth / 2.0)),
                                  Util.MillimeterToPoint(offsetTop + Top + (BorderWidth / 2.0)),
                                  Util.MillimeterToPoint((Width - BorderWidth) * scaleX),
                                  Util.MillimeterToPoint((Height - BorderWidth) * scaleY));
            }
            else
            {
                double width  = (Width - BorderWidth) * scaleX;
                double height = (Height - BorderWidth) * scaleY;



                gfx.DrawRoundedRectangle(FillColor,
                                         Util.MillimeterToPoint(offsetLeft + Left),
                                         Util.MillimeterToPoint(offsetTop + Top),
                                         Util.MillimeterToPoint((Width) * scaleX),
                                         Util.MillimeterToPoint((Height) * scaleY),
                                         Math.Min(Util.MillimeterToPoint(Width), radiusx + Util.MillimeterToPoint(BorderWidth)) - 0.1,
                                         Math.Min(Util.MillimeterToPoint(Height), radiusy + Util.MillimeterToPoint(BorderWidth)) - 0.1);

                gfx.DrawRoundedRectangle(pen,
                                         Util.MillimeterToPoint(offsetLeft + Left + (BorderWidth / 2.0)),
                                         Util.MillimeterToPoint(offsetTop + Top + (BorderWidth / 2.0)),
                                         Util.MillimeterToPoint(width),
                                         Util.MillimeterToPoint(height),
                                         Math.Min(Util.MillimeterToPoint(width), radiusx) - 0.1,
                                         Math.Min(Util.MillimeterToPoint(height), radiusy) - 0.1);
            }



            /**/

            /*if (radiusx == 0.0 && radiusy == 0.0)
             * {
             * if (Fill)
             * {
             *  gfx.DrawRectangle(FillColor,
             *    Util.MillimeterToPoint(offsetLeft + Left),
             *    Util.MillimeterToPoint(offsetTop + Top),
             *    Util.MillimeterToPoint(Width * scaleX),
             *    Util.MillimeterToPoint(Height * scaleY));
             * }
             * if (BorderWidth > 0.0 && DrawBorder) {
             *  gfx.DrawRectangle(pen,
             *  Util.MillimeterToPoint(offsetLeft + Left + (borderWidth / 2f)),
             *  Util.MillimeterToPoint(offsetTop + Top + (borderWidth / 2f)),
             *  Util.MillimeterToPoint((Width - (borderWidth / 2f)) * scaleX),
             *  Util.MillimeterToPoint((Height - (borderWidth / 2f)) * scaleY));
             * }
             * }
             * else
             * {
             * if (Fill)
             * {
             *  gfx.DrawRoundedRectangle(FillColor,
             *    Util.MillimeterToPoint(offsetLeft + Left + borderWidth),
             *    Util.MillimeterToPoint(offsetTop + Top + borderWidth),
             *    Util.MillimeterToPoint((Width - (borderWidth * 2.0)) * scaleX),
             *    Util.MillimeterToPoint((Height - (borderWidth * 2.0)) * scaleY),
             *    radiusx,
             *    radiusy);
             * }
             * if (BorderWidth > 0.0)
             * {
             *  gfx.DrawRoundedRectangle(pen,
             *  Util.MillimeterToPoint(offsetLeft + Left+(BorderRadius/2f)),
             *  Util.MillimeterToPoint(offsetTop + Top + (BorderRadius / 2f)),
             *  Util.MillimeterToPoint((Width - (BorderRadius / 2f)) * scaleX),
             *  Util.MillimeterToPoint((Height - (BorderRadius / 2f)) * scaleY),
             *  radiusx,
             *  radiusy);
             * }
             * }*/

            base.Render(ref gfx, offsetLeft, offsetTop, scaleX, scaleY);
        }
Example #32
0
 private static void DrawFill(XGraphics formGfx, string Color, int Width, int Height, int Left, int Top)
 {
     XColor back = default(XColor);
     back = XColor.FromName(Color);
     back.A = 0.2;
     XSolidBrush brush = new XSolidBrush(back);
     formGfx.DrawRectangle(brush, Left, Top, Width, Height);
 }
Example #33
0
 public void GenerateTableRow(string[] headerArray, PdfPage page, XGraphics gfx, double currentWidth, double currentLine)
 {
     double tableCol = currentWidth;
     foreach (string item in headerArray)
     {
         if (!string.IsNullOrEmpty(item))
         {
             double colSize = (page.Width - currentWidth * 2) / headerArray.Length;
             XRect rect = new XRect(tableCol, currentLine, colSize, 10);
             gfx.DrawString(item, Font10, XBrushes.Black, rect, XStringFormats.TopLeft);
             tableCol += colSize;
         }               
     }
     XRect divRect = new XRect(20, currentLine + 14, page.Width - currentWidth * 2, 0.4);
     gfx.DrawRectangle(XBrushes.LightGray, divRect);
 }
Example #34
0
        private void DrawGrid(XGraphics gfx)
        {
            var foregroundPen = new XPen(_foregroundColor, 0.5);
            var backgroundPen = new XPen(_backgroundColor);

            gfx.DrawRectangle(backgroundPen, new XSolidBrush(_backgroundColor), 0, 0, PageWidth, PageHeight);

            for (int i = 0; i < (Columns + 2); i++)
            {
                var x = (XMargin + (i * CardSize));

                gfx.DrawLine(foregroundPen, x, 0, x, PageHeight);
            }
            for (int i = 0; i < (Rows + 2); i++)
            {
                var y = (YMargin + (i * CardSize));
                gfx.DrawLine(foregroundPen, 0, y, PageWidth, y);
            }
        }
Example #35
-1
    /// <summary>
    /// Demonstrates serveral bar code types.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      XRect rc;
      base.RenderPage(gfx);

      Graphics grfx = gfx.Internals.Graphics;

      Code2of5Interleaved bc25 = new Code2of5Interleaved();
      bc25.Text = "123456";
      bc25.Size = new XSize(90, 30);
      //bc25.Direction = BarCodeDirection.RightToLeft;
      bc25.TextLocation = TextLocation.Above;
      gfx.DrawBarCode(bc25, XBrushes.DarkBlue, new XPoint(100, 100));

      CodeDataMatrix dm = new CodeDataMatrix("test", 26);
      dm.Size = new XSize(XUnit.FromMillimeter(15), XUnit.FromMillimeter(15));
      gfx.DrawMatrixCode(dm, XBrushes.DarkBlue, new XPoint(300, 100));

      rc = new XRect(30, 200, XUnit.FromCentimeter(9.3) + XUnit.FromMillimeter(0.5), XUnit.FromMillimeter(6));
      gfx.DrawRectangle(new XSolidBrush(XColor.FromArgb(128, XColors.LightSeaGreen)), rc);

      CodeOmr omr = new CodeOmr(0xF8F5FF3F.ToString(), rc.Size, CodeDirection.LeftToRight);
      omr.MakerDistance = XUnit.FromMillimeter(3);
      omr.MakerThickness = XUnit.FromMillimeter(0.5);
      gfx.DrawBarCode(omr, XBrushes.Black, rc.Center);

      omr.Direction = CodeDirection.RightToLeft;
      gfx.DrawBarCode(omr, XBrushes.Black, rc.Center + new XSize(0, 50));

      omr.Direction = CodeDirection.RightToLeft;
      gfx.DrawBarCode(omr, XBrushes.Black, rc.Center + new XSize(0, 50));

      omr.Direction = CodeDirection.TopToBottom;
      gfx.DrawBarCode(omr, XBrushes.Black, rc.Center + new XSize(300, 25));
    }