Exemplo n.º 1
0
        static void DrawPathAlternateAndWinding(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawPath (alternate / winding)");

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

            // Alternate fill mode
            XGraphicsPath path = new XGraphicsPath();

            path.FillMode = XFillMode.Alternate;
            path.AddLine(10, 130, 10, 40);
            path.AddBeziers(new XPoint[] { new XPoint(10, 40), new XPoint(30, 0), new XPoint(40, 20), new XPoint(60, 40),
                                           new XPoint(80, 60), new XPoint(100, 60), new XPoint(120, 40) });
            path.AddLine(120, 40, 120, 130);
            path.CloseFigure();
            path.AddEllipse(40, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, path);

            // Winding fill mode
            path          = new XGraphicsPath();
            path.FillMode = XFillMode.Winding;
            path.AddLine(130, 130, 130, 40);
            path.AddBeziers(new XPoint[] { new XPoint(130, 40), new XPoint(150, 0), new XPoint(160, 20), new XPoint(180, 40),
                                           new XPoint(200, 60), new XPoint(220, 60), new XPoint(240, 40) });
            path.AddLine(240, 40, 240, 130);
            path.CloseFigure();
            path.AddEllipse(160, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, path);

            EndBox(gfx);
        }
Exemplo n.º 2
0
        private void DrawThemeLayer(XGraphics gfx, Map map, double scaleFactor, VectorLayer lyr)
        {
            TransformsProvider tp      = new TransformsProvider(gfx);
            BoundingBox        geombox = map.GetExtents();

            FeatureDataSet fds = new FeatureDataSet();

            try
            {
                lyr.DataSource.ExecuteIntersectionQuery(geombox, fds);
                FeatureDataTable fdt = fds.Tables[0];
                for (int i = 0; i < fdt.Count; i++)
                {
                    FeatureDataRow fdr  = fdt[i];
                    VectorStyle    s    = (VectorStyle)lyr.Theme.GetStyle(fdr);
                    Geometry       geom = fdr.Geometry;
                    XPen           xp   = new XPen(XColor.FromArgb(s.Outline.Color), s.Outline.Width);
                    xp.DashStyle = (XDashStyle)s.Outline.DashStyle;
                    XSolidBrush xb = null;
                    if (geom is MultiLineString)
                    {
                        XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiLineString)geom, geombox);
                        this._geomCache.Add(new PDFGeom(g, xp, null));
                        gfx.DrawPath(xp, g);
                    }
                    if (geom is MultiPolygon)
                    {
                        XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiPolygon)geom, geombox);
                        if (s.Fill != null)
                        {
                            if ((s.Fill) is SolidBrush)
                            {
                                xb = new XSolidBrush(XColor.FromArgb((s.Fill as SolidBrush).Color));
                            }
                            else
                            {
                                xb = new XSolidBrush(XColor.FromKnownColor(KnownColor.Transparent));
                            }
                            this._geomCache.Add(new PDFGeom(g, xp, xb));
                            gfx.DrawPath(xp, xb, g);
                        }
                        else
                        {
                            this._geomCache.Add(new PDFGeom(g, xp, null));
                            gfx.DrawPath(xp, g);
                        }
                    }
                }
            }
            catch
            {
                //Do nothing, no render
            }
        }
Exemplo n.º 3
0
        public void DrawPath(IPen pen, IBrush brush, IGraphicsPath path)
        {
            if (brush is PdfBrush)
            {
                Graphics.DrawPath((XBrush)brush, (XGraphicsPath)path.Raw);
            }

            if (pen is PdfPen)
            {
                Graphics.DrawPath((XPen)pen.Raw, (XGraphicsPath)path.Raw);
            }
        }
Exemplo n.º 4
0
        public void Stroke(XGraphics graphics, XPen pen)
        {
            XGraphicsPath path      = new XGraphicsPath();
            bool          hasFigure = false;
            int           ptIndex   = 0;

            foreach (Command command in Commands)
            {
                switch (command)
                {
                case Command.MoveTo:
                    if (hasFigure)
                    {
                        graphics.DrawPath(pen, path);
                        path      = new XGraphicsPath();
                        hasFigure = false;
                    }
                    ptIndex++;
                    break;

                case Command.LineTo:
                    path.AddLine(Points[ptIndex - 1], Points[ptIndex]);
                    ptIndex  += 1;
                    hasFigure = true;
                    break;

                case Command.CubicCurveTo:
                    path.AddBezier(Points[ptIndex - 1], Points[ptIndex], Points[ptIndex + 1], Points[ptIndex + 2]);
                    ptIndex  += 3;
                    hasFigure = true;
                    break;

                case Command.CloseSubpath:
                    if (hasFigure)
                    {
                        path.CloseFigure();
                        hasFigure = false;
                    }
                    graphics.DrawPath(pen, path);
                    path = new XGraphicsPath();
                    break;

                case Command.Rectangle:
                    path.AddRectangle(Points[ptIndex + 1].X, Points[ptIndex + 1].Y, Points[ptIndex].X, Points[ptIndex].Y);
                    ptIndex += 2;
                    path.CloseFigure();
                    hasFigure = false;
                    break;
                }
            }

            graphics.DrawPath(pen, path);
        }
Exemplo n.º 5
0
        void IDrawingCanvas.DrawAndFillPath(PenEx pen, BrushEx brush, PathEx path)
        {
            var pdfPath = GetPath(path);

            if (brush != null)
            {
                _graphics.DrawPath((BrushBase)brush, pdfPath);
            }
            if (pen != null)
            {
                _graphics.DrawPath((Pen)pen, pdfPath);
            }
        }
Exemplo n.º 6
0
        public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics)
        {
            if (!string.IsNullOrEmpty(Data))
            {
                var   watermark = Data;
                XSize size      = Graphics.MeasureString(watermark, owner.Font);

                // Define a rotation transformation at the center of the page
                Graphics.TranslateTransform(Page.Width / 2, Page.Height / 2);
                Graphics.RotateTransform(-Math.Atan(Page.Height / Page.Width) * 180 / Math.PI);
                Graphics.TranslateTransform(-Page.Width / 2, -Page.Height / 2);

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

                // Add the text to the path
                path.AddString(watermark, owner.Font.FontFamily, XFontStyle.BoldItalic, 150, new XPoint(0, (Page.Height / 2) - 80), XStringFormats.TopLeft);

                // Create a dimmed red pen and brush
                XPen   pen   = new XPen(XColor.FromArgb(50, 75, 0, 130), 3);
                XBrush brush = new XSolidBrush(XColor.FromArgb(50, 106, 90, 205));

                // Stroke the outline of the path
                Graphics.DrawPath(pen, brush, path);
            }
        }
Exemplo n.º 7
0
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);
            DrawGridlines(gfx);

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

            XSize  size          = new XSize(90, 140);
            double rotationAngle = 130;

            path.AddArc(new XPoint(100, 100), new XPoint(200, 200), size, rotationAngle, false, System.Windows.Media.SweepDirection.Clockwise);
            path.StartFigure();
            path.AddArc(new XPoint(400, 100), new XPoint(500, 200), size, rotationAngle, false, System.Windows.Media.SweepDirection.Counterclockwise);
            path.StartFigure();
            path.AddArc(new XPoint(100, 300), new XPoint(200, 400), size, rotationAngle, true, System.Windows.Media.SweepDirection.Clockwise);
            path.StartFigure();
            path.AddArc(new XPoint(400, 300), new XPoint(500, 400), size, rotationAngle, true, System.Windows.Media.SweepDirection.Counterclockwise);
            path.StartFigure();

#if DEBUG_
            gfx.WriteComment("PathArcSegment");
#endif
            gfx.DrawPath(XPens.Red, path);
        }
Exemplo n.º 8
0
        public void Fill(XGraphics graphics, XBrush brush)
        {
            XGraphicsPath path = new XGraphicsPath
            {
                FillMode = XFillMode.Winding
            };
            bool hasFigure = false;
            int  ptIndex   = 0;

            foreach (Command command in Commands)
            {
                switch (command)
                {
                case Command.MoveTo:
                    if (hasFigure)
                    {
                        path.CloseFigure();
                        hasFigure = false;
                    }
                    ptIndex++;
                    break;

                case Command.LineTo:
                    path.AddLine(Points[ptIndex - 1], Points[ptIndex]);
                    ptIndex  += 1;
                    hasFigure = true;
                    break;

                case Command.CubicCurveTo:
                    path.AddBezier(Points[ptIndex - 1], Points[ptIndex], Points[ptIndex + 1], Points[ptIndex + 2]);
                    ptIndex  += 3;
                    hasFigure = true;
                    break;

                case Command.CloseSubpath:
                    if (hasFigure)
                    {
                        path.CloseFigure();
                        hasFigure = false;
                    }
                    break;

                case Command.Rectangle:
                    path.AddRectangle(Points[ptIndex + 1].X, Points[ptIndex + 1].Y, Points[ptIndex].X, Points[ptIndex].Y);
                    ptIndex += 2;
                    path.CloseFigure();
                    hasFigure = false;
                    break;
                }
            }

            if (hasFigure)
            {
                path.CloseFigure();
            }

            graphics.DrawPath(brush, path);
        }
Exemplo n.º 9
0
        private void DrawGlyphs(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "Draw Glyphs");
            XGraphicsPath xGraphicsPath = new XGraphicsPath();

            xGraphicsPath.AddString("Hello!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 100.0, new XRect(0.0, 0.0, 250.0, 140.0), XStringFormats.Center);
            gfx.DrawPath(new XPen(XColors.Purple, 2.3), XBrushes.DarkOrchid, xGraphicsPath);
            base.EndBox(gfx);
        }
Exemplo n.º 10
0
        static void DrawText(XGraphics gfx, XPen pen, XBrush brush)
        {
            XSize         size = gfx.PageSize;
            XGraphicsPath path = new XGraphicsPath();

            path.AddString("PDFsharp",
                           new XFontFamily("Verdana"), XFontStyle.BoldItalic, 60,
                           new XRect(0, size.Height / 3.5, size.Width, 0), XStringFormats.Center);
            gfx.DrawPath(new XPen(pen.Color, 3), brush, path);
        }
Exemplo n.º 11
0
        public void FillPath(Brush b, GraphicsPath roundrect)
        {
            var brush = GetXBrush(b);

            if (brush != null)
            {
                var path = new XGraphicsPath(roundrect.PathPoints, roundrect.PathTypes, (XFillMode)roundrect.FillMode);
                g.DrawPath(brush, path);
            }
        }
Exemplo n.º 12
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);
                }
            }
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        private void DrawPathAlternateAndWinding(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "DrawPath (alternate / winding)");
            XPen          pen           = new XPen(XColors.Navy, 2.5);
            XGraphicsPath xGraphicsPath = new XGraphicsPath();

            xGraphicsPath.FillMode = XFillMode.Alternate;
            xGraphicsPath.AddLine(10, 130, 10, 40);
            xGraphicsPath.AddBeziers(new XPoint[]
            {
                new XPoint(10.0, 40.0),
                new XPoint(30.0, 0.0),
                new XPoint(40.0, 20.0),
                new XPoint(60.0, 40.0),
                new XPoint(80.0, 60.0),
                new XPoint(100.0, 60.0),
                new XPoint(120.0, 40.0)
            });
            xGraphicsPath.AddLine(120, 40, 120, 130);
            xGraphicsPath.CloseFigure();
            xGraphicsPath.AddEllipse(40, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, xGraphicsPath);
            xGraphicsPath          = new XGraphicsPath();
            xGraphicsPath.FillMode = XFillMode.Winding;
            xGraphicsPath.AddLine(130, 130, 130, 40);
            xGraphicsPath.AddBeziers(new XPoint[]
            {
                new XPoint(130.0, 40.0),
                new XPoint(150.0, 0.0),
                new XPoint(160.0, 20.0),
                new XPoint(180.0, 40.0),
                new XPoint(200.0, 60.0),
                new XPoint(220.0, 60.0),
                new XPoint(240.0, 40.0)
            });
            xGraphicsPath.AddLine(240, 40, 240, 130);
            xGraphicsPath.CloseFigure();
            xGraphicsPath.AddEllipse(160, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, xGraphicsPath);
            base.EndBox(gfx);
        }
Exemplo n.º 15
0
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            XGraphicsPath path = new XGraphicsPath();

            path.AddLine(50, 150, 50, 100);
            path.AddArc(50, 50, 100, 100, -180, 180);
            path.AddLine(150, 70, 200, 70);
            path.AddLine(200, 70, 200, 150);
            path.CloseFigure();
            gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        private void DrawPathOpen(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "DrawPath (open)");
            XPen xPen = new XPen(XColors.Navy, 3.1415926535897931);

            xPen.DashStyle = XDashStyle.Dash;
            XGraphicsPath xGraphicsPath = new XGraphicsPath();

            xGraphicsPath.AddLine(10, 120, 50, 60);
            xGraphicsPath.AddArc(50, 20, 110, 80, 180, 180);
            xGraphicsPath.AddLine(160, 60, 220, 100);
            gfx.DrawPath(xPen, xGraphicsPath);
            base.EndBox(gfx);
        }
Exemplo n.º 18
0
        private void DrawVectorLayer(XGraphics gfx, Map map, double scaleFactor, VectorLayer lyr, string lineColor, double lineWidth, string fillColor)
        {
            TransformsProvider tp      = new TransformsProvider(gfx);
            BoundingBox        geombox = map.GetExtents();

            XPen        xp = new XPen(XColor.FromName(lineColor), lineWidth);
            XSolidBrush xb = new XSolidBrush(XColor.FromName(fillColor));

            foreach (Geometry geom in (lyr as VectorLayer).DataSource.GetGeometriesInView(geombox))
            {
                if ((geom) is MultiLineString)
                {
                    XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiLineString)geom, geombox);
                    this._geomCache.Add(new PDFGeom(g, xp, null));
                    gfx.DrawPath(xp, g);
                }
                if ((geom) is MultiPolygon)
                {
                    XGraphicsPath g = tp.TransformGeom(scaleFactor, (MultiPolygon)geom, geombox);
                    this._geomCache.Add(new PDFGeom(g, xp, xb));
                    gfx.DrawPath(xp, xb, g);
                }
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Converts text to path.
        /// </summary>
        void DrawGlyphs(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "Draw Glyphs");

#if CORE
            DrawMessage(gfx, "AddString is not implemented in PDFsharp Core.");
#else
            var path = new XGraphicsPath();
            // AddString is not implemented int PDFsharp Core.
            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);
#endif

            EndBox(gfx);
        }
Exemplo n.º 20
0
        void RenderOpenPath(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

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

            pen.DashStyle = XDashStyle.Dash;

            XGraphicsPath path = new XGraphicsPath();

            path.AddLine(10, 120, 50, 60);
            path.AddArc(50, 20, 110, 80, 180, 180);
            path.AddLine(160, 60, 220, 100);
            gfx.DrawPath(pen, path);
        }
Exemplo n.º 21
0
        public override void RenderPage(XGraphics gfx)
        {
            base.RenderPage(gfx);

            XGraphicsPath path = new XGraphicsPath();

            path.AddLine(50, 150, 50, 100);
            path.AddArc(50, 50, 100, 100, -180, 180);
            path.AddLine(150, 70, 200, 70);
            path.AddLine(200, 70, 200, 150);
            path.CloseFigure();
            XPen pen = new XPen(XColors.Red, 50);

            path.Widen(pen, new XMatrix(), 3);
            path.FillMode = this.properties.General.FillMode;
            gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path);
        }
Exemplo n.º 22
0
        static void DrawPathOpen(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawPath (open)");

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

            pen.DashStyle = XDashStyle.Dash;

            XGraphicsPath path = new XGraphicsPath();

            path.AddLine(10, 120, 50, 60);
            path.AddArc(50, 20, 110, 80, 180, 180);
            path.AddLine(160, 60, 220, 100);
            gfx.DrawPath(pen, path);

            EndBox(gfx);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Strokes a closed path.
        /// </summary>
        void DrawPathClosed(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawPath (closed)");

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

            pen.DashStyle = XDashStyle.Dash;

            XGraphicsPath path = new XGraphicsPath();

            path.AddLine(10, 120, 50, 60);
            path.AddArc(50, 20, 110, 80, 180, 180);
            path.AddLine(160, 60, 220, 100);
            path.CloseFigure();
            gfx.DrawPath(pen, path);

            EndBox(gfx);
        }
Exemplo n.º 25
0
        void RenderAlternatePath(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 20);

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

            // Alternate fill mode
            XGraphicsPath path = new XGraphicsPath();

            path.FillMode = XFillMode.Alternate;
            path.AddLine(10, 130, 10, 40);
            path.AddBeziers(new XPoint[] { new XPoint(10, 40), new XPoint(30, 0), new XPoint(40, 20), new XPoint(60, 40),
                                           new XPoint(80, 60), new XPoint(100, 60), new XPoint(120, 40) });
            path.AddLine(120, 40, 120, 130);
            path.CloseFigure();
            path.AddEllipse(40, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, path);
        }
Exemplo n.º 26
0
 private static void DrawLineCurveInternal(XGraphics gfx, XPen pen, bool isStroked, ref XPoint pt1, ref XPoint pt2, double curvature, Core2D.Style.CurveOrientation orientation, Core2D.Shape.PointAlignment pt1a, Core2D.Shape.PointAlignment pt2a)
 {
     if (isStroked)
     {
         var    path = new XGraphicsPath();
         double p1x  = pt1.X;
         double p1y  = pt1.Y;
         double p2x  = pt2.X;
         double p2y  = pt2.Y;
         Core2D.Shapes.XLineExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt1a, pt2a, ref p1x, ref p1y, ref p2x, ref p2y);
         path.AddBezier(
             pt1.X, pt1.Y,
             p1x, p1y,
             p2x, p2y,
             pt2.X, pt2.Y);
         gfx.DrawPath(pen, path);
     }
 }
Exemplo n.º 27
0
        void RenderWindingPath(XGraphics gfx)
        {
            gfx.TranslateTransform(15, 150);

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

            // Winding fill mode
            XGraphicsPath path = new XGraphicsPath();

            path          = new XGraphicsPath();
            path.FillMode = XFillMode.Winding;
            path.AddLine(130, 130, 130, 40);
            path.AddBeziers(new XPoint[] { new XPoint(130, 40), new XPoint(150, 0), new XPoint(160, 20), new XPoint(180, 40),
                                           new XPoint(200, 60), new XPoint(220, 60), new XPoint(240, 40) });
            path.AddLine(240, 40, 240, 130);
            path.CloseFigure();
            path.AddEllipse(160, 80, 50, 40);
            gfx.DrawPath(pen, XBrushes.DarkOrange, path);
        }
Exemplo n.º 28
0
        public static void DrawChevron(XGraphics graphics, PointF pos, float angle, float size, Brush fillBrush)
        {
            if (m_chevronPath == null)
            {
                var apex        = new PointF(0.5f, 0);
                var leftCorner  = new PointF(-0.5f, 0.5f);
                var rightCorner = new PointF(-0.5f, -0.5f);
                m_chevronPath = new XGraphicsPath();
                m_chevronPath.AddLine(apex, rightCorner);
                m_chevronPath.AddLine(rightCorner, leftCorner);
                m_chevronPath.AddLine(leftCorner, apex);
            }
            var state = graphics.Save();

            graphics.TranslateTransform(pos.X, pos.Y);
            graphics.RotateTransform(angle);
            graphics.ScaleTransform(size, size);
            graphics.DrawPath(fillBrush, m_chevronPath);
            graphics.Restore(state);
        }
Exemplo n.º 29
0
        public void Fill(XGraphics graphics, RectangleF rect, Brush fillBrush)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            RectangleF bounds = TransformedBounds;

            if (bounds.IntersectsWith(rect))
            {
                XGraphicsPath path = Path;

                using (RenderUtil.SaveState(graphics))
                {
                    XMatrix matrix = new XMatrix();
                    matrix.ScalePrepend(ScaleX, ScaleY);
                    matrix.TranslatePrepend(-OriginX, -OriginY);
                    graphics.MultiplyTransform(matrix);
                    graphics.DrawPath(fillBrush, path);
                }
            }
        }
Exemplo n.º 30
0
        public void Draw(XGraphics graphics, RectangleF rect, MapOptions options, XPen pen)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            RectangleF bounds = TransformedBounds;

            //graphics.DrawRectangle( new XPen(XColors.Yellow, 1), bounds.X, bounds.Y, bounds.Width, bounds.Height );

            if (bounds.IntersectsWith(rect))
            {
                XGraphicsPath path = Path;
                using (RenderUtil.SaveState(graphics))
                {
                    XMatrix matrix = new XMatrix();
                    matrix.ScalePrepend(ScaleX, ScaleY);
                    matrix.TranslatePrepend(-OriginX, -OriginY);
                    graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend);
                    graphics.DrawPath(pen, path);
                }
            }
        }