Ejemplo n.º 1
0
        private void DrawFormXObject(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "DrawImage (Form XObject)");
            XImage xImage = XImage.FromFile("../../../../../PDFs/SomeLayout.pdf");

            gfx.TranslateTransform(125.0, 70.0);
            gfx.ScaleTransform(0.35);
            gfx.TranslateTransform(-125.0, -70.0);
            double num  = (double)(xImage.PixelWidth * 72) / xImage.HorizontalResolution;
            double num2 = (double)(xImage.PixelHeight * 72) / xImage.HorizontalResolution;

            gfx.DrawImage(xImage, (250.0 - num) / 2.0, (140.0 - num2) / 2.0, num, num2);
            base.EndBox(gfx);
        }
Ejemplo n.º 2
0
        private void DrawImageSheared(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "DrawImage (sheared)");
            XImage xImage = XImage.FromFile("../../../../../../dev/XGraphicsLab/images/Z3.jpg");

            gfx.TranslateTransform(125.0, 70.0);
            gfx.ScaleTransform(-0.7, 0.7);
            gfx.ShearTransform(-0.4, -0.3);
            gfx.TranslateTransform(-125.0, -70.0);
            double num    = (double)(xImage.PixelWidth * 72) / xImage.HorizontalResolution;
            double height = (double)(xImage.PixelHeight * 72) / xImage.HorizontalResolution;

            gfx.DrawImage(xImage, (250.0 - num) / 2.0, 0.0, num, height);
            base.EndBox(gfx);
        }
Ejemplo n.º 3
0
        private void BeginBox(XGraphics gfx, int number, string title)
        {
            const int dEllipse = 15;
            XRect     rect     = new XRect(0, 20, 300, 200);

            if (number % 2 == 0)
            {
                rect.X = 300 - 5;
            }
            rect.Y = 40 + ((number - 1) / 2) * (200 - 5);
            rect.Inflate(-10, -10);
            XRect rect2 = rect;

            rect2.Offset(2, 2);
            XColor xColor1 = XColors.DarkGoldenrod;
            XColor xColor2 = XColors.Chocolate;

            gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromArgb(9, XColors.DarkGoldenrod)), rect2, new XSize(dEllipse + 8, dEllipse + 8));
            XLinearGradientBrush brush = new XLinearGradientBrush(rect, xColor1, xColor2, XLinearGradientMode.Vertical);

            gfx.DrawRoundedRectangle(brush, rect, new XSize(dEllipse, dEllipse));
            rect.Inflate(-5, -5);
            XFont font = new XFont("Verdana", 14, XFontStyle.Bold);

            gfx.DrawString(title, font, XBrushes.Black, rect, XStringFormats.TopCenter);
            rect.Inflate(-10, -5);
            rect.Y      += 20;
            rect.Height -= 20;
            gfx.Save();
            gfx.TranslateTransform(rect.X, rect.Y);
        }
Ejemplo n.º 4
0
    public void DrawBox(XGraphics gfx, XRect rect, XPen borderPen)
    {
        //int dEllipse = 15;
        //XRect rect = new XRect(75, 130, 400, 300);
        //if (number % 2 == 0)
        //    rect.X = 300 - 5;
        //rect.Y = 40 + ((number - 1) / 2) * (200 - 5);
        //rect.Inflate(-10, -10);
        //XRect rect2 = rect;
        //rect2.Offset(this.borderWidth, this.borderWidth);
        gfx.DrawRectangle(borderPen, rect);
        //gfx.DrawRoundedRectangle(this.borderPen, new XSolidBrush(this.backColor), rect, new XSize(dEllipse, dEllipse));
        //rect.Inflate(-5, -5);

        //XFont font = new XFont("Verdana", 12, XFontStyle.Regular);
        //gfx.DrawString(title, font, XBrushes.Black, rect, XStringFormat.CenterTop);

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

        this._state = gfx.Save();
        gfx.TranslateTransform(rect.X, rect.Y);
        SetBoxX(0);
        SetBoxY(0);
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Draws a clock on a square page.
        /// Inspired by Charles Petzold's AnalogClock sample in
        /// 'Programming Microsoft Windows with C#'.
        /// </summary>
        void RenderClock(XGraphics gfx)
        {
            // Clocks should always look happy on hardcopies...
            //this.time = new DateTime(2005, 1, 1, 11, 6, 22, 500);

            XColor strokeColor = XColors.DarkBlue;
            XColor fillColor   = XColors.DarkOrange;

            XPen   pen   = new XPen(strokeColor, 5);
            XBrush brush = new XSolidBrush(fillColor);

            strokeColor.A = 0.8;
            fillColor.A   = 0.8;
            XPen   handPen   = new XPen(strokeColor, 5);
            XBrush handBrush = new XSolidBrush(fillColor);

            DrawText(gfx, pen, brush);

            double width  = gfx.PageSize.Width;
            double height = gfx.PageSize.Height;

            gfx.TranslateTransform(width / 2, height / 2);
            double scale = Math.Min(width, height);

            gfx.ScaleTransform(scale / 2000);

            DrawFace(gfx, pen, brush);
            DrawHourHand(gfx, handPen, handBrush);
            DrawMinuteHand(gfx, handPen, handBrush);
            DrawSecondHand(gfx, new XPen(XColors.Red, 7));
        }
Ejemplo n.º 6
0
        public override void SetTransformation(double translateX, double translateY, double rotate, double scaleX, double scaleY)
        {
            // Revert to original state, and immediately put this state on the stack again.
            XGraphics.Restore();
            XGraphics.Save();

            XGraphics.TranslateTransform(translateX, translateY);
            if (rotate != 0.0)
            {
                XGraphics.RotateTransform(rotate / System.Math.PI * 180.0);
            }
            if (scaleX != 1.0 || scaleY != 1.0)
            {
                XGraphics.ScaleTransform(scaleX, scaleY);
            }
        }
Ejemplo n.º 7
0
        public void BeginBox(XGraphics gfx, int number, string title)
        {
            XRect xRect = new XRect(0.0, 20.0, 300.0, 200.0);
            bool  flag  = number % 2 == 0;

            if (flag)
            {
                xRect.X = 295.0;
            }
            xRect.Y = (double)(40 + (number - 1) / 2 * 195);
            xRect.Inflate(-10.0, -10.0);
            XRect rect = xRect;

            rect.Offset(this.borderWidth, this.borderWidth);
            gfx.DrawRoundedRectangle(new XSolidBrush(this.shadowColor), rect, new XSize(23.0, 23.0));
            XLinearGradientBrush brush = new XLinearGradientBrush(xRect, this.backColor, this.backColor2, XLinearGradientMode.Vertical);

            gfx.DrawRoundedRectangle(this.borderPen, brush, xRect, new XSize(15.0, 15.0));
            xRect.Inflate(-5.0, -5.0);
            XFont font = new XFont("Verdana", 12.0, XFontStyle.Regular);

            gfx.DrawString(title, font, XBrushes.Navy, xRect, XStringFormats.TopCenter);
            xRect.Inflate(-10.0, -5.0);
            xRect.Y      += 20.0;
            xRect.Height -= 20.0;
            this.state    = gfx.Save();
            gfx.TranslateTransform(xRect.X, xRect.Y);
        }
Ejemplo n.º 8
0
    public void BeginBox(XGraphics gfx, int number, string title)
    {
        const int dEllipse = 15;
        XRect     rect     = new XRect(0, 20, 300, 200);

        if (number % 2 == 0)
        {
            rect.X = 300 - 5;
        }
        rect.Y = 40 + ((number - 1) / 2) * (200 - 5);
        rect.Inflate(-10, -10);
        XRect rect2 = rect;

        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);

        XFont font = new XFont("Verdana", 12, XFontStyle.Regular);

        gfx.DrawString(title, font, XBrushes.Navy, rect, XStringFormats.TopCenter);

        rect.Inflate(-10, -5);
        rect.Y      += 20;
        rect.Height -= 20;

        this.state = gfx.Save();
        gfx.TranslateTransform(rect.X, rect.Y);
    }
Ejemplo n.º 9
0
        public static void DrawImageOnPage(PdfPage page, XImage image, double x, double y, double page_rotation)
        {
            XGraphics gfx = XGraphics.FromPdfPage(page);

            // there is a bug for landscape PDF files
            Console.WriteLine("orientation {0}", page.Orientation);
            if (page.Orientation == PdfSharp.PageOrientation.Landscape)
            {
                // Translate coordinate system. To solve a strange problem.
                gfx.RotateTransform(-90);
                gfx.TranslateTransform(-page.Height, 0);
            }

            // rotate
            if (page_rotation != 0.0)
            {
                Console.WriteLine("rotate {0} degree", page_rotation);

                XPoint centerPoint = new XPoint(page.Width / 2, page.Height / 2);
                gfx.RotateAtTransform(-page_rotation, centerPoint);
            }

            gfx.DrawImage(image, x, y);
            gfx.Dispose();
        }
Ejemplo n.º 10
0
        PdfPage CreateWaterMark(PdfPage page, string watermark)
        {
            // Variation 1: Draw watermark as text string
            Gfx.Dispose();
            // Get an XGraphics object for drawing beneath the existing content
            XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend);

            // Get the size (in point) of the text
            XSize size = gfx.MeasureString(watermark, font);

            // Define a rotation transformation at the center of the page
            gfx.TranslateTransform(10, -400);

            // Create a string format
            XStringFormat format = new XStringFormat();

            format.Alignment     = XStringAlignment.Near;
            format.LineAlignment = XLineAlignment.Near;

            // Create a dimmed red brush
            XBrush brush = new XSolidBrush(XColor.FromArgb(128, 255, 0, 0));

            // Draw the string
            gfx.DrawString(watermark, font, brush,
                           new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
                           format);
            gfx.Dispose();
            Gfx = XGraphics.FromPdfPage(Page);

            return(page);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Draws Arcs.
        /// </summary>
        void RenderArcs(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

            XPen pen = new XPen(XColors.Plum, 4.7);

            gfx.DrawArc(pen, 0, 0, 250, 140, 190, 200);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Demonstrates the use of XGraphics.DrawImage.
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            XImage image = XImage.FromFile(@"..\..\images\Test (OS2).bmp");

            double dx = gfx.PageSize.Width;
            double dy = gfx.PageSize.Height;

#if true
            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.RotateTransform(-60);
            gfx.TranslateTransform(-dx / 2, -dy / 2);
#endif

            gfx.DrawImage(image, (dx - image.PixelWidth) / 2, (dy - image.PixelHeight) / 2, image.PixelWidth, image.PixelHeight);
        }
Ejemplo n.º 13
0
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            XImage image = XImage.FromFile(@"..\..\..\..\samples\PDFs\SomeLayout.pdf");

            double dx = gfx.PageSize.Width;
            double dy = gfx.PageSize.Height;

#if true
            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.RotateTransform(-25);
            gfx.TranslateTransform(-dx / 2, -dy / 2);
#endif

            gfx.DrawImage(image, (dx - image.PixelWidth) / 2, (dy - image.PixelHeight) / 2, image.PixelWidth, image.PixelHeight);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Source and more infos: http://www.math.dartmouth.edu/~dlittle/java/SpiroGraph/
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            //int R =  60, r =  60, p =   60, N = 270; // Cardioid
            //int R =  60, r = -45, p = -101, N = 270; // Rounded Square
            //int R =  75, r = -25, p =   85, N = 270; // Gold fish
            //int R =  75, r = -30, p =   60, N = 270; // Star fish
            //int R = 100, r =  49, p =   66, N =   7; // String of Pearls
            //int R =  90, r =   1, p =  105, N = 105; // Rotating Triangle

            //int R =  90, r =   1, p =  105, N = 105;
            int R = 60, r = 2, p = 122, N = 490;

            int revs = Math.Abs(r) / Gcd(R, Math.Abs(r));

            XPoint[] points = new XPoint[revs * N + 1];
            for (int i = 0; i <= revs * N; i++)
            {
                double t = 4 * i * Math.PI / N;
                points[i].X = ((R + r) * Math.Cos(t) - p * Math.Cos((R + r) * t / r));
                points[i].Y = ((R + r) * Math.Sin(t) - p * Math.Sin((R + r) * t / r));
            }

#if true
            // Draw as lines
            gfx.TranslateTransform(300, 250);
            gfx.DrawLines(properties.Pen2.Pen, points);

            //gfx.DrawPolygon(properties.Pen2.Pen, properties.Brush2.Brush, points, properties.General.FillMode);

            // Draw as closed curve
            gfx.TranslateTransform(0, 400);
            gfx.DrawClosedCurve(properties.Pen2.Pen, properties.Brush2.Brush, points, properties.General.FillMode,
                                properties.General.Tension);
#else
            gfx.TranslateTransform(300, 400);
            XSolidBrush dotBrush = new XSolidBrush(properties.Pen2.Pen.Color);
            float       width    = properties.Pen2.Width;
            for (int i = 0; i < revs * N; i++)
            {
                gfx.DrawEllipse(dotBrush, points[i].X, points[i].Y, width, width);
            }
#endif
        }
Ejemplo n.º 15
0
        private void DrawWaterMark(int wx, int wy, string wText, XFont wFont, Color wColor)
        {
            XSize sf = gfx.MeasureString(wText, wFont);

            gfx.TranslateTransform(wx / 2, wy / 2);

            //double Agle = -Math.Atan(wy / wx) * 180 / Math.PI;
            //gfx.RotateTransform((float)Agle);
            //gfx.TranslateTransform(-wx / 2, -wy / 2);

            XStringFormat wformat = new XStringFormat();

            wformat.Alignment     = XStringAlignment.Near;
            wformat.LineAlignment = XLineAlignment.Near;

            // XBrush wbrush = new XSolidBrush(Color.FromArgb(20, Color.Black));
            XBrush wbrush = new XSolidBrush(Color.FromArgb(20, wColor));

            wx = (int)(wx - sf.Width) / 2;
            wy = (int)(wy - sf.Height) / 2;

            XPoint Point_xy = new XPoint(wx, wy);
            //gfx.DrawString(wText, wFont, wbrush, Point_xy, wformat);


            // OUTLINED METHOD
            // System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            // StringFormat wformat2 = new StringFormat();
            // wformat2.Alignment = StringAlignment.Near;
            // wformat2.LineAlignment = StringAlignment.Near;
            Point Point_xy2 = new Point(wx, wy);
            // path.AddString(wText, new FontFamily("Arial"), (int)FontStyle.Italic, 120, Point_xy2, wformat2);

            // Pen pen = new Pen(Color.FromArgb(64,Color.Black), 3);
            //gfx.Graphics.DrawPath(pen, path);


            XGraphicsPath path = new XGraphicsPath();

            path.AddString(wText, wFont.FontFamily, XFontStyle.Italic, 103, Point_xy2, wformat);
            Pen pen = new Pen(Color.FromArgb(64, wColor), 3);

            //e.Graphics.DrawPath(pen, path);
            gfx.DrawPath(pen, path);
        }
Ejemplo n.º 16
0
        void RenderPolygons(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

            XPen pen = new XPen(XColors.DarkBlue, 2.5);

            gfx.DrawPolygon(pen, XBrushes.LightCoral, GeometryObjects.GetPentagram(50, new XPoint(60, 70)), XFillMode.Winding);
            gfx.DrawPolygon(pen, XBrushes.LightCoral, GeometryObjects.GetPentagram(50, new XPoint(180, 70)), XFillMode.Alternate);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Draws curves.
        /// </summary>
        void RenderCurves(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

            XPoint[] points = { new XPoint(20, 30), new XPoint(60, 120), new XPoint(90, 20), new XPoint(170, 90), new XPoint(230, 40) };
            XPen     pen    = new XPen(XColors.RoyalBlue, 3.5);

            gfx.DrawCurve(pen, points, 1);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Demonstrates the use of XGraphics.SetClip.
        /// </summary>
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            gfx.Save();
            gfx.TranslateTransform(50, 50);
            gfx.IntersectClip(new Rectangle(0, 0, 400, 250));
            gfx.TranslateTransform(50, 50);
            //gfx.Clear(XColor.GhostWhite);
            gfx.DrawEllipse(XPens.Green, XBrushes.Yellow, 40, 40, 500, 500);
            gfx.Restore();

            gfx.Save();
            //gfx.Transform = new XMatrix();  //XMatrix.Identity;
            gfx.TranslateTransform(200, 200);
            gfx.IntersectClip(new Rectangle(0, 0, 400, 250));
            gfx.DrawEllipse(XPens.Green, XBrushes.Yellow, 40, 40, 500, 500);
            gfx.Restore();
        }
Ejemplo n.º 19
0
        void RenderClosedCurves(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

            XPen pen = new XPen(XColors.DarkBlue, 2.5);

            gfx.DrawClosedCurve(pen, XBrushes.SkyBlue,
                                new XPoint[] { new XPoint(10, 120), new XPoint(80, 30), new XPoint(220, 20), new XPoint(170, 110), new XPoint(100, 90) },
                                XFillMode.Winding, 0.7);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Draws a form XObject (a page from an external PDF file).
        /// </summary>
        void DrawFormXObject(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawImage (Form XObject)");

            var image = XImage.FromFile(PdfSamplePath);

            const double dx = 250, dy = 140;

            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.ScaleTransform(0.35);
            gfx.TranslateTransform(-dx / 2, -dy / 2);

            var width  = image.PixelWidth * 72 / image.HorizontalResolution;
            var height = image.PixelHeight * 72 / image.HorizontalResolution;

            gfx.DrawImage(image, (dx - width) / 2, (dy - height) / 2, width, height);

            EndBox(gfx);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Draws an image transformed.
        /// </summary>
        void DrawImageRotated(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawImage (rotated)");

            var image = XImage.FromFile(JpegSamplePath);

            const double dx = 250, dy = 140;

            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.ScaleTransform(0.7);
            gfx.RotateTransform(-25);
            gfx.TranslateTransform(-dx / 2, -dy / 2);
            var width  = image.PixelWidth * 72 / image.HorizontalResolution;
            var height = image.PixelHeight * 72 / image.HorizontalResolution;

            gfx.DrawImage(image, (dx - width) / 2, 0, width, height);

            EndBox(gfx);
        }
Ejemplo n.º 22
0
        private static void RenderToGraphics(Render.RenderContext ctx, int rot, float translateX, float translateY, XGraphics graphics)
        {
            graphics.TranslateTransform(translateX, translateY);
            graphics.RotateTransform(rot * 90);

            using (Maps.Rendering.RenderUtil.SaveState(graphics))
            {
                if (ctx.clipPath != null)
                {
                    XMatrix m = ctx.ImageSpaceToWorldSpace;
                    graphics.MultiplyTransform(m);
                    graphics.IntersectClip(ctx.clipPath);
                    m.Invert();
                    graphics.MultiplyTransform(m);
                }

                ctx.graphics = graphics;
                Maps.Rendering.Render.RenderTile(ctx);
            }


            if (ctx.border && ctx.clipPath != null)
            {
                using (Maps.Rendering.RenderUtil.SaveState(graphics))
                {
                    // Render border in world space
                    XMatrix m = ctx.ImageSpaceToWorldSpace;
                    graphics.MultiplyTransform(m);
                    XPen pen = new XPen(ctx.styles.imageBorderColor, 0.2f);

                    // PdfSharp can't ExcludeClip so we take advantage of the fact that we know
                    // the path starts on the left edge and proceeds clockwise. We extend the
                    // path with a counterclockwise border around it, then use that to exclude
                    // the original path's region for rendering the border.
                    ctx.clipPath.Flatten();
                    RectangleF bounds = PathUtil.Bounds(ctx.clipPath);
                    bounds.Inflate(2 * (float)pen.Width, 2 * (float)pen.Width);
                    List <byte>   types  = new List <byte>(ctx.clipPath.Internals.GdiPath.PathTypes);
                    List <PointF> points = new List <PointF>(ctx.clipPath.Internals.GdiPath.PathPoints);

                    PointF key = points[0];
                    points.Add(new PointF(bounds.Left, key.Y)); types.Add(1);
                    points.Add(new PointF(bounds.Left, bounds.Bottom)); types.Add(1);
                    points.Add(new PointF(bounds.Right, bounds.Bottom)); types.Add(1);
                    points.Add(new PointF(bounds.Right, bounds.Top)); types.Add(1);
                    points.Add(new PointF(bounds.Left, bounds.Top)); types.Add(1);
                    points.Add(new PointF(bounds.Left, key.Y)); types.Add(1);
                    points.Add(new PointF(key.X, key.Y)); types.Add(1);

                    XGraphicsPath path = new XGraphicsPath(points.ToArray(), types.ToArray(), XFillMode.Winding);
                    graphics.IntersectClip(path);
                    graphics.DrawPath(pen, ctx.clipPath);
                }
            }
        }
Ejemplo n.º 23
0
        void RenderGIFs(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

            XImage image = XImage.FromFile("Test.gif");

            // Left position in point
            double x = (250 - image.PixelWidth * 72 / image.HorizontalResolution) / 2;

            gfx.DrawImage(image, x, 0);
        }
Ejemplo n.º 24
0
        static void DrawFormXObject(XGraphics gfx, int number)
        {
            //this.backColor = XColors.LightSalmon;
            BeginBox(gfx, number, "DrawImage (Form XObject)");

            XImage image = XImage.FromFile(pdfSamplePath);

            const double dx = 250, dy = 140;

            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.ScaleTransform(0.35);
            gfx.TranslateTransform(-dx / 2, -dy / 2);

            double width  = image.PixelWidth * 72 / image.HorizontalResolution;
            double height = image.PixelHeight * 72 / image.HorizontalResolution;

            gfx.DrawImage(image, (dx - width) / 2, (dy - height) / 2, width, height);

            EndBox(gfx);
        }
Ejemplo n.º 25
0
        void DrawImageSheared(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawImage (sheared)");

            XImage image = XImage.FromFile(jpegSamplePath);

            const double dx = 250, dy = 140;

            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.ScaleTransform(-0.7, 0.7);
            gfx.ShearTransform(-0.4, -0.3);
            gfx.TranslateTransform(-dx / 2, -dy / 2);

            double width  = image.PixelWidth * 72 / image.HorizontalResolution;
            double height = image.PixelHeight * 72 / image.HorizontalResolution;

            gfx.DrawImage(image, (dx - width) / 2, 0, width, height);

            EndBox(gfx);
        }
Ejemplo n.º 26
0
        void RenderRectangles(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);
        }
Ejemplo n.º 27
0
        /// <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);
        }
Ejemplo n.º 28
0
        void RenderRoundedRectangles(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

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

            gfx.DrawRoundedRectangle(pen, 10, 0, 100, 60, 30, 20);
            gfx.DrawRoundedRectangle(XBrushes.Orange, 130, 0, 100, 60, 30, 20);
            gfx.DrawRoundedRectangle(pen, XBrushes.Orange, 10, 80, 100, 60, 30, 20);
            gfx.DrawRoundedRectangle(pen, XBrushes.Orange, 150, 80, 60, 60, 20, 20);
        }
Ejemplo n.º 29
0
        void RenderPies(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

            XPen pen = new XPen(XColors.DarkBlue, 2.5);

            gfx.DrawPie(pen, 10, 0, 100, 90, -120, 75);
            gfx.DrawPie(XBrushes.Gold, 130, 0, 100, 90, -160, 150);
            gfx.DrawPie(pen, XBrushes.Gold, 10, 50, 100, 90, 80, 70);
            gfx.DrawPie(pen, XBrushes.Gold, 150, 80, 60, 60, 35, 290);
        }
Ejemplo n.º 30
0
        void RenderGlyphsPath(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

            XGraphicsPath path = new XGraphicsPath();

            //path.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100, new XRect(0, 0, 250, 140),
            //        XStringFormat.Center);
            path.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100, new XRect(0, 0, 250, 140), XStringFormats.Center);
            gfx.DrawPath(new XPen(XColors.Purple, 2.3), XBrushes.DarkOrchid, path);
        }