static void CreateDocumentGraphics(C1WordDocument word)
        {
            // set up to draw
            word.Landscape = true;
            Rect   rc   = new Rect(0, 100, 300, 300);
            string text = Strings.DocumentGraphicsText;
            Font   font = new Font("Segoe UI Light", 16, RtfFontStyle.Italic);

            // add warning paragraph
            word.AddParagraph(Strings.GraphicsWarning, font, Colors.DarkGray, RtfHorizontalAlignment.Left);
            var paragraph = (RtfParagraph)word.Current;

            paragraph.BottomBorderColor = Colors.Red;
            paragraph.BottomBorderStyle = RtfBorderStyle.Dotted;
            paragraph.BottomBorderWidth = 1f;
            word.AddParagraph(string.Empty);

            // draw to word document
            int  penWidth = 0;
            byte penRGB   = 0;

            word.FillPie(Colors.DarkRed, rc, 0, 20f);
            word.FillPie(Colors.Green, rc, 20f, 30f);
            word.FillPie(Colors.Teal, rc, 60f, 12f);
            word.FillPie(Colors.Orange, rc, -80f, -20f);
            for (float startAngle = 0; startAngle < 360; startAngle += 40)
            {
                Color penColor = Color.FromArgb(0xff, penRGB, penRGB, penRGB);
                Pen   pen      = new Pen(penColor, penWidth++);
                penRGB = (byte)(penRGB + 20);
                word.DrawArc(pen, rc, startAngle, 40f);
            }
            word.DrawRectangle(Colors.Red, rc);
            word.DrawString(text, font, Colors.Black, rc);

            // show a Bezier curve
            var pts = new Point[]
            {
                new Point(400, 100), new Point(420, 30),
                new Point(500, 140), new Point(530, 20),
            };

            // draw Bezier
            word.DrawBeziers(new Pen(Colors.Green, 4), pts);

            // show Bezier control points
            word.DrawPolyline(Colors.Gray, pts);
            foreach (Point pt in pts)
            {
                word.FillRectangle(Colors.Orange, pt.X - 2, pt.Y - 2, 4, 4);
            }

            // title
            word.DrawString(Strings.Bezier, font, Colors.Black, new Rect(500, 150, 100, 100));
        }
Beispiel #2
0
        private void _btCurve_Click(object sender, System.EventArgs e)
        {
            // create document
            C1WordDocument c1Word = new C1WordDocument();

            c1Word.Info.Title = "Various curves sample";
            _statusBar.Text   = "Creating document...";

            StringFormat sf = new StringFormat();

            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
            RectangleF rc   = new RectangleF(250, 100, 150, 20);
            Font       font = new Font("Tachoma", 12, FontStyle.Italic | FontStyle.Underline);

            c1Word.DrawString("Curves sample", font, Color.Black, rc, sf);

            //// curve
            //PointF[] pts = new PointF[7];
            //pts[0] = new PointF(191.1f, 172.3f);
            //pts[1] = new PointF(229.1f, 205.3f);
            //pts[2] = new PointF(267.15f, 238.3f);
            //pts[3] = new PointF(296.4f, 235.3f);
            //pts[4] = new PointF(325.65f, 232.3f);
            //pts[5] = new PointF(346.1f, 193.3f);
            //pts[6] = new PointF(366.6f, 154.3f);
            //c1Word.DrawBeziers(Pens.HotPink, pts);

            //// pie
            //rc = new RectangleF(120, 100, 150, 80);
            //c1Word.FillPie(Brushes.Yellow, rc, 0, 90);
            //c1Word.DrawPie(Pens.Indigo, rc, 0, 90);

            // arc
            rc = new RectangleF(120, 100, 150, 80);
            c1Word.DrawArc(Pens.Red, rc, 0, 90);

            //// arc
            //rc = new RectangleF(320, 300, 90, 45);
            //c1Word.DrawArc(Pens.Blue, rc, 270, 90);

            _statusBar.Text = "Saving document...";
            string fileName = GetFileName(c1Word, "curves.rtf");

            c1Word.Save(fileName);
            Process.Start(fileName);
            _statusBar.Text = "Ready.";
        }
Beispiel #3
0
        //---------------------------------------------------------------------------------
        #region ** graphics

        static void CreateDocumentGraphics(C1WordDocument rtf)
        {
            // set up to draw
            Rect   rc   = new Rect(100, 100, 300, 200);
            string text = "Hello world of .NET Graphics and Word/RTF.\r\nNice to meet you.";
            Font   font = new Font("Times New Roman", 12, RtfFontStyle.Italic | RtfFontStyle.Underline);

            // draw to pdf document
            int  penWidth = 0;
            byte penRGB   = 0;

            rtf.FillPie(Colors.Red, rc, 0, 20f);
            rtf.FillPie(Colors.Green, rc, 20f, 30f);
            rtf.FillPie(Colors.Blue, rc, 60f, 12f);
            rtf.FillPie(Colors.Orange, rc, -80f, -20f);
            for (float startAngle = 0; startAngle < 360; startAngle += 40)
            {
                Color penColor = Color.FromArgb(0xff, penRGB, penRGB, penRGB);
                Pen   pen      = new Pen(penColor, penWidth++);
                penRGB = (byte)(penRGB + 20);
                rtf.DrawArc(pen, rc, startAngle, 40f);
            }
            rtf.DrawRectangle(Colors.Red, rc);
            rtf.DrawString(text, font, Colors.Black, rc);

            // show a Bezier curve
            var pts = new Point[]
            {
                new Point(400, 200), new Point(420, 130),
                new Point(500, 240), new Point(530, 120),
            };

            // draw Bezier
            rtf.DrawBeziers(new Pen(Colors.Blue, 4), pts);

            // show Bezier control points
            rtf.DrawPolyline(Colors.Gray, pts);
            foreach (Point pt in pts)
            {
                rtf.FillRectangle(Colors.Red, pt.X - 2, pt.Y - 2, 4, 4);
            }

            // title
            rtf.DrawString("Simple Bezier", font, Colors.Black, new Rect(500, 150, 100, 100));
        }