private void button15_Click(object sender, System.EventArgs e) { C1.C1Pdf.C1PdfDocument pdf = new C1.C1Pdf.C1PdfDocument(); // create an array with some brushes Brush[] brushes = new Brush[] { Brushes.Red, Brushes.Green, Brushes.Blue, Brushes.Yellow, Brushes.Crimson, Brushes.Aquamarine }; // setup rectangle and initialize angles RectangleF rc = new RectangleF(100, 100, 180, 150); float startAngle = 0; float sweepAngle = -90; // << counter-clockwise // draw pie foreach (Brush brush in brushes) { pdf.FillPie(brush, rc, startAngle, sweepAngle); pdf.DrawPie(Pens.Black, rc, startAngle, sweepAngle); startAngle += sweepAngle; sweepAngle /= 2; } // save the document to a file string fileName = tempdir + "drawpie.pdf"; pdf.Save(fileName); System.Diagnostics.Process.Start(fileName); }
private void GdiModel_Load(object sender, EventArgs e) { //start document _c1pdf.Clear(); //prepare to draw with Gdi-like commands int penWidth = 0; int penRGB = 0; Rectangle rc = new Rectangle(50, 50, 300, 200); string text = "Hello world of .NET Graphics and PDF.\r\nNice to meet you."; Font font = new Font("Times New Roman", 16, FontStyle.Italic | FontStyle.Underline); //start, c1, c2, end1, c3, c4, end PointF[] bezierPoints = new PointF[] { new PointF(110f, 200f), new PointF(120f, 110f), new PointF(135f, 150f), new PointF(150f, 200f), new PointF(160f, 250f), new PointF(165f, 200f), new PointF(150f, 100f) }; //draw to pdf document C1.C1Pdf.C1PdfDocument g = _c1pdf; g.FillPie(Brushes.Red, rc, 0, 20f); g.FillPie(Brushes.Green, rc, 20f, 30f); g.FillPie(Brushes.Blue, rc, 60f, 12f); g.FillPie(Brushes.Gold, rc, -80f, -20f); for (float sa = 0; sa < 360; sa += 40) { Color penColor = Color.FromArgb(penRGB, penRGB, penRGB); Pen pen = new Pen(penColor, penWidth++); penRGB = penRGB + 20; g.DrawArc(pen, rc, sa, 40f); } g.DrawRectangle(Pens.Red, rc); g.DrawBeziers(Pens.Blue, bezierPoints); g.DrawString(text, font, Brushes.Black, rc); //save pdf file string filename = GetTempFileName(".pdf"); _c1pdf.Save(filename); //display it webBrowser1.Navigate(filename); }
private void button5_Click(object sender, System.EventArgs e) { // create pdf document C1.C1Pdf.C1PdfDocument g = new C1.C1Pdf.C1PdfDocument(); // set up to draw Rectangle rc = new Rectangle(0, 0, 300, 200); string text = "Hello world of .NET Graphics and PDF.\r\nNice to meet you."; Font font = new Font("Times New Roman", 12, FontStyle.Italic | FontStyle.Underline); PointF[] bezierpts = new PointF[] { new PointF(10f, 100f), new PointF(20f, 10f), new PointF(35f, 50f), new PointF(50f, 100f), new PointF(60f, 150f), new PointF(65f, 100f), new PointF(50f, 50f) }; // draw to pdf document int penWidth = 0; int penRGB = 0; g.FillPie(Brushes.Red, rc, 0, 20f); g.FillPie(Brushes.Green, rc, 20f, 30f); g.FillPie(Brushes.Blue, rc, 60f, 12f); g.FillPie(Brushes.Gold, rc, -80f, -20f); for (float startAngle = 0; startAngle < 360; startAngle += 40) { Color penColor = Color.FromArgb(penRGB, penRGB, penRGB); Pen pen = new Pen(penColor, penWidth++); penRGB = penRGB + 20; g.DrawArc(pen, rc, startAngle, 40f); } g.DrawRectangle(Pens.Red, rc); g.DrawBeziers(Pens.Blue, bezierpts); g.DrawString(text, font, Brushes.Black, rc); // show it string fileName = tempdir + "graphics.pdf"; g.Save(fileName); System.Diagnostics.Process.Start(fileName); }