DrawBeziers() public method

Draws a series of Bézier splines from an array of points.
public DrawBeziers ( XPen pen, PointF points ) : void
pen XPen
points PointF
return void
    /// <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 #2
1
    /// <summary>
    /// Draws Bézier curves.
    /// </summary>
    void RenderBéziers(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XPoint[] points =  {new XPoint(20, 30), new XPoint(40, 120), new XPoint(80, 20), new XPoint(110, 90), 
                                new XPoint(180, 40), new XPoint(210, 40), new XPoint(220, 80)};
      XPen pen = new XPen(XColors.Firebrick, 4);
      //pen.DashStyle = XDashStyle.Dot;
      gfx.DrawBeziers(pen, points);
    }
Example #3
0
        private static void PrepareInvoiceTop(XGraphics formGfx, XGraphicsState state, string InvoiceNumber)
        {
            string Headline = "Service Invoice " + InvoiceNumber + "";
            string MyName = TimeConnector.Data.Variables.SelectedContractor["CmpName"];
            string Phone = TimeConnector.Data.Variables.SelectedContractorContact["ConPhone"];
            string MyPhone = "Phone (" + Phone.Substring(0, 3) + ") " + Phone.Substring(4, 3) + "-" + Phone.Substring(7, 4) + "";
            string MyEmail = "Email: " + TimeConnector.Data.Variables.SelectedContractorContact["ConEmail"] + "";
            string MyAddress = TimeConnector.Data.Variables.SelectedContractor["CmpAddress"];
            string MyCityStateZip = "" + TimeConnector.Data.Variables.SelectedContractor["CmpCity"] + ", " + TimeConnector.Data.Variables.SelectedContractor["CmpState"] + "  " + TimeConnector.Data.Variables.SelectedContractor["CmpZip"] + "";
            string WeekEnding = TimeConnector.Data.Variables.SelectedPaydate["WeekEnd"];
            string PayDate = TimeConnector.Data.Variables.SelectedPaydate["PayDate"];
            string CompanyName = TimeConnector.Data.Variables.SelectedCompany["CmpName"];
            string CompanyContact = "c/o " + TimeConnector.Data.Variables.SelectedContact["ConName"] + "";
            string CompanyContactPhone = "" + TimeConnector.Data.Variables.SelectedContact["ConPhone"] + "";
            string CompanyContactEmail = "" + TimeConnector.Data.Variables.SelectedContact["ConEmail"] + "";
            string CompanyAddress = TimeConnector.Data.Variables.SelectedCompany["CmpAddress"];
            string CompanyCityStateZip = "" + TimeConnector.Data.Variables.SelectedCompany["CmpCity"] + ", " + TimeConnector.Data.Variables.SelectedCompany["CmpState"] + "  " + TimeConnector.Data.Variables.SelectedCompany["CmpZip"] + "";

            //----- Invoice Header
            XFont HeaderFont = new XFont("Imprint MT Shadow", 30, XFontStyle.Bold);
            string HeaderText = "I N V O I C E";
            XStringFormat format = new XStringFormat();
            format.Alignment = XStringAlignment.Near;
            format.LineAlignment = XLineAlignment.Near;
            XColor color = default(XColor);
            color = XColor.FromName("SteelBlue");
            color.A = 0.5;
            XBrush brush = default(XBrush);
            brush = new XSolidBrush(color);
            XPoint point = new XPoint(410, 20);
            formGfx.DrawString(HeaderText, HeaderFont, brush, point, format);

            //..... My Company Icon
            state = formGfx.Save();
            formGfx.DrawImage(XImage.FromFile("Images\\logo.png"), 20, 20, 65, 65);
            formGfx.Restore(state);

            //..... My Company Information
            DrawText(MyName, formGfx, new XFont(PdfFontMyInfo, 15, XFontStyle.Bold), XBrushes.SteelBlue, 95, 20);
            DrawText(MyAddress, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 45);
            DrawText(MyCityStateZip, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 55);
            DrawText(MyPhone, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 65);
            DrawText(MyEmail, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 75);

            XPen pen1 = new XPen(XColors.Maroon);
            pen1.Width = 1;
            //Dim pen2 As New XPen(XColors.Maroon)
            XPen pen2 = new XPen(XColors.SteelBlue);
            pen2.Width = 2;
            //Dim pen3 As New XPen(XColors.SteelBlue)
            XPen pen3 = new XPen(XColors.Maroon);
            pen3.Width = 1;
            formGfx.DrawBeziers(pen1, XPoint.ParsePoints("20,95 80,140 190,70 250,110"));

            DrawSignature(formGfx, 531, 696, "LightGray", 1);
            DrawSignature(formGfx, 530, 695, "Black", 1.5);
            DrawSignature(formGfx, 530, 695, "SteelBlue", 1);

            //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("300,100 310,110 340,90 350,100"))  'Top
            //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("312,108 322,118 332,99 342,110")) 'Top Center
            //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("314,118 324,128 334,109 344,120")) 'Bottom Center
            //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("310,130 315,140 330,120 335,130")) 'Bottom
            //formGfx.DrawBeziers(pen2, XPoint.ParsePoints("325,100 335,110 325,120 335,130")) 'Center

            //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("300,100 310,110 340,90 350,100"))  'Top
            //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("312,108 322,118 332,99 342,110")) 'Top Center
            //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("314,118 324,128 334,109 344,120")) 'Bottom Center
            //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("310,130 315,140 330,120 335,130")) 'Bottom
            //formGfx.DrawBeziers(pen3, XPoint.ParsePoints("325,100 335,110 325,120 335,130")) 'Center

            //..... ACS Company Icon
            DrawText("B I L L   T O :", formGfx, new XFont(PdfFont, 9, XFontStyle.Bold), XBrushes.Black, 60, 95);
            state = formGfx.Save();
            formGfx.DrawImage(XImage.FromFile("Images\\ACSIcon.jpg"), 20, 115, 65, 65);
            formGfx.Restore(state);

            //..... ACS Company Information
            DrawText(CompanyName, formGfx, new XFont(PdfFontMyInfo, 15, XFontStyle.Bold), XBrushes.Green, 95, 115);
            DrawText(CompanyContact, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 135);
            DrawText(CompanyAddress, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 145);
            DrawText(CompanyCityStateZip, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 155);
            DrawText(CompanyContactPhone, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 165);
            DrawText(CompanyContactEmail, formGfx, new XFont(PdfFontMyInfo, 7, XFontStyle.Regular), XBrushes.Black, 95, 175);

            //..... Invoice Information
            DrawLine(formGfx, 450, 590, 80, "SteelBlue", 0.5);
            DrawText("Invoice #:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 71);
            DrawText(InvoiceNumber, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Maroon, 530, 71);
            DrawLine(formGfx, 450, 590, 90, "SteelBlue", 0.5);
            DrawText("Week Ending:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 81);
            DrawText(WeekEnding, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 81);
            DrawLine(formGfx, 450, 590, 100, "SteelBlue", 0.5);
            DrawText("Pay Date:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 91);
            DrawText(PayDate, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 91);
            DrawLine(formGfx, 450, 590, 110, "SteelBlue", 0.5);
            DrawText("Hours Worked:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 101);
            DrawText(TimeConnector.Data.Invoice.FinHour, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 101);
            DrawLine(formGfx, 450, 590, 120, "SteelBlue", 0.5);
            DrawText("Balance Due:", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 452, 111);
            DrawText(TimeConnector.Data.Invoice.FinCost, formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 530, 111);
        }
Example #4
0
 private static void PrepareFooter(XGraphics formGfx)
 {
     DrawRectangle(formGfx, 0.5, 200, 15, 20, 609);
     DrawText("Notes", formGfx, new XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 25, 612);
     DrawRectangle(formGfx, 0.5, 200, 80, 20, 624);
     //DrawText("Notes", formGfx, New XFont(PdfFont, 7, XFontStyle.Bold), XBrushes.Black, 25, 637)
     DrawText("Thank you for your business!!", formGfx, new XFont(PdfFont, 12, XFontStyle.Bold), XBrushes.SteelBlue, 350, 750);
     //DrawLine(formGfx, 20, 590, 756, "Black", 0.5)
     //DrawLine(formGfx, 20, 590, 757, "SteelBlue", 0.5)
     //DrawLine(formGfx, 20, 590, 758, "Maroon", 0.5)
     XPen pen1 = new XPen(XColors.Black);
     XPen pen2 = new XPen(XColors.SteelBlue);
     XPen pen3 = new XPen(XColors.Maroon);
     formGfx.DrawBeziers(pen1, XPoint.ParsePoints("20,715 134,810 476,635 590,775"));
     formGfx.DrawBeziers(pen2, XPoint.ParsePoints("20,730 134,815 476,640 590,775"));
     formGfx.DrawBeziers(pen3, XPoint.ParsePoints("20,745 134,820 476,645 590,775"));
 }
Example #5
0
        private static void DrawSignature(XGraphics gfx, int StartLeft, int StartTop, string Color, double Thickness)
        {
            XPen Main = new XPen(XColor.FromName(Color));
            Main.Width = Thickness;

            string LinePoints = null;
            int val1 = 0;
            int val2 = 0;
            int val3 = 0;
            int val4 = 0;
            int val5 = 0;
            int val6 = 0;
            int val7 = 0;
            int val8 = 0;

            //----- Top Line
            val1 = StartLeft;
            val2 = StartTop;
            val3 = val1 + 10;
            val4 = val2 + 10;
            val5 = val1 + 40;
            val6 = val2 - 10;
            val7 = val1 + 50;
            val8 = val2;
            LinePoints = "" + val1.ToString() + "," + val2.ToString() + " " + val3.ToString() + "," + val4.ToString() + " " + val5.ToString() + "," + val6.ToString() + " " + val7.ToString() + "," + val8.ToString() + "";
            gfx.DrawBeziers(Main, XPoint.ParsePoints(LinePoints));
            //gfx.DrawBeziers(Main, XPoint.ParsePoints("300,100 310,110 340,90 350,100"))

            //----- Top Center Line
            val1 = val1 + 12;
            val2 = val2 + 8;
            val3 = val1 + 10;
            val4 = val2 + 10;
            val5 = val1 + 20;
            val6 = val2 - 9;
            val7 = val1 + 30;
            val8 = val2 + 2;
            LinePoints = "" + val1.ToString() + "," + val2.ToString() + " " + val3.ToString() + "," + val4.ToString() + " " + val5.ToString() + "," + val6.ToString() + " " + val7.ToString() + "," + val8.ToString() + "";
            gfx.DrawBeziers(Main, XPoint.ParsePoints(LinePoints));
            //gfx.DrawBeziers(Main, XPoint.ParsePoints("312,108 322,118 332,99 342,110"))

            //----- Bottom Center Line
            val1 = val1 + 2;
            val2 = val2 + 10;
            val3 = val1 + 10;
            val4 = val2 + 10;
            val5 = val1 + 20;
            val6 = val2 - 9;
            val7 = val1 + 30;
            val8 = val2 + 2;
            LinePoints = "" + val1.ToString() + "," + val2.ToString() + " " + val3.ToString() + "," + val4.ToString() + " " + val5.ToString() + "," + val6.ToString() + " " + val7.ToString() + "," + val8.ToString() + "";
            gfx.DrawBeziers(Main, XPoint.ParsePoints(LinePoints));
            //gfx.DrawBeziers(Main, XPoint.ParsePoints("314,118 324,128 334,109 344,120")) 'Bottom Center

            //----- Bottom Line
            val1 = val1 - 4;
            //310
            val2 = val2 + 12;
            //130
            val3 = val1 + 10;
            //320
            val4 = val2 + 10;
            //140
            val5 = val1 + 15;
            //325
            val6 = val2 - 10;
            //120
            val7 = val1 + 25;
            //335
            val8 = val2;
            //130
            LinePoints = "" + val1.ToString() + "," + val2.ToString() + " " + val3.ToString() + "," + val4.ToString() + " " + val5.ToString() + "," + val6.ToString() + " " + val7.ToString() + "," + val8.ToString() + "";
            gfx.DrawBeziers(Main, XPoint.ParsePoints(LinePoints));
            //gfx.DrawBeziers(Main, XPoint.ParsePoints("310,130 315,140 330,120 335,130")) 'Bottom

            //----- Center Line
            val1 = val1 + 15;
            //325
            val2 = val2 - 30;
            //100
            val3 = val1 + 10;
            //335
            val4 = val2 + 10;
            //110
            val5 = val1;
            //325
            val6 = val2 + 20;
            //120
            val7 = val1 + 10;
            //335
            val8 = val2 + 30;
            //110
            LinePoints = "" + val1.ToString() + "," + val2.ToString() + " " + val3.ToString() + "," + val4.ToString() + " " + val5.ToString() + "," + val6.ToString() + " " + val7.ToString() + "," + val8.ToString() + "";
            gfx.DrawBeziers(Main, XPoint.ParsePoints(LinePoints));
            //gfx.DrawBeziers(Main, XPoint.ParsePoints("325,100 335,110 325,120 335,130")) 'Center

            //gfx.DrawBeziers(Main, XPoint.ParsePoints("300,100 310,110 340,90 350,100"))  'Top
            //gfx.DrawBeziers(Main, XPoint.ParsePoints("312,108 322,118 332,99 342,110")) 'Top Center
            //gfx.DrawBeziers(Main, XPoint.ParsePoints("314,118 324,128 334,109 344,120")) 'Bottom Center
            //gfx.DrawBeziers(Main, XPoint.ParsePoints("310,130 320,140 325,120 335,130")) 'Bottom
            //gfx.DrawBeziers(Main, XPoint.ParsePoints("325,100 335,110 325,120 335,130")) 'Center
        }
    /// <summary>
    /// Draws two Bézier curves.
    /// </summary>
    void DrawBeziers(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawBeziers");

      XPoint[] points = new XPoint[]{new XPoint(20, 30), new XPoint(40, 120), new XPoint(80, 20), new XPoint(110, 90), 
                                   new XPoint(180, 40), new XPoint(210, 40), new XPoint(220, 80)};
      XPen pen = new XPen(XColors.Firebrick, 4);
      //pen.DashStyle = XDashStyle.Dot;
      gfx.DrawBeziers(pen, points);

      EndBox(gfx);
    }