DrawLine() public method

Draws a line connecting two PointF structures.
public DrawLine ( XPen pen, PointF pt1, PointF pt2 ) : void
pen XPen
pt1 PointF
pt2 PointF
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 XGraphics.DrawBeziers.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      int n = 2;
      int count = 1 + 3 * n;
      XPoint[] points = new XPoint[count];
      Random rnd = new Random(42);
      for (int idx = 0; idx < count; idx++)
      {
        points[idx].X = 20 + rnd.Next(600);
        points[idx].Y = 50 + rnd.Next(800);
      }

      // Draw the points
      XPen pen = new XPen(XColors.Red, 0.5);
      pen.DashStyle = XDashStyle.Dash;
      for (int idx = 0; idx + 3 < count; idx += 3)
      {
        gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx]));
        gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 1]));
        gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 2]));
        gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 3]));
        gfx.DrawLine(pen, points[idx], points[idx + 1]);
        gfx.DrawLine(pen, points[idx + 2], points[idx + 3]);
      }

      // Draw the curve
      gfx.DrawBeziers(properties.Pen2.Pen, points);
    }
Example #3
1
    /// <summary>
    /// Draws simple lines.
    /// </summary>
    void RenderLines(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      gfx.DrawLine(XPens.Red, new XPoint(10, 10), new XPoint(300, 300));

      gfx.DrawLine(XPens.DarkGreen, 0, 0, 250, 0);

      gfx.DrawLine(XPens.Gold, 15, 7, 230, 15);

      XPen pen = new XPen(XColors.Navy, 4);
      gfx.DrawLine(pen, 0, 20, 250, 20);

      pen = new XPen(XColors.Firebrick, 6);
      pen.DashStyle = XDashStyle.Dash;
      gfx.DrawLine(pen, 0, 40, 250, 40);
      pen.Width = 7.3;
      pen.DashStyle = XDashStyle.DashDotDot;
      gfx.DrawLine(pen, 0, 60, 250, 60);

      pen = new XPen(XColors.Goldenrod, 10);
      pen.LineCap = XLineCap.Flat;
      gfx.DrawLine(pen, 10, 90, 240, 90);
      gfx.DrawLine(XPens.Black, 10, 90, 240, 90);

      pen = new XPen(XColors.Goldenrod, 10);
      pen.LineCap = XLineCap.Square;
      gfx.DrawLine(pen, 10, 110, 240, 110);
      gfx.DrawLine(XPens.Black, 10, 110, 240, 110);

      pen = new XPen(XColors.Goldenrod, 10);
      pen.LineCap = XLineCap.Round;
      gfx.DrawLine(pen, 10, 130, 240, 130);
      gfx.DrawLine(XPens.Black, 10, 130, 240, 130);
    }
 private void DrawDebuggingCrosshair(XGraphics context)
 {
     var pen = new XPen(XColors.Red);
     var w = form.Size.Width;
     var h = form.Size.Height;
     context.DrawLine(pen, 0, 0, w, h);
     context.DrawLine(pen, w, 0, 0, h);
 }
    /// <summary>
    /// Draws simple lines.
    /// </summary>
    void DrawLine(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawLine");

      gfx.DrawLine(XPens.DarkGreen, 0, 0, 250, 0);

      gfx.DrawLine(XPens.Gold, 15, 7, 230, 15);

      XPen pen = new XPen(XColors.Navy, 4);
      gfx.DrawLine(pen, 0, 20, 250, 20);

      pen = new XPen(XColors.Firebrick, 6);
      pen.DashStyle = XDashStyle.Dash;
      gfx.DrawLine(pen, 0, 40, 250, 40);
      pen.Width = 7.3;
      pen.DashStyle = XDashStyle.DashDotDot;
      gfx.DrawLine(pen, 0, 60, 250, 60);

      pen = new XPen(XColors.Goldenrod, 10);
      pen.LineCap = XLineCap.Flat;
      gfx.DrawLine(pen, 10, 90, 240, 90);
      gfx.DrawLine(XPens.Black, 10, 90, 240, 90);

      pen = new XPen(XColors.Goldenrod, 10);
      pen.LineCap = XLineCap.Square;
      gfx.DrawLine(pen, 10, 110, 240, 110);
      gfx.DrawLine(XPens.Black, 10, 110, 240, 110);

      pen = new XPen(XColors.Goldenrod, 10);
      pen.LineCap = XLineCap.Round;
      gfx.DrawLine(pen, 10, 130, 240, 130);
      gfx.DrawLine(XPens.Black, 10, 130, 240, 130);

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

#if true__
      XPen pen = new XPen(XColors.DarkGreen, 20);
      gfx.DrawLine(pen, 0, 0, 1000, 1000);
#endif

      XGraphicsPath path = new XGraphicsPath();

      path.AddString("@", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 500, new XPoint(90, 60), XStringFormats.Default);
      gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path);
    }
Example #7
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 #8
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 * 0.0174532925199433;
      double b = (startAngle + sweepAngle) * 0.0174532925199433;

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


#if true
#if true_
      for (double deg = 0; deg < 360; deg += 10)
        gfx.DrawLine(XPens.Yellow, xc, yc, 
          (xc + rect.Width / 2 * Math.Cos(deg * 0.0174532925199433)), 
          (yc + rect.Height / 2 * Math.Sin(deg * 0.0174532925199433)));
#endif
      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, (xc + rect.Width / 2 * Math.Cos(a)), (yc + rect.Height / 2 * Math.Sin(a)));
      //gfx.DrawLine(XPens.DarkGray, xc, yc, (xc + rect.Width / 2 * Math.Cos(b)), (yc + rect.Height / 2 * Math.Sin(b)));
#endif
      gfx.Restore(state);
      gfx.DrawRectangle(properties.Pen1.Pen, rect);
    }
    /// <summary>
    /// Demonstrates the use of XGraphics.Transform.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      //gfx.Clear(this.properties.General.BackColor.Color);
      base.RenderPage(gfx);

      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)));
    }
 public void Draw(XGraphics gfx)
 {
   string s = "Testtext";
   //gfx.DrawLine(XPens.GreenYellow, 5, 100, 30, 50);
   //gfx.DrawEllipse(XBrushes.DarkBlue, new XRect(30, 40, 250, 235));
   XFont font = new XFont("Arial", 40, XFontStyle.Italic);
   gfx.DrawString(s, font, XBrushes.Firebrick, 40, 60);
   XSize size = gfx.MeasureString(s, font);
   gfx.DrawLine(XPens.DarkBlue, 40, 60, 40 + size.Width, 60);
   gfx.DrawLine(XPens.DarkBlue, 40, 60, 40, 60 + size.Height);
 }
Example #11
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)));

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

      string facename = "Times";
      XFont fontR = new XFont(facename, 40);
      XFont fontB = new XFont(facename, 40, XFontStyle.Bold);
      XFont fontI = new XFont(facename, 40, XFontStyle.Italic);
      XFont fontBI = new XFont(facename, 40, XFontStyle.Bold | XFontStyle.Italic);
      //gfx.DrawString("Hello", this.properties.Font1.Font, this.properties.Font1.Brush, 200, 200);
      double x = 80;
      XPen pen = XPens.SlateBlue;
      gfx.DrawLine(pen, x, 100, x, 600);
      gfx.DrawLine(pen, x - 50, 200, 400, 200);
      gfx.DrawLine(pen, x - 50, 300, 400, 300);
      gfx.DrawLine(pen, x - 50, 400, 400, 400);
      gfx.DrawLine(pen, x - 50, 500, 400, 500);

      double lineSpace = fontR.GetHeight(gfx);
      int cellSpace = fontR.FontFamily.GetLineSpacing(fontR.Style);
      int cellAscent = fontR.FontFamily.GetCellAscent(fontR.Style);
      int cellDescent = fontR.FontFamily.GetCellDescent(fontR.Style);
      double cyAscent = lineSpace * cellAscent / cellSpace;

      XFontMetrics metrics = fontR.Metrics;

      XSize size;
      gfx.DrawString("Times 40", fontR, this.properties.Font1.Brush, x, 200);
      size = gfx.MeasureString("Times 40", fontR);
      //gfx.DrawLine(this.properties.Pen3.Pen, x, 200, x + size.Width, 200);

      gfx.DrawString("Times bold 40", fontB, this.properties.Font1.Brush, x, 300);
      size = gfx.MeasureString("Times bold 40", fontB);
      //gfx.DrawLine(this.properties.Pen3.Pen, x, 300, x + size.Width, 300);

      gfx.DrawString("Times italic 40", fontI, this.properties.Font1.Brush, x, 400);
      size = gfx.MeasureString("Times italic 40", fontI);
      //gfx.DrawLine(this.properties.Pen3.Pen, x, 400, x + size.Width, 400);

      gfx.DrawString("Times bold italic 40", fontBI, this.properties.Font1.Brush, x, 500);
      size = gfx.MeasureString("Times bold italic 40", fontBI);
      //gfx.DrawLine(this.properties.Pen3.Pen, x, 500, x + size.Width, 500);

#if true
      // Check Malayalam
      XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
      XFont Kartika = new XFont("Kartika", 20, XFontStyle.Regular, options);
      XFont AnjaliOldLipi = new XFont("AnjaliOldLipi", 20, XFontStyle.Regular, options);
      gfx.DrawString("മകനെ ഇത് ഇന്ത്യയുടെ ഭൂപടം", Kartika, this.properties.Font1.Brush, x, 600);
      gfx.DrawString("മകനെ ഇത് ഇന്ത്യയുടെ ഭൂപടം", AnjaliOldLipi, this.properties.Font1.Brush, x, 650);
#endif
    }
Example #13
0
    public void Arc(XGraphics gfx, RectangleF rect, float startAngle, float sweepAngle)
    {
      RectangleF rect2 = RectangleF.Inflate(rect, rect.Width, 0);
      Box2(gfx, rect2, startAngle, sweepAngle);
      Box1(gfx, rect, startAngle, sweepAngle);
      //Box(gfx, rect, startAngle, sweepAngle);
      gfx.DrawArc(properties.Pen2.Pen, rect, startAngle, sweepAngle);
      gfx.DrawArc(properties.Pen3.Pen, rect2, 0, 90);
      gfx.DrawArc(properties.Pen2.Pen, rect2, startAngle, sweepAngle);

      float delta = (float)(Math.PI / 360);
      float rx = rect2.Width / 2;
      float ry = rect2.Height / 2;
      float dx = rect2.X + rx;
      float dy = rect2.Y + ry;
      for (float rad = 0; rad < Math.PI * 2; rad += delta)
      {
        gfx.DrawLine(XPens.LawnGreen, (float)(dx + rx * Math.Cos(rad)), (float)(dy + ry * Math.Sin(rad)), 
          (float)(dx + rx * Math.Cos(rad + delta)), (float)(dy + ry * Math.Sin(rad + delta)));
      }

      double gamma1 = (ry * Math.Cos(20 * 0.0174532925199433)) / (rx * Math.Sin(20 * 0.0174532925199433));
      gamma1 = Math.Atan(gamma1);
      gamma1 = 90 - gamma1 / 0.0174532925199433;
      double gamma2 = (ry * Math.Cos(70 * 0.0174532925199433)) / (rx * Math.Sin(70 * 0.0174532925199433));
      gamma2 = Math.Atan(gamma2);
      gamma2 = 90 - gamma2 / 0.0174532925199433 - gamma1;
      gfx.DrawArc(XPens.Black, rect2, (float)gamma1, (float)gamma2);
    }
Example #14
0
    public override void RenderPage(XGraphics gfx)
    {
      //base.RenderPage(gfx);

      XFont font1 = new XFont("Arial", 9);
      XFont font2 = new XFont("Arial", 9, XFontStyle.Italic);
      XFont font3 = new XFont("Arial", 9, XFontStyle.Bold);
      XSolidBrush brush = new XSolidBrush(XColors.Black);

      gfx.DrawString("Page 5", font1, brush, 100, 100);
      gfx.DrawString("Water Sports You've Done continued", font2, brush, 100, 200);
      gfx.DrawString("Rowing", font1, brush, 100, 250);
      gfx.DrawString("Snorkeling", font1, brush, 100, 300);
      gfx.DrawString("WINTER SPORTS, SKIING, SKIING IN THE US", font3, XBrushes.Red, 100, 320);

      gfx.DrawLine(XPens.Red, 100, 100, 200, 200);

      gfx.DrawString("Resorts You've Skied in Vermont", font3, brush, 100, 400);
      gfx.DrawString("Haystack", font1, brush, 100, 420);

//      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;
//      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);
//      gfx.DrawLine(XPens.Red, 0, 0, 100, 100);
//      gfx.DrawString(text, font, this.properties.Font1.Brush, x, y + 20);
    }
Example #15
0
        private static void DrawEdge(XGraphics g, Edge e, LayoutProvider layout, NetworkColorizer colorizer)
        {
            Vector3 p1 = layout.GetPositionOfNode(e.Source);
            Vector3 p2 = layout.GetPositionOfNode(e.Target);

            g.DrawLine(new Pen(colorizer[e], 0.05f), p1.X, p1.Y, p2.X, p2.Y);
        }
Example #16
0
 public override float Draw(XGraphics gfx, PointF pt, bool dorender)
 {
     if (Options.PrintSeparatorLines)
     {
         float y = pt.Y + Options.SongSpaceHeight / 2;
         if (dorender) gfx.DrawLine(XPens.Black, pt.X, y, pt.X + Options.PageWidth, y);
     }
     return Options.SongSpaceHeight;
 }
Example #17
0
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      string text = "TgfÄÖÜWi9";
      if (!String.IsNullOrEmpty(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;
      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);
      gfx.DrawLine(XPens.Red, 0, 0, 100, 100);
      gfx.DrawString(text, font, this.properties.Font1.Brush, x, y + 20);
    }
Example #18
0
        public void DrawBarCharts(XGraphics gfx)
        {
            XPoint backgroundPoint = new XPoint(20, page_.Height * 0.55);
            XRect backgroundRect = new XRect(backgroundPoint.X, backgroundPoint.Y, page_.Width - 40, page_.Height * 0.425);
            double quarterRectWidth = backgroundRect.Width * 0.25;
            double offset = quarterRectWidth * 0.25;
            DrawingUtil.DrawOutlineRect(backgroundRect, gfx, new XSize(40,40));
            gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromKnownColor(XKnownColor.Gray)),
                backgroundRect,
                new XSize(40, 40));

            DoubleBar ShoulderFlexionBar = new DoubleBar(userParameters_[dataReadStart + 4], userParameters_[dataReadStart + 9], gfx);
            ShoulderFlexionBar.Draw(new XPoint(quarterRectWidth - offset, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            DoubleBar hipFlexionBar = new DoubleBar(userParameters_[dataReadStart + 5], userParameters_[dataReadStart + 10], gfx);
            hipFlexionBar.Draw(new XPoint(quarterRectWidth * 2 - offset, backgroundPoint.Y + 20),
                backgroundRect,
                 XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            DoubleBar kneeFlexionBar = new DoubleBar(userParameters_[dataReadStart + 6], userParameters_[dataReadStart + 11], gfx);
            kneeFlexionBar.Draw(new XPoint(quarterRectWidth * 3 - offset, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            DoubleBar ankleFlexionBar = new DoubleBar(userParameters_[dataReadStart + 7], userParameters_[dataReadStart + 12], gfx);
            ankleFlexionBar.Draw(new XPoint(quarterRectWidth * 4 - offset, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            gfx.DrawString("Degrees :",
                new XFont("Arial", 10),
                XBrushes.Black,
                (backgroundPoint + new XPoint(0, 20)) + new XPoint(backgroundRect.Width * 0.05, backgroundRect.Height * 0.05),
                XStringFormats.Center);

            gfx.DrawString("LSI % :",
                new XFont("Arial", 10),
                XBrushes.Black,
                (backgroundPoint + new XPoint(0, 20)) + new XPoint(backgroundRect.Width * 0.05, backgroundRect.Height * 0.125),
                XStringFormats.Center);

            XPoint top = new XPoint(backgroundPoint.X, backgroundPoint.Y + backgroundRect.Height * 0.2);
            XPoint bottom = new XPoint(backgroundPoint.X, backgroundPoint.Y + backgroundRect.Height * 0.8);
            for (int i = 11; i > 0; i--)
            {
                float increment = -i * 0.1f;

                XPoint percentagePoint = DrawingUtil.Instance.Interpolate(top, bottom, increment);
                percentagePoint = new XPoint(percentagePoint.X, Math.Floor(percentagePoint.Y));
                gfx.DrawString(((11 - i) * 10).ToString() + "%", new XFont("Arial", 8), XBrushes.Black, percentagePoint + new XPoint(5, -2));
                gfx.DrawLine(XPens.LightGray, percentagePoint, percentagePoint + new XPoint(backgroundRect.Width, 0));
            }
        }
    /// <summary>
    /// Demonstrates the use of XGraphics.DrawBezier.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      gfx.DrawEllipse(XBrushes.Red, MakeRect(50, 100));
      gfx.DrawEllipse(XBrushes.Red, MakeRect(450, 100));
      gfx.DrawEllipse(XBrushes.Red, MakeRect(550, 190));
      gfx.DrawEllipse(XBrushes.Red, MakeRect(150, 300));

      gfx.DrawLine(XPens.Red, 50, 100, 450, 100);
      gfx.DrawLine(XPens.Red, 550, 190, 150, 300);

      gfx.DrawBezier(properties.Pen2.Pen, 50, 100, 450, 100, 550, 190, 150, 300);

      //XPoint[] points = new XPoint[1 + 3 * 3];
      //Random rnd = new Random();
      //for (int idx = 0; idx < points.Length; idx++)
      //{
      //  points[idx].X = 100 + rnd.Next(400);
      //  points[idx].Y = 200 + rnd.Next(700);
      //}
      //gfx.DrawBeziers(properties.Pen1.Pen, points);
    }
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      gfx.DrawLine(properties.Pen1.Pen, 50, 100, 550, 100);
      gfx.DrawLine(properties.Pen2.Pen, 50, 200, 550, 200);
      gfx.DrawLine(properties.Pen3.Pen, 50, 300, 550, 300);

      XPen pen = properties.Pen2.Pen.Clone();

      pen.DashStyle = XDashStyle.Dash;
      gfx.DrawLine(pen, 50, 500, 550, 500);

      pen.DashStyle = XDashStyle.Dot;
      gfx.DrawLine(pen, 50, 550, 550, 550);

      pen.DashStyle = XDashStyle.DashDot;
      gfx.DrawLine(pen, 50, 600, 550, 600);

      pen.DashStyle = XDashStyle.DashDotDot;
      gfx.DrawLine(pen, 50, 650, 550, 650);

      // Custom pattern
      //pen.DashStyle = XDashStyle.Custom;
      pen.DashPattern = new double[] { 3, 1, 2.5, 1.5 };
      pen.Width = 7;

      pen.DashOffset = 1;
      gfx.DrawLine(pen, 50, 700, 550, 700);

      pen.DashOffset = 2;
      gfx.DrawLine(pen, 50, 720, 550, 720);

      pen.DashOffset = 4;
      gfx.DrawLine(pen, 50, 740, 550, 740);

    }
Example #21
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));
    }
        private static void DrawCorners(XRect rect, XGraphics gfx)
        {
            var pen = new XPen(XColors.Black, 0.5);
            pen.DashStyle = XDashStyle.Dash;

            //top left
            gfx.DrawLine(pen, rect.Left, rect.Top, rect.Left, rect.Top + 20);
            gfx.DrawLine(pen, rect.Left, rect.Top, rect.Left + 20, rect.Top);

            //top right
            gfx.DrawLine(pen, rect.Right - 20, rect.Top, rect.Right, rect.Top);
            gfx.DrawLine(pen, rect.Right, rect.Top, rect.Right, rect.Top + 20);

            //bottom left
            gfx.DrawLine(pen, rect.Left, rect.Bottom, rect.Left + 20, rect.Bottom);
            gfx.DrawLine(pen, rect.Left, rect.Bottom, rect.Left, rect.Bottom - 20);

            //bottom right
            gfx.DrawLine(pen, rect.Right, rect.Bottom, rect.Right, rect.Bottom - 20);
            gfx.DrawLine(pen, rect.Right, rect.Bottom, rect.Right - 20, rect.Bottom);
        }
Example #23
0
        public void DrawBarCharts(XGraphics gfx)
        {
            XPoint backgroundPoint = new XPoint(20, page.Height * 0.585);
            XRect backgroundRect = new XRect(backgroundPoint.X, backgroundPoint.Y, page.Width - 40, page.Height * 0.41);
            gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromKnownColor(XKnownColor.Gray)),
                backgroundRect,
                new XSize(40, 40));

            DoubleBar ShoulderFlexionBar = new DoubleBar(userParameters["LEFT Shoulder Flexion"], userParameters["RIGHT Shoulder Flexion"], gfx);
            ShoulderFlexionBar.Draw(new XPoint(quaterWidth * 0.5  - 10,backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Shoulder Flexion.png"));

            DoubleBar hipFlexionBar = new DoubleBar(userParameters["LEFT Hip Flexion"], userParameters["RIGHT Hip Flexion"], gfx);
            hipFlexionBar.Draw(new XPoint(quaterWidth * 2 - (quaterWidth * 0.5) - 10, backgroundPoint.Y + 20),
                backgroundRect,
                 XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Hip Flexion.png"));

            DoubleBar kneeFlexionBar = new DoubleBar(userParameters["LEFT Knee Flexion"], userParameters["RIGHT Knee Flexion"], gfx);
            kneeFlexionBar.Draw(new XPoint(quaterWidth * 3 - (quaterWidth * 0.5) - 10, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Knee Flexion.png"));

            DoubleBar ankleFlexionBar = new DoubleBar(userParameters["LEFT Ankle Flexion"], userParameters["RIGHT Ankle Flexion"], gfx);
            ankleFlexionBar.Draw(new XPoint(quaterWidth * 4 - (quaterWidth * 0.5) - 10, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Ankle Flexion.png"));

            XPoint top = new XPoint(backgroundPoint.X, backgroundPoint.Y + backgroundRect.Height * 0.2);
            XPoint bottom = new XPoint(backgroundPoint.X, backgroundPoint.Y + backgroundRect.Height * 0.8);
            for (int i = 11; i > 0; i--)
            {
                float increment = -i * 0.1f;

                XPoint percentagePoint = Interpolate(top, bottom, increment);
                gfx.DrawString(((11 - i) * 10).ToString() + "%", new XFont("Arial", 8), XBrushes.Black, percentagePoint + new XPoint(5, 0));
                gfx.DrawLine(XPens.Black, percentagePoint, percentagePoint + new XPoint(backgroundRect.Width, 0));

            }
        }
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      // Create a new graphical path
      XGraphicsPath path = new XGraphicsPath();

      // Add the outline of the glyphs of the word 'Clip' to the path
      path.AddString("Clip!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 250, new XPoint(30, 100), XStringFormats.Default);

#if DEBUG_
      gfx.WriteComment("SetClip");
#endif
      // Set the path as clip path
      gfx.IntersectClip(path);
#if DEBUG_
      gfx.WriteComment("Random lines");
#endif
      // Draw some random lines to show that clipping happens
      Random rnd = new Random(42);
      for (int idx = 0; idx < 300; idx++)
        gfx.DrawLine(properties.Pen2.Pen, rnd.Next(600), rnd.Next(500), rnd.Next(600), rnd.Next(500));
    }
        private void button_generate_Click(object sender, EventArgs e)
        {
            int         yPoint   = 170;
            PdfDocument document = new PdfDocument();

            document.Info.Title = "Raport";
            PdfPage page = document.AddPage();

            PdfSharp.Drawing.XGraphics gfx = XGraphics.FromPdfPage(page);
            XFont font_bold = new XFont("Verdana", 10, XFontStyle.BoldItalic);

            DateTime date_from = dateTimePicker_from.Value;
            DateTime date_to   = dateTimePicker_to.Value;

            var orders = db.orders.Where(o => o.deadline >= date_from && o.deadline <= date_to);

            if (!orders.Any())
            {
                MessageBox.Show("There is no orders added to raport !");
            }
            else
            {
                XFont font_regular = new XFont("Verdana", 10, XFontStyle.Bold);



                gfx.DrawString("Raport from: " + date_from.ToString("d") + " to: " + date_to.ToString("d"), font_regular, XBrushes.Black, new XRect(60, 80, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);

                gfx.DrawString("Created: ", font_regular, XBrushes.Black, new XRect(60, 150, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);
                gfx.DrawString("Deadline: ", font_regular, XBrushes.Black, new XRect(160, 150, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);
                gfx.DrawString("Customer: ", font_regular, XBrushes.Black, new XRect(260, 150, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);
                gfx.DrawString("Employee: ", font_regular, XBrushes.Black, new XRect(360, 150, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);
                font_regular = new XFont("Verdana", 10, XFontStyle.Regular);

                foreach (order order in orders)
                {
                    gfx.DrawString(order.create_timestamp.ToString("d"), font_regular, XBrushes.Black, new XRect(60, yPoint, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);
                    gfx.DrawString(order.deadline.ToString("d"), font_regular, XBrushes.Black, new XRect(160, yPoint, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);
                    gfx.DrawString(order.customer.company_name, font_regular, XBrushes.Black, new XRect(260, yPoint, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);
                    gfx.DrawString(order.employee.firstname + " " + order.employee.lastname, font_regular, XBrushes.Black, new XRect(360, yPoint, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);
                    gfx.DrawLine(XPens.Black, 0, yPoint, 1000, yPoint);
                    yPoint += 30;
                }
                gfx.DrawLine(XPens.Black, 0, yPoint, 1000, yPoint);

                SaveFileDialog sfd = new SaveFileDialog
                {
                    Filter   = "PDF (*.pdf)|*.pdf",
                    FileName = "Output.pdf"
                };
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        document.Save(sfd.FileName);
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex.Message);
                        MessageBox.Show("You cannot generate raport unless previous one is closed !");
                    }
                }
            }
        }
        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 #27
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 #28
0
 private static void DrawRectangle(XGraphics gfx, double PenWidth, int RectWidth, int RectHeight, int StartLeft, int StartTop)
 {
     XPen pen = default(XPen);
     pen = XPens.SteelBlue.Clone();
     pen.Width = PenWidth;
     int Width = RectWidth;
     int Height = RectHeight;
     int Left = StartLeft;
     int Right = (Left + Width);
     int Top = StartTop;
     int Bottom = (Top + Height);
     gfx.DrawLine(pen, new Point(Left, Top), new Point(Right, Top));
     gfx.DrawLine(pen, new Point(Right, Top), new Point(Right, Bottom));
     gfx.DrawLine(pen, new Point(Right, Bottom), new Point(Left, Bottom));
     gfx.DrawLine(pen, new Point(Left, Bottom), new Point(Left, Top));
 }
Example #29
0
 private static void DrawLine(XGraphics gfx, int Left, int Right, int Top, string Color, double Thickness)
 {
     XPen pen = new XPen(XColor.FromName(Color));
     pen.Width = Thickness;
     gfx.DrawLine(pen, new Point(Left, Top), new Point(Right, Top));
 }
        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
        }
Example #31
0
 void DrawGridline(XGraphics gfx, XPoint origin, XPen pen, double delta, XRect box)
 {
   double xmin = box.X, ymin = box.Y, xmax = box.X + box.Width, ymax = box.Y + box.Height;
   double x, y;
   y = origin.Y;
   while (y < ymax)
   {
     gfx.DrawLine(pen, xmin, y, xmax, y);
     y += delta;
   }
   y = origin.Y - delta;
   while (y > ymin)
   {
     gfx.DrawLine(pen, xmin, y, xmax, y);
     y -= delta;
   }
   x = origin.X;
   while (x < xmax)
   {
     gfx.DrawLine(pen, x, ymin, x, ymax);
     x += delta;
   }
   x = origin.X - delta;
   while (x > xmin)
   {
     gfx.DrawLine(pen, x, ymin, x, ymax);
     x -= delta;
   }
 }
Example #32
-1
        public void Render(XGraphics gfx, FixedElement element)
        {
            var spec = element.Specification;

            var penTop = new XPen(XColor.FromArgb(spec.Borders.Color), spec.Borders.Top.Points);
            var penLeft = new XPen(XColor.FromArgb(spec.Borders.Color), spec.Borders.Left.Points);
            var penRight = new XPen(XColor.FromArgb(spec.Borders.Color), spec.Borders.Right.Points);
            var penBottom = new XPen(XColor.FromArgb(spec.Borders.Color), spec.Borders.Bottom.Points);

            var midBorderTop = element.InnerBox.Top - spec.Borders.Top / 2;
            var midBorderRight = element.InnerBox.Right + spec.Borders.Right / 2;
            var midBorderBottom = element.InnerBox.Bottom + spec.Borders.Bottom / 2;
            var midBorderLeft = element.InnerBox.Left - spec.Borders.Left / 2;

            if (spec.Borders.Top != Unit.Zero)
                gfx.DrawLine(penTop, element.InnerBox.Left.Points, midBorderTop.Points, element.InnerBox.Right.Points, midBorderTop.Points);

            if (spec.Borders.Right != Unit.Zero)
                gfx.DrawLine(penRight, midBorderRight.Points, element.MarginBox.Top.Points, midBorderRight.Points, element.MarginBox.Bottom.Points);

            if (spec.Borders.Bottom != Unit.Zero)
                gfx.DrawLine(penBottom, element.InnerBox.Left.Points, midBorderBottom.Points, element.InnerBox.Right.Points, midBorderBottom.Points);

            if (spec.Borders.Left != Unit.Zero)
                gfx.DrawLine(penLeft, midBorderLeft.Points, element.MarginBox.Top.Points, midBorderLeft.Points, element.MarginBox.Bottom.Points);
        }
Example #33
-1
 private static void DrawLineInternal(XGraphics gfx, XPen pen, bool isStroked, ref XPoint p0, ref XPoint p1)
 {
     if (isStroked)
     {
         gfx.DrawLine(pen, p0, p1);
     }
 }