Example #1
1
    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);
    }
Example #2
1
    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);
    }
Example #3
1
    /// <summary>
    /// Strokes an open path.
    /// </summary>
    void DrawPathOpen(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawPath (open)");

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

      EndBox(gfx);
    }
    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);
    }
Example #5
1
    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);
    }
    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);
    }
Example #7
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);
    }
Example #8
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();
      path.Flatten(XMatrix.Identity, 0.1);
      gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path);
    }
Example #9
0
    void RenderClipPath(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XGraphicsPath path = new XGraphicsPath();
      path.AddString("Clip!", new XFontFamily("Verdana"), XFontStyle.Bold, 90, new XRect(0, 0, 250, 140),
        XStringFormats.Center);

      gfx.IntersectClip(path);

      gfx.DrawRectangle(XBrushes.LightSalmon, new XRect(0, 0, 10000, 10000));
      // Draw a beam of dotted lines
      XPen pen = XPens.DarkRed.Clone();
      pen.DashStyle = XDashStyle.Dot;
      for (double r = 0; r <= 90; r += 0.5)
        gfx.DrawLine(pen, 0, 0, 1000 * Math.Cos(r / 90 * Math.PI), 1000 * Math.Sin(r / 90 * Math.PI));
    }
    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);
    }
Example #11
0
        public static void AddLine(XGraphicsPath path, LineSegment segment, Random random, bool straightEdges)
        {
            if (Settings.HandDrawn && !straightEdges)
              {
            var dx = segment.End.X - segment.Start.X;
            var dy = segment.End.Y - segment.Start.Y;
            var distance = (float) Math.Sqrt(dx*dx + dy*dy);
            var points = random.Next(Math.Max(3, (int) (distance/15)), Math.Max(6, (int) (distance/8)));
            var lines = points - 1;
            var last = segment.Start;
            for (var line = 0; line < lines; ++line)
            {
              Vector next;
              if (line == 0)
              {
            next = last;
              }
              else if (line == lines - 1)
              {
            next = segment.End;
              }
              else
              {
            var fraction = line/(float) (lines - 1);
            var x = segment.Start.X + (segment.End.X - segment.Start.X)*fraction;
            var y = segment.Start.Y + (segment.End.Y - segment.Start.Y)*fraction;

            x += random.Next(-1, 2);
            y += random.Next(-1, 2);
            next = new Vector(x, y);
              }

              path.AddLine(last.ToPointF(), next.ToPointF());
              last = next;
            }
              }
              else
              {
            path.AddLine(segment.Start.ToPointF(), segment.End.ToPointF());
              }
        }
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

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

      // Add the outline of the glyphs of the word 'Clip' to the path
      path.AddString("Clip!", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 250, new XPoint(30, 100), XStringFormats.Default);

#if DEBUG_
      gfx.WriteComment("SetClip");
#endif
      // Set the path as clip path
      gfx.IntersectClip(path);
#if DEBUG_
      gfx.WriteComment("Random lines");
#endif
      // Draw some random lines to show that clipping happens
      Random rnd = new Random(42);
      for (int idx = 0; idx < 300; idx++)
        gfx.DrawLine(properties.Pen2.Pen, rnd.Next(600), rnd.Next(500), rnd.Next(600), rnd.Next(500));
    }
Example #13
0
        internal void Render(XUnit x, XUnit y, XUnit width, XUnit height, RoundedCorner roundedCorner)
        {
            // If there is no rounded corner, we can use the usual Render method.
            if (roundedCorner == RoundedCorner.None)
            {
                Render(x, y, width, height);
                return;
            }

            if (_shading == null || _brush == null)
                return;

            XGraphicsPath path = new XGraphicsPath();

            switch (roundedCorner)
            {
                case RoundedCorner.TopLeft:
                    path.AddArc(new XRect(x, y, width * 2, height * 2), 180, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x + width, y), new XPoint(x + width, y + height));
                    break;
                case RoundedCorner.TopRight:
                    path.AddArc(new XRect(x - width, y, width * 2, height * 2), 270, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x + width, y + height), new XPoint(x, y + height));
                    break;
                case RoundedCorner.BottomRight:
                    path.AddArc(new XRect(x - width, y - height, width * 2, height * 2), 0, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x, y + height), new XPoint(x, y));
                    break;
                case RoundedCorner.BottomLeft:
                    path.AddArc(new XRect(x, y - height, width * 2, height * 2), 90, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x, y), new XPoint(x + width, y));
                    break;
            }

            path.CloseFigure();
            _gfx.DrawPath(_brush, path);
        }
Example #14
0
    // ----- stroke and fill -----

    /// <summary>
    /// Draws a graphical path.
    /// </summary>
    public void DrawPath(XPen pen, XBrush brush, XGraphicsPath path)
    {
      if (pen == null && brush == null)
        throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);
      if (path == null)
        throw new ArgumentNullException("path");

      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
        {
          if (brush != null)
            this.gfx.FillPath(brush.RealizeGdiBrush(), path.gdipPath);
          if (pen != null)
            this.gfx.DrawPath(pen.RealizeGdiPen(), path.gdipPath);
        }
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
        {
          System.Windows.Media.Brush wpfBrush = brush != null ? brush.RealizeWpfBrush() : null;
          System.Windows.Media.Pen wpfPen = pen != null ? pen.RealizeWpfPen() : null;
          this.dc.DrawGeometry(wpfBrush, wpfPen, path.pathGeometry);
        }
#endif
      }

      if (this.renderer != null)
        this.renderer.DrawPath(pen, brush, path);
    }
Example #15
0
    // ----- fill -----

    /// <summary>
    /// Draws a graphical path.
    /// </summary>
    public void DrawPath(XBrush brush, XGraphicsPath path)
    {
      if (brush == null)
        throw new ArgumentNullException("brush");
      if (path == null)
        throw new ArgumentNullException("path");

      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
          this.gfx.FillPath(brush.RealizeGdiBrush(), path.gdipPath);
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
          this.dc.DrawGeometry(brush.RealizeWpfBrush(), null, path.pathGeometry);
#endif
      }

      if (this.renderer != null)
        this.renderer.DrawPath(null, brush, path);
    }
Example #16
0
    // ----- DrawPath -----------------------------------------------------------------------------

    // ----- stroke -----

    /// <summary>
    /// Draws a graphical path.
    /// </summary>
    public void DrawPath(XPen pen, XGraphicsPath path)
    {
      if (pen == null)
        throw new ArgumentNullException("pen");
      if (path == null)
        throw new ArgumentNullException("path");

      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
          this.gfx.DrawPath(pen.RealizeGdiPen(), path.gdipPath);
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
          this.dc.DrawGeometry(null, pen.RealizeWpfPen(), path.pathGeometry);
#endif
      }

      if (this.renderer != null)
        this.renderer.DrawPath(pen, null, path);
    }
 /// <summary>
 /// Draws a line specified by path.
 /// </summary>
 public void DrawPath(XGraphicsPath path)
 {
   if (this.pen != null)
     this.gfx.DrawPath(this.pen, path);
 }
Example #18
0
    static void Main()
    {
      const string watermark = "PDFsharp";
      const int emSize = 150;

      // Get a fresh copy of the sample PDF file
      const string filename = "Portable Document Format.pdf";
      File.Copy(Path.Combine("../../../../../PDFs/", filename),
        Path.Combine(Directory.GetCurrentDirectory(), filename), true);

      // Create the font for drawing the watermark
      XFont font = new XFont("Times New Roman", emSize, XFontStyle.BoldItalic);

      // Open an existing document for editing and loop through its pages
      PdfDocument document = PdfReader.Open(filename);

      // Set version to PDF 1.4 (Acrobat 5) because we use transparency.
      if (document.Version < 14)
        document.Version = 14;

      for (int idx = 0; idx < document.Pages.Count; idx++)
      {
        //if (idx == 1) break;
        PdfPage page = document.Pages[idx];

        switch (idx % 3)
        {
          case 0:
            {
              // Variation 1: Draw watermark as text string

              // Get an XGraphics object for drawing beneath the existing content
              XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend);

#if true_
            // Fill background with linear gradient color
            XRect rect = page.MediaBox.ToXRect();
            XLinearGradientBrush gbrush = new XLinearGradientBrush(rect,
              XColors.LightSalmon, XColors.WhiteSmoke, XLinearGradientMode.Vertical);
            gfx.DrawRectangle(gbrush, rect);
#endif

              // 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(page.Width / 2, page.Height / 2);
              gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
              gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

              // 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);
            }
            break;

          case 1:
            {
              // Variation 2: Draw watermark as outlined graphical path

              // 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(page.Width / 2, page.Height / 2);
              gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
              gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

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

              // Add the text to the path
              path.AddString(watermark, font.FontFamily, XFontStyle.BoldItalic, 150,
                new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
                XStringFormats.Default);

              // Create a dimmed red pen
              XPen pen = new XPen(XColor.FromArgb(128, 255, 0, 0), 2);

              // Stroke the outline of the path
              gfx.DrawPath(pen, path);
            }
            break;

          case 2:
            {
              // Variation 3: Draw watermark as transparent graphical path above text

              // Get an XGraphics object for drawing above the existing content
              XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append);

              // 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(page.Width / 2, page.Height / 2);
              gfx.RotateTransform(-Math.Atan(page.Height / page.Width) * 180 / Math.PI);
              gfx.TranslateTransform(-page.Width / 2, -page.Height / 2);

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

              // Add the text to the path
              path.AddString(watermark, font.FontFamily, XFontStyle.BoldItalic, 150,
                new XPoint((page.Width - size.Width) / 2, (page.Height - size.Height) / 2),
                XStringFormats.Default);

              // 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
              gfx.DrawPath(pen, brush, path);
            }
            break;
        }
      }
      // Save the document...
      document.Save(filename);
      // ...and start a viewer
      Process.Start(filename);
    }
Example #19
0
 /// <summary>
 /// Updates the clip region of this XGraphics to the intersection of the 
 /// current clip region and the specified rectangle.
 /// </summary>
 public void IntersectClip(XRect rect)
 {
   XGraphicsPath path = new XGraphicsPath();
   path.AddRectangle(rect);
   IntersectClip(path);
 }
Example #20
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="bezier"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, Kaliber3D.Render.XBezier bezier, double dx, double dy, ImmutableArray<Kaliber3D.Render.ShapeProperty> db, Kaliber3D.Render.Record r)
        {
            var _gfx = gfx as XGraphics;

            if (bezier.IsFilled)
            {
                var path = new XGraphicsPath();
                path.AddBezier(
                    _scaleToPage(bezier.Point1.X + dx),
                    _scaleToPage(bezier.Point1.Y + dy),
                    _scaleToPage(bezier.Point2.X + dx),
                    _scaleToPage(bezier.Point2.Y + dy),
                    _scaleToPage(bezier.Point3.X + dx),
                    _scaleToPage(bezier.Point3.Y + dy),
                    _scaleToPage(bezier.Point4.X + dx),
                    _scaleToPage(bezier.Point4.Y + dy));

                if (bezier.IsStroked)
                {
                    _gfx.DrawPath(
                        ToXPen(bezier.Style, _scaleToPage),
                        ToXSolidBrush(bezier.Style.Fill),
                        path);
                }
                else
                {
                    _gfx.DrawPath(
                        ToXSolidBrush(bezier.Style.Fill),
                        path);
                }
            }
            else
            {
                if (bezier.IsStroked)
                {
                    _gfx.DrawBezier(
                        ToXPen(bezier.Style, _scaleToPage),
                        _scaleToPage(bezier.Point1.X + dx),
                        _scaleToPage(bezier.Point1.Y + dy),
                        _scaleToPage(bezier.Point2.X + dx),
                        _scaleToPage(bezier.Point2.Y + dy),
                        _scaleToPage(bezier.Point3.X + dx),
                        _scaleToPage(bezier.Point3.Y + dy),
                        _scaleToPage(bezier.Point4.X + dx),
                        _scaleToPage(bezier.Point4.Y + dy));
                }
            }
        }
Example #21
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="arc"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, Kaliber3D.Render.XArc arc, double dx, double dy, ImmutableArray<Kaliber3D.Render.ShapeProperty> db, Kaliber3D.Render.Record r)
        {
            var _gfx = gfx as XGraphics;

            var a = Kaliber3D.Render.GdiArc.FromXArc(arc, dx, dy);

            if (arc.IsFilled)
            {
                var path = new XGraphicsPath();
                // NOTE: Not implemented in PdfSharp Core version.
                path.AddArc(
                    _scaleToPage(a.X),
                    _scaleToPage(a.Y),
                    _scaleToPage(a.Width),
                    _scaleToPage(a.Height),
                    a.StartAngle,
                    a.SweepAngle);

                if (arc.IsStroked)
                {
                    _gfx.DrawPath(
                        ToXPen(arc.Style, _scaleToPage),
                        ToXSolidBrush(arc.Style.Fill),
                        path);
                }
                else
                {
                    _gfx.DrawPath(
                        ToXSolidBrush(arc.Style.Fill),
                        path);
                }
            }
            else
            {
                if (arc.IsStroked)
                {
                    _gfx.DrawArc(
                        ToXPen(arc.Style, _scaleToPage),
                        _scaleToPage(a.X),
                        _scaleToPage(a.Y),
                        _scaleToPage(a.Width),
                        _scaleToPage(a.Height),
                        a.StartAngle,
                        a.SweepAngle);
                }
            }
        }
 internal XGraphicsPathInternals(XGraphicsPath path)
 {
     this.path = path;
 }
Example #23
0
 public XGraphicsPath Path()
 {
     var path = new XGraphicsPath();
     //m_items.Add(path);
     return path;
 }
Example #24
0
    /// <summary>
    /// Draws an alternating and a winding path.
    /// </summary>
    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);
    }
Example #25
0
 internal XGraphicsPathInternals(XGraphicsPath path)
 {
     _path = path;
 }
Example #26
0
        public static PDF.XGraphicsPath ToXGraphicsPath(this IPathGeometry pg, Func <double, double> scale)
        {
            var gp = new PDF.XGraphicsPath()
            {
                FillMode = pg.FillRule == FillRule.EvenOdd ? PDF.XFillMode.Alternate : PDF.XFillMode.Winding
            };

            foreach (var pf in pg.Figures)
            {
                var startPoint = pf.StartPoint;

                foreach (var segment in pf.Segments)
                {
                    if (segment is IArcSegment arcSegment)
                    {
#if WPF
                        var point1 = new PDF.XPoint(
                            scale(startPoint.X),
                            scale(startPoint.Y));
                        var point2 = new PDF.XPoint(
                            scale(arcSegment.Point.X),
                            scale(arcSegment.Point.Y));
                        var size = new PDF.XSize(
                            scale(arcSegment.Size.Width),
                            scale(arcSegment.Size.Height));
                        gp.AddArc(
                            point1,
                            point2,
                            size, arcSegment.RotationAngle, arcSegment.IsLargeArc,
                            arcSegment.SweepDirection == SweepDirection.Clockwise ? PDF.XSweepDirection.Clockwise : PDF.XSweepDirection.Counterclockwise);
                        startPoint = arcSegment.Point;
#else
                        // TODO: Convert WPF/SVG elliptical arc segment format to GDI+ bezier curves.
                        startPoint = arcSegment.Point;
#endif
                    }
                    else if (segment is ICubicBezierSegment cubicBezierSegment)
                    {
                        gp.AddBezier(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(cubicBezierSegment.Point1.X),
                            scale(cubicBezierSegment.Point1.Y),
                            scale(cubicBezierSegment.Point2.X),
                            scale(cubicBezierSegment.Point2.Y),
                            scale(cubicBezierSegment.Point3.X),
                            scale(cubicBezierSegment.Point3.Y));
                        startPoint = cubicBezierSegment.Point3;
                    }
                    else if (segment is ILineSegment)
                    {
                        var lineSegment = segment as ILineSegment;
                        gp.AddLine(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(lineSegment.Point.X),
                            scale(lineSegment.Point.Y));
                        startPoint = lineSegment.Point;
                    }
                    else if (segment is IQuadraticBezierSegment quadraticBezierSegment)
                    {
                        var    p1 = startPoint;
                        var    p2 = quadraticBezierSegment.Point1;
                        var    p3 = quadraticBezierSegment.Point2;
                        double x1 = p1.X;
                        double y1 = p1.Y;
                        double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                        double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                        double x3 = x2 + (p3.X - p1.X) / 3.0;
                        double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                        double x4 = p3.X;
                        double y4 = p3.Y;
                        gp.AddBezier(
                            scale(x1),
                            scale(y1),
                            scale(x2),
                            scale(y2),
                            scale(x3),
                            scale(y3),
                            scale(x4),
                            scale(y4));
                        startPoint = quadraticBezierSegment.Point2;
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                    }
                }

                if (pf.IsClosed)
                {
                    gp.CloseFigure();
                }
                else
                {
                    gp.StartFigure();
                }
            }

            return(gp);
        }
Example #27
0
 public void SetClip(XGraphicsPath path)
 {
   throw new InvalidOperationException("Function is obsolete. Use IntersectClip.");
   //SetClip(path, XCombineMode.Replace);
 }
Example #28
0
    public void SetClip(XGraphicsPath path, XCombineMode combineMode)
    {
      throw new InvalidOperationException("Function is obsolete. Use IntersectClip.");
      //      if (path == null)
      //        throw new ArgumentNullException("path");

      //      if (combineMode != XCombineMode.Replace && combineMode != XCombineMode.Intersect)
      //        throw new ArgumentException("Only XCombineMode.Replace and XCombineMode.Intersect are currently supported by PDFsharp.", "combineMode");

      //      if (this.drawGraphics)
      //      {
      //#if GDI
      //        if (this.targetContext == XGraphicTargetContext.GDI)
      //          this.gfx.SetClip(path.gdipPath, (CombineMode)combineMode);
      //#endif
      //#if WPF
      //        if (this.targetContext == XGraphicTargetContext.GDI)
      //          GetType();
      //        //this.gfx.Transform = (Matrix)this.defaultViewMatrix;
      //#endif
      //      }

      //if (this.renderer != null)
      //  this.renderer.SetClip(path, combineMode);
    }
Example #29
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="qbezier"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, Kaliber3D.Render.XQBezier qbezier, double dx, double dy, ImmutableArray<Kaliber3D.Render.ShapeProperty> db, Kaliber3D.Render.Record r)
        {
            var _gfx = gfx as XGraphics;

            double x1 = qbezier.Point1.X;
            double y1 = qbezier.Point1.Y;
            double x2 = qbezier.Point1.X + (2.0 * (qbezier.Point2.X - qbezier.Point1.X)) / 3.0;
            double y2 = qbezier.Point1.Y + (2.0 * (qbezier.Point2.Y - qbezier.Point1.Y)) / 3.0;
            double x3 = x2 + (qbezier.Point3.X - qbezier.Point1.X) / 3.0;
            double y3 = y2 + (qbezier.Point3.Y - qbezier.Point1.Y) / 3.0;
            double x4 = qbezier.Point3.X;
            double y4 = qbezier.Point3.Y;

            if (qbezier.IsFilled)
            {
                var path = new XGraphicsPath();
                path.AddBezier(
                    _scaleToPage(x1 + dx),
                    _scaleToPage(y1 + dy),
                    _scaleToPage(x2 + dx),
                    _scaleToPage(y2 + dy),
                    _scaleToPage(x3 + dx),
                    _scaleToPage(y3 + dy),
                    _scaleToPage(x4 + dx),
                    _scaleToPage(y4 + dy));

                if (qbezier.IsStroked)
                {
                    _gfx.DrawPath(
                        ToXPen(qbezier.Style, _scaleToPage),
                        ToXSolidBrush(qbezier.Style.Fill),
                        path);
                }
                else
                {
                    _gfx.DrawPath(
                        ToXSolidBrush(qbezier.Style.Fill),
                        path);
                }
            }
            else
            {
                if (qbezier.IsStroked)
                {
                    _gfx.DrawBezier(
                        ToXPen(qbezier.Style, _scaleToPage),
                        _scaleToPage(x1 + dx),
                        _scaleToPage(y1 + dy),
                        _scaleToPage(x2 + dx),
                        _scaleToPage(y2 + dy),
                        _scaleToPage(x3 + dx),
                        _scaleToPage(y3 + dy),
                        _scaleToPage(x4 + dx),
                        _scaleToPage(y4 + dy));
                }
            }
        }
Example #30
0
    /// <summary>
    /// Updates the clip region of this XGraphics to the intersection of the 
    /// current clip region and the specified graphical path.
    /// </summary>
    public void IntersectClip(XGraphicsPath path)
    {
      if (path == null)
        throw new ArgumentNullException("path");

      if (this.drawGraphics)
      {
#if GDI && WPF
        if (this.targetContext == XGraphicTargetContext.GDI)
        {
          //this.gfx.SetClip(path.gdipPath, CombineMode.Intersect);
          this.gfx.SetClip(path.gdipPath, CombineMode.Intersect);
        }
        else
        {
          //this.dc.p.renderer.SetClip(path, XCombineMode.Intersect);
          this.gsStack.Current.SetClip(path.pathGeometry);
        }
#endif
#if GDI && !WPF
        if (this.targetContext == XGraphicTargetContext.GDI)
          this.gfx.SetClip(path.gdipPath, CombineMode.Intersect);
#endif
#if WPF && !GDI
        if (this.targetContext == XGraphicTargetContext.WPF)
          this.gsStack.Current.SetClip(path.pathGeometry);
#endif
      }
      if (this.renderer != null)
        this.renderer.SetClip(path, XCombineMode.Intersect);
    }
        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);
                }
            }
        }
Example #32
0
        private static void DrawMicroBorders(RenderContext ctx, BorderLayer layer)
        {
            const byte FILL_ALPHA = 64;

            float[] edgex, edgey;
            PathUtil.PathType borderPathType = ctx.styles.microBorderStyle == MicroBorderStyle.Square ?
                PathUtil.PathType.Square : PathUtil.PathType.Hex;
            RenderUtil.HexEdges(borderPathType, out edgex, out edgey);

            XSolidBrush solidBrush = new XSolidBrush();
            XPen pen = new XPen(XColor.Empty);
            ctx.styles.microBorders.pen.Apply(ref pen);

            foreach (Sector sector in ctx.selector.Sectors)
            {
                XGraphicsPath sectorClipPath = null;

                using (RenderUtil.SaveState(ctx.graphics))
                {
                    // This looks craptacular for Candy style borders :(
                    if (ctx.clipOutsectorBorders &&
                        (layer == BorderLayer.Fill || ctx.styles.microBorderStyle != MicroBorderStyle.Curve))
                    {
                        Sector.ClipPath clip = sector.ComputeClipPath(borderPathType);
                        if (!ctx.tileRect.IntersectsWith(clip.bounds))
                            continue;

                        sectorClipPath = new XGraphicsPath(clip.clipPathPoints, clip.clipPathPointTypes, XFillMode.Alternate);
                        if (sectorClipPath != null)
                            ctx.graphics.IntersectClip(sectorClipPath);
                    }

                    ctx.graphics.SmoothingMode = XSmoothingMode.AntiAlias;

                    foreach (Border border in sector.Borders)
                    {
                        BorderPath borderPath = border.ComputeGraphicsPath(sector, borderPathType);

                        XGraphicsPath drawPath = borderPath.borderPathPoints.Length > 0 ? new XGraphicsPath(borderPath.borderPathPoints, borderPath.borderPathTypes, XFillMode.Alternate) : null;
                        XGraphicsPath clipPath = new XGraphicsPath(borderPath.clipPathPoints, borderPath.clipPathTypes, XFillMode.Alternate);

                        Color? borderColor = border.Color;
                        LineStyle? borderStyle = border.Style;

                        SectorStylesheet.StyleResult ssr = sector.ApplyStylesheet("border", border.Allegiance);
                        borderStyle = borderStyle ?? ssr.GetEnum<LineStyle>("style") ?? LineStyle.Solid;
                        borderColor = borderColor ?? ssr.GetColor("color") ?? ctx.styles.microBorders.pen.color;

                        if (layer == BorderLayer.Stroke && borderStyle.Value == LineStyle.None)
                            continue;

                        if (ctx.styles.grayscale ||
                            !ColorUtil.NoticeableDifference(borderColor.Value, ctx.styles.backgroundColor))
                        {
                            borderColor = ctx.styles.microBorders.pen.color; // default
                        }

                        pen.Color = borderColor.Value;
                        pen.DashStyle = LineStyleToDashStyle(borderStyle.Value);

                        if (ctx.styles.microBorderStyle != MicroBorderStyle.Curve)
                        {
                            // Clip to the path itself - this means adjacent borders don't clash
                            using (RenderUtil.SaveState(ctx.graphics))
                            {
                                ctx.graphics.IntersectClip(clipPath);
                                if (layer == BorderLayer.Fill)
                                {
                                    solidBrush.Color = Color.FromArgb(FILL_ALPHA, borderColor.Value);
                                    ctx.graphics.DrawPath(solidBrush, clipPath);
                                }

                                if (layer == BorderLayer.Stroke && drawPath != null)
                                    ctx.graphics.DrawPath(pen, drawPath);
                            }
                        }
                        else
                        {
                            if (layer == BorderLayer.Fill)
                            {
                                solidBrush.Color = Color.FromArgb(FILL_ALPHA, borderColor.Value);
                                ctx.graphics.DrawClosedCurve(solidBrush, borderPath.clipPathPoints);
                            }

                            if (layer == BorderLayer.Stroke)
                            {
                                foreach (PointF[] curve in borderPath.curvePoints)
                                {
                                    // TODO: Investigate DrawClosedCurve to handle endings
                                    // Would need to have path computer tell whether
                                    // or not the path was actually a closed loop
                                    // Can do it by clipping borders to sector, but that loses
                                    // bottom/right overlaps
                                    ctx.graphics.DrawCurve(pen, curve, 0.6f);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #33
0
    /// <summary>
    /// Draws a rectangles with round corners.
    /// </summary>
    public void DrawRoundedRectangle(XPen pen, XBrush brush, double x, double y, double width, double height,
      double ellipseWidth, double ellipseHeight)
    {
      if (pen == null && brush == null)
        throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);

      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
        {
          XGraphicsPath path = new XGraphicsPath();
          path.AddRoundedRectangle(x, y, width, height, ellipseWidth, ellipseHeight);
          DrawPath(pen, brush, path);
        }
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
        {
          this.dc.DrawRoundedRectangle(
            brush != null ? brush.RealizeWpfBrush() : null,
            pen != null ? pen.RealizeWpfPen() : null,
            new Rect(x, y, width, height), ellipseWidth / 2, ellipseHeight / 2);
        }
#endif
      }

      if (this.renderer != null)
        this.renderer.DrawRoundedRectangle(pen, brush, x, y, width, height, ellipseWidth, ellipseHeight);
    }
Example #34
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pg"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static PDF.XGraphicsPath ToXGraphicsPath(this IPathGeometry pg, double dx, double dy, Func <double, double> scale)
        {
            var gp = new PDF.XGraphicsPath()
            {
                FillMode = pg.FillRule == FillRule.EvenOdd ? PDF.XFillMode.Alternate : PDF.XFillMode.Winding
            };

            foreach (var pf in pg.Figures)
            {
                var startPoint = pf.StartPoint;

                foreach (var segment in pf.Segments)
                {
                    if (segment is IArcSegment arcSegment)
                    {
#if WPF
                        var point1 = new PDF.XPoint(
                            scale(startPoint.X + dx),
                            scale(startPoint.Y + dy));
                        var point2 = new PDF.XPoint(
                            scale(arcSegment.Point.X + dx),
                            scale(arcSegment.Point.Y + dy));
                        var size = new PDF.XSize(
                            scale(arcSegment.Size.Width),
                            scale(arcSegment.Size.Height));
                        gp.AddArc(
                            point1,
                            point2,
                            size, arcSegment.RotationAngle, arcSegment.IsLargeArc,
                            arcSegment.SweepDirection == SweepDirection.Clockwise ? PDF.XSweepDirection.Clockwise : PDF.XSweepDirection.Counterclockwise);
                        startPoint = arcSegment.Point;
#else
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                        // TODO: Convert WPF/SVG elliptical arc segment format to GDI+ bezier curves.
                        //startPoint = arcSegment.Point;
#endif
                    }
                    else if (segment is ICubicBezierSegment cubicBezierSegment)
                    {
                        gp.AddBezier(
                            scale(startPoint.X + dx),
                            scale(startPoint.Y + dy),
                            scale(cubicBezierSegment.Point1.X + dx),
                            scale(cubicBezierSegment.Point1.Y + dy),
                            scale(cubicBezierSegment.Point2.X + dx),
                            scale(cubicBezierSegment.Point2.Y + dy),
                            scale(cubicBezierSegment.Point3.X + dx),
                            scale(cubicBezierSegment.Point3.Y + dy));
                        startPoint = cubicBezierSegment.Point3;
                    }
                    else if (segment is ILineSegment)
                    {
                        var lineSegment = segment as ILineSegment;
                        gp.AddLine(
                            scale(startPoint.X + dx),
                            scale(startPoint.Y + dy),
                            scale(lineSegment.Point.X + dx),
                            scale(lineSegment.Point.Y + dy));
                        startPoint = lineSegment.Point;
                    }
                    else if (segment is IPolyCubicBezierSegment polyCubicBezierSegment)
                    {
                        if (polyCubicBezierSegment.Points.Length >= 3)
                        {
                            gp.AddBezier(
                                scale(startPoint.X + dx),
                                scale(startPoint.Y + dy),
                                scale(polyCubicBezierSegment.Points[0].X + dx),
                                scale(polyCubicBezierSegment.Points[0].Y + dy),
                                scale(polyCubicBezierSegment.Points[1].X + dx),
                                scale(polyCubicBezierSegment.Points[1].Y + dy),
                                scale(polyCubicBezierSegment.Points[2].X + dx),
                                scale(polyCubicBezierSegment.Points[2].Y + dy));
                        }

                        if (polyCubicBezierSegment.Points.Length > 3 &&
                            polyCubicBezierSegment.Points.Length % 3 == 0)
                        {
                            for (int i = 3; i < polyCubicBezierSegment.Points.Length; i += 3)
                            {
                                gp.AddBezier(
                                    scale(polyCubicBezierSegment.Points[i - 1].X + dx),
                                    scale(polyCubicBezierSegment.Points[i - 1].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i].X + dx),
                                    scale(polyCubicBezierSegment.Points[i].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i + 1].X + dx),
                                    scale(polyCubicBezierSegment.Points[i + 1].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i + 2].X + dx),
                                    scale(polyCubicBezierSegment.Points[i + 2].Y + dy));
                            }
                        }

                        startPoint = polyCubicBezierSegment.Points.Last();
                    }
                    else if (segment is IPolyLineSegment polyLineSegment)
                    {
                        if (polyLineSegment.Points.Length >= 1)
                        {
                            gp.AddLine(
                                scale(startPoint.X + dx),
                                scale(startPoint.Y + dy),
                                scale(polyLineSegment.Points[0].X + dx),
                                scale(polyLineSegment.Points[0].Y + dy));
                        }

                        if (polyLineSegment.Points.Length > 1)
                        {
                            for (int i = 1; i < polyLineSegment.Points.Length; i++)
                            {
                                gp.AddLine(
                                    scale(polyLineSegment.Points[i - 1].X + dx),
                                    scale(polyLineSegment.Points[i - 1].Y + dy),
                                    scale(polyLineSegment.Points[i].X + dx),
                                    scale(polyLineSegment.Points[i].Y + dy));
                            }
                        }

                        startPoint = polyLineSegment.Points.Last();
                    }
                    else if (segment is IPolyQuadraticBezierSegment polyQuadraticSegment)
                    {
                        if (polyQuadraticSegment.Points.Length >= 2)
                        {
                            var    p1 = startPoint;
                            var    p2 = polyQuadraticSegment.Points[0];
                            var    p3 = polyQuadraticSegment.Points[1];
                            double x1 = p1.X;
                            double y1 = p1.Y;
                            double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                            double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                            double x3 = x2 + (p3.X - p1.X) / 3.0;
                            double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                            double x4 = p3.X;
                            double y4 = p3.Y;
                            gp.AddBezier(
                                scale(x1 + dx),
                                scale(y1 + dy),
                                scale(x2 + dx),
                                scale(y2 + dy),
                                scale(x3 + dx),
                                scale(y3 + dy),
                                scale(x4 + dx),
                                scale(y4 + dy));
                        }

                        if (polyQuadraticSegment.Points.Length > 2 &&
                            polyQuadraticSegment.Points.Length % 2 == 0)
                        {
                            for (int i = 3; i < polyQuadraticSegment.Points.Length; i += 3)
                            {
                                var    p1 = polyQuadraticSegment.Points[i - 1];
                                var    p2 = polyQuadraticSegment.Points[i];
                                var    p3 = polyQuadraticSegment.Points[i + 1];
                                double x1 = p1.X;
                                double y1 = p1.Y;
                                double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                                double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                                double x3 = x2 + (p3.X - p1.X) / 3.0;
                                double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                                double x4 = p3.X;
                                double y4 = p3.Y;
                                gp.AddBezier(
                                    scale(x1 + dx),
                                    scale(y1 + dy),
                                    scale(x2 + dx),
                                    scale(y2 + dy),
                                    scale(x3 + dx),
                                    scale(y3 + dy),
                                    scale(x4 + dx),
                                    scale(y4 + dy));
                            }
                        }

                        startPoint = polyQuadraticSegment.Points.Last();
                    }
                    else if (segment is IQuadraticBezierSegment quadraticBezierSegment)
                    {
                        var    p1 = startPoint;
                        var    p2 = quadraticBezierSegment.Point1;
                        var    p3 = quadraticBezierSegment.Point2;
                        double x1 = p1.X;
                        double y1 = p1.Y;
                        double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                        double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                        double x3 = x2 + (p3.X - p1.X) / 3.0;
                        double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                        double x4 = p3.X;
                        double y4 = p3.Y;
                        gp.AddBezier(
                            scale(x1 + dx),
                            scale(y1 + dy),
                            scale(x2 + dx),
                            scale(y2 + dy),
                            scale(x3 + dx),
                            scale(y3 + dy),
                            scale(x4 + dx),
                            scale(y4 + dy));
                        startPoint = quadraticBezierSegment.Point2;
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                    }
                }

                if (pf.IsClosed)
                {
                    gp.CloseFigure();
                }
                else
                {
                    gp.StartFigure();
                }
            }

            return(gp);
        }
Example #35
0
        // ----- AddPath ------------------------------------------------------------------------------

        /// <summary>
        /// Adds the specified path to this path.
        /// </summary>
        public void AddPath(XGraphicsPath path, bool connect)
        {
            DiagnosticsHelper.HandleNotImplemented("XGraphicsPath.AddPath");
        }