コード例 #1
0
    /// <summary>
    /// Initializes a new instance of the <see cref="XGraphicsPath"/> class.
    /// </summary>
    public XGraphicsPath(PointF[] points, byte[] types, XFillMode fillMode)
    {
#if GDI
      this.gdipPath = new GraphicsPath(points, types, (FillMode)fillMode);
#endif
#if WPF
      this.pathGeometry = new PathGeometry();
      this.pathGeometry.FillRule = FillRule.EvenOdd;
#endif
    }
コード例 #2
0
ファイル: GeometryHelper.cs プロジェクト: mapilab/PDFsharp
        /// <summary>
        /// Creates a path geometry from a polygon.
        /// </summary>
        public static PolyLineSegment CreatePolyLineSegment(SysPoint[] points, XFillMode fillMode, bool closed)
        {
            PolyLineSegment seg   = new PolyLineSegment();
            int             count = points.Length;

            // For correct drawing the start point of the segment must not be the same as the first point.
            for (int idx = 1; idx < count; idx++)
            {
                seg.Points.Add(new SysPoint(points[idx].X, points[idx].Y));
            }
#if !SILVERLIGHT && !NETFX_CORE
            seg.IsStroked = true;
#endif
            return(seg);
        }
コード例 #3
0
ファイル: XGraphicsPath.cs プロジェクト: Core2D/PDFsharp
        /// <summary>
        /// Initializes a new instance of the <see cref="XGraphicsPath"/> class.
        /// </summary>
        public XGraphicsPath(PointF[] points, byte[] types, XFillMode fillMode)
        {
#if GDI
            try
            {
                Lock.EnterGdiPlus();
                _gdipPath = new GraphicsPath(points, types, (FillMode)fillMode);
            }
            finally { Lock.ExitGdiPlus(); }
#endif
#if WPF  // Is true only in Hybrid build.
            _pathGeometry = new PathGeometry();
            _pathGeometry.FillRule = FillRule.EvenOdd;
#endif
        }
コード例 #4
0
 /// <summary>
 /// Creates a path geometry form a polygon.
 /// </summary>
 public static PathGeometry CreatePolygonGeometry(System.Windows.Point[] points, XFillMode fillMode, bool closed)
 {
   PolyLineSegment seg = new PolyLineSegment();
   int count = points.Length;
   // For correct drawing the start point of the segment must not be the same as the first point
   for (int idx = 1; idx < count; idx++)
     seg.Points.Add(new System.Windows.Point(points[idx].X, points[idx].Y));
   seg.IsStroked = true;
   PathFigure fig = new PathFigure();
   fig.StartPoint = new System.Windows.Point(points[0].X, points[0].Y);
   fig.Segments.Add(seg);
   fig.IsClosed = closed;
   PathGeometry geo = new PathGeometry();
   geo.FillRule = fillMode == XFillMode.Winding ? FillRule.Nonzero : FillRule.EvenOdd;
   geo.Figures.Add(fig);
   return geo;
 }
コード例 #5
0
ファイル: GeometryHelper.cs プロジェクト: mapilab/PDFsharp
        /// <summary>
        /// Creates a path geometry from a polygon.
        /// </summary>
        public static PathGeometry CreatePolygonGeometry(SysPoint[] points, XFillMode fillMode, bool closed)
        {
            PolyLineSegment seg   = new PolyLineSegment();
            int             count = points.Length;

            // For correct drawing the start point of the segment must not be the same as the first point.
            for (int idx = 1; idx < count; idx++)
            {
                seg.Points.Add(new SysPoint(points[idx].X, points[idx].Y));
            }
#if !SILVERLIGHT && !NETFX_CORE
            seg.IsStroked = true;
#endif
            PathFigure fig = new PathFigure();
            fig.StartPoint = new SysPoint(points[0].X, points[0].Y);
            fig.Segments.Add(seg);
            fig.IsClosed = closed;
            PathGeometry geo = new PathGeometry();
            geo.FillRule = fillMode == XFillMode.Winding ? FillRule.Nonzero : FillRule.EvenOdd;
            geo.Figures.Add(fig);
            return(geo);
        }
コード例 #6
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
    // ----- fill -----

#if GDI
    /// <summary>
    /// Draws a polygon defined by an array of points.
    /// </summary>
    public void DrawPolygon(XBrush brush, System.Drawing.Point[] points, XFillMode fillmode)
    {
      DrawPolygon(brush, MakeXPointArray(points), fillmode);
    }
コード例 #7
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
    /// <summary>
    /// Draws a polygon defined by an array of points.
    /// </summary>
    public void DrawPolygon(XBrush brush, XPoint[] points, XFillMode fillmode)
    {
      if (brush == null)
        throw new ArgumentNullException("brush");
      if (points == null)
        throw new ArgumentNullException("points");
      if (points.Length < 2)
        throw new ArgumentException("points", PSSR.PointArrayAtLeast(2));

      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
          this.gfx.FillPolygon(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode);
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
        {
          this.dc.DrawGeometry(brush.RealizeWpfBrush(), null, GeometryHelper.CreatePolygonGeometry(MakePointArray(points), fillmode, true));
        }
#endif
      }

      if (this.renderer != null)
        this.renderer.DrawPolygon(null, brush, points, fillmode);
    }
コード例 #8
0
ファイル: XGraphics.cs プロジェクト: BackupTheBerlios/zp7-svn
    // ----- fill -----

    /// <summary>
    /// Draws a polygon defined by an array of points.
    /// </summary>
    public void DrawPolygon(XBrush brush, Point[] points, XFillMode fillmode)
    {
      DrawPolygon(brush, MakePointFArray(points), fillmode);
    }
コード例 #9
0
 public void DrawPolygon(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode)
 {
 }
コード例 #10
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
 /// <summary>
 /// Draws a closed cardinal spline defined by an array of points.
 /// </summary>
 public void DrawClosedCurve(XPen pen, XBrush brush, System.Windows.Point[] points, XFillMode fillmode)
 {
   DrawClosedCurve(pen, brush, MakeXPointArray(points), fillmode, 0.5);
 }
コード例 #11
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
 /// <summary>
 /// Draws a closed cardinal spline defined by an array of points.
 /// </summary>
 public void DrawClosedCurve(XPen pen, XBrush brush, PointF[] points, XFillMode fillmode, double tension)
 {
   DrawClosedCurve(pen, brush, MakeXPointArray(points), fillmode, tension);
 }
コード例 #12
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
    /// <summary>
    /// Draws a polygon defined by an array of points.
    /// </summary>
    public void DrawPolygon(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode)
    {
      if (pen == null && brush == null)
        throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);
      if (points == null)
        throw new ArgumentNullException("points");
      if (points.Length < 2)
        throw new ArgumentException("points", PSSR.PointArrayAtLeast(2));

      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
        {
          PointF[] pts = MakePointFArray(points);
          this.gfx.FillPolygon(brush.RealizeGdiBrush(), pts, (FillMode)fillmode);
          this.gfx.DrawPolygon(pen.RealizeGdiPen(), pts);
        }
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
        {
          System.Windows.Media.Brush wpfBrush = brush != null ? brush.RealizeWpfBrush() : null;
          System.Windows.Media.Pen wpfPen = brush != null ? pen.RealizeWpfPen() : null;
          this.dc.DrawGeometry(wpfBrush, wpfPen, GeometryHelper.CreatePolygonGeometry(MakePointArray(points), fillmode, true));
        }
#endif
      }

      if (this.renderer != null)
        this.renderer.DrawPolygon(pen, brush, points, fillmode);
    }
コード例 #13
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
 /// <summary>
 /// Draws a closed cardinal spline defined by an array of points.
 /// </summary>
 public void DrawClosedCurve(XBrush brush, System.Windows.Point[] points, XFillMode fillmode, double tension)
 {
   DrawClosedCurve(null, brush, MakeXPointArray(points), fillmode, tension);
 }
コード例 #14
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
 /// <summary>
 /// Draws a polygon defined by an array of points.
 /// </summary>
 public void DrawPolygon(XPen pen, XBrush brush, System.Windows.Point[] points, XFillMode fillmode)
 {
   DrawPolygon(pen, brush, MakeXPointArray(points), fillmode);
 }
コード例 #15
0
ファイル: XGraphics.cs プロジェクト: BackupTheBerlios/zp7-svn
    /// <summary>
    /// Draws a closed cardinal spline defined by an array of points.
    /// </summary>
    public void DrawClosedCurve(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode, double tension)
    {
      if (pen == null && brush == null)
        throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);

      if (this.drawGraphics)
      {
        this.gfx.FillClosedCurve(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode, (float)tension);
        // The fillmode is not used by DrawClosedCurve
        this.gfx.DrawClosedCurve(pen.RealizeGdiPen(), MakePointFArray(points), (float)tension, (FillMode)fillmode);
      }

      if (this.renderer != null)
        this.renderer.DrawClosedCurve(pen, brush, points, tension, fillmode);
    }
コード例 #16
0
ファイル: XGraphics.cs プロジェクト: BackupTheBerlios/zp7-svn
    /// <summary>
    /// Draws a closed cardinal spline defined by an array of points.
    /// </summary>
    public void DrawClosedCurve(XBrush brush, XPoint[] points, XFillMode fillmode, double tension)
    {
      if (brush == null)
        throw new ArgumentNullException("brush");

      if (this.drawGraphics)
        this.gfx.FillClosedCurve(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode, (float)tension);

      if (this.renderer != null)
        this.renderer.DrawClosedCurve(null, brush, points, tension, fillmode);
    }
コード例 #17
0
ファイル: XGraphics.cs プロジェクト: BackupTheBerlios/zp7-svn
    /// <summary>
    /// Draws a polygon defined by an array of points.
    /// </summary>
    public void DrawPolygon(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode)
    {
      if (pen == null && brush == null)
        throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);
      if (points == null)
        throw new ArgumentNullException("points");
      if (points.Length < 2)
        throw new ArgumentException("points", PSSR.PointArrayAtLeast(2));

      if (this.drawGraphics)
      {
        PointF[] pts = MakePointFArray(points);
        this.gfx.FillPolygon(brush.RealizeGdiBrush(), pts, (FillMode)fillmode);
        this.gfx.DrawPolygon(pen.RealizeGdiPen(), pts);
      }
      if (this.renderer != null)
        this.renderer.DrawPolygon(pen, brush, points, fillmode);
    }
コード例 #18
0
ファイル: XGraphics.cs プロジェクト: BackupTheBerlios/zp7-svn
    /// <summary>
    /// Draws a polygon defined by an array of points.
    /// </summary>
    public void DrawPolygon(XBrush brush, XPoint[] points, XFillMode fillmode)
    {
      if (brush == null)
        throw new ArgumentNullException("brush");
      if (points == null)
        throw new ArgumentNullException("points");
      if (points.Length < 2)
        throw new ArgumentException("points", PSSR.PointArrayAtLeast(2));

      if (this.drawGraphics)
        this.gfx.FillPolygon(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode);

      if (this.renderer != null)
        this.renderer.DrawPolygon(null, brush, points, fillmode);
    }
コード例 #19
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
 /// <summary>
 /// Draws a polygon defined by an array of points.
 /// </summary>
 public void DrawPolygon(XPen pen, XBrush brush, PointF[] points, XFillMode fillmode)
 {
   DrawPolygon(pen, brush, MakeXPointArray(points), fillmode);
 }
コード例 #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XGraphicsPath"/> class.
 /// </summary>
 public XGraphicsPath(PointF[] points, byte[] types, XFillMode fillMode)
 {
   this.gdipPath = new GraphicsPath(points, types, (FillMode)fillMode);
 }
コード例 #21
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
 /// <summary>
 /// Draws a closed cardinal spline defined by an array of points.
 /// </summary>
 public void DrawClosedCurve(XBrush brush, PointF[] points, XFillMode fillmode)
 {
   DrawClosedCurve(null, brush, MakeXPointArray(points), fillmode, 0.5);
 }
コード例 #22
0
        // ----- DrawPolygon --------------------------------------------------------------------------

        public void DrawPolygon(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode)
        {
            Realize(pen, brush);

            int count = points.Length;
            if (points.Length < 2)
                throw new ArgumentException("points", PSSR.PointArrayAtLeast(2));

            const string format = Config.SignificantFigures4;
            AppendFormatPoint("{0:" + format + "} {1:" + format + "} m\n", points[0].X, points[0].Y);
            for (int idx = 1; idx < count; idx++)
                AppendFormatPoint("{0:" + format + "} {1:" + format + "} l\n", points[idx].X, points[idx].Y);

            AppendStrokeFill(pen, brush, fillmode, true);
        }
コード例 #23
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
    /// <summary>
    /// Draws a closed cardinal spline defined by an array of points.
    /// </summary>
    public void DrawClosedCurve(XBrush brush, XPoint[] points, XFillMode fillmode, double tension)
    {
      DrawClosedCurve(null, brush, points, fillmode, tension);
      //      if (brush == null)
      //        throw new ArgumentNullException("brush");

      //      if (this.drawGraphics)
      //      {
      //#if GDI
      //        if (this.targetContext == XGraphicTargetContext.GDI)
      //          this.gfx.FillClosedCurve(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode, (float)tension);
      //#endif
      //#if WPF
      //        if (this.targetContext == XGraphicTargetContext.WPF)
      //        {
      //          // throw new NotImplementedException("TODO");
      //        }
      //#endif
      //      }

      //      if (this.renderer != null)
      //        this.renderer.DrawClosedCurve(null, brush, points, tension, fillmode);
    }
コード例 #24
0
    void AppendStrokeFill(XPen pen, XBrush brush, XFillMode fillMode, bool closePath)
    {
      if (closePath)
        this.content.Append("h ");

      if (fillMode == XFillMode.Winding)
      {
        if (pen != null && brush != null)
          this.content.Append("B\n");
        else if (pen != null)
          this.content.Append("S\n");
        else
          this.content.Append("f\n");
      }
      else
      {
        if (pen != null && brush != null)
          this.content.Append("B*\n");
        else if (pen != null)
          this.content.Append("S\n");
        else
          this.content.Append("f*\n");
      }
    }
コード例 #25
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
 /// <summary>
 /// Draws a closed cardinal spline defined by an array of points.
 /// </summary>
 public void DrawClosedCurve(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode)
 {
   DrawClosedCurve(pen, brush, points, fillmode, 0.5);
 }
コード例 #26
0
    // ----- DrawPolygon --------------------------------------------------------------------------

    public void DrawPolygon(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode)
    {
      Realize(pen, brush);

      int count = points.Length;
      if (points.Length < 2)
        throw new ArgumentException("points", PSSR.PointArrayAtLeast(2));

      AppendFormat("{0:0.####} {1:0.####} m\n", points[0].X, points[0].Y);
      for (int idx = 1; idx < count; idx++)
        AppendFormat("{0:0.####} {1:0.####} l\n", points[idx].X, points[idx].Y);

      AppendStrokeFill(pen, brush, fillmode, true);
    }
コード例 #27
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
    /// <summary>
    /// Draws a closed cardinal spline defined by an array of points.
    /// </summary>
    public void DrawClosedCurve(XPen pen, XBrush brush, XPoint[] points, XFillMode fillmode, double tension)
    {
      if (pen == null && brush == null)
        throw new ArgumentNullException("pen and brush", PSSR.NeedPenOrBrush);

      int count = points.Length;
      if (count == 0)
        return;
      if (count < 2)
        throw new ArgumentException("Not enough points.", "points");

      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
        {
          if (brush != null)
            this.gfx.FillClosedCurve(brush.RealizeGdiBrush(), MakePointFArray(points), (FillMode)fillmode, (float)tension);
          if (pen != null)
          {
            // The fillmode is not used by DrawClosedCurve
            this.gfx.DrawClosedCurve(pen.RealizeGdiPen(), MakePointFArray(points), (float)tension, (FillMode)fillmode);
          }
        }
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
        {
#if !SILVERLIGHT
          tension /= 3; // Simply tried out. Not proofed why it is correct.

          PathFigure figure = new PathFigure();
          figure.IsClosed = true;
          figure.StartPoint = new System.Windows.Point(points[0].x, points[0].y);
          if (count == 2)
          {
            figure.Segments.Add(GeometryHelper.CreateCurveSegment(points[0], points[0], points[1], points[1], tension));
          }
          else
          {
            figure.Segments.Add(GeometryHelper.CreateCurveSegment(points[count - 1], points[0], points[1], points[2], tension));
            for (int idx = 1; idx < count - 2; idx++)
              figure.Segments.Add(GeometryHelper.CreateCurveSegment(points[idx - 1], points[idx], points[idx + 1], points[idx + 2], tension));
            figure.Segments.Add(GeometryHelper.CreateCurveSegment(points[count - 3], points[count - 2], points[count - 1], points[0], tension));
            figure.Segments.Add(GeometryHelper.CreateCurveSegment(points[count - 2], points[count - 1], points[0], points[1], tension));
          }
          PathGeometry geo = new PathGeometry();
          geo.FillRule = fillmode == XFillMode.Alternate ? FillRule.EvenOdd : FillRule.Nonzero;
          geo.Figures.Add(figure);
          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, geo);
#else
          // AGHACK
#endif
        }
#endif
      }

      if (this.renderer != null)
        this.renderer.DrawClosedCurve(pen, brush, points, tension, fillmode);
    }
コード例 #28
0
    // ----- DrawClosedCurve ----------------------------------------------------------------------

    public void DrawClosedCurve(XPen pen, XBrush brush, XPoint[] points, double tension, XFillMode fillmode)
    {
      int count = points.Length;
      if (count == 0)
        return;
      if (count < 2)
        throw new ArgumentException("Not enough points", "points");

      // Simply tried out. Not proofed why it is correct.
      tension /= 3;

      Realize(pen, brush);

      AppendFormat("{0:0.####} {1:0.####} m\n", points[0].X, points[0].Y);
      if (count == 2)
      {
        // Just draws a line...
        AppendCurveSegment(points[0], points[0], points[1], points[1], tension);
      }
      else
      {
        AppendCurveSegment(points[count - 1], points[0], points[1], points[2], tension);
        for (int idx = 1; idx < count - 2; idx++)
          AppendCurveSegment(points[idx - 1], points[idx], points[idx + 1], points[idx + 2], tension);
        AppendCurveSegment(points[count - 3], points[count - 2], points[count - 1], points[0], tension);
        AppendCurveSegment(points[count - 2], points[count - 1], points[0], points[1], tension);
      }
      AppendStrokeFill(pen, brush, fillmode, true);
    }
コード例 #29
0
ファイル: GeometryHelper.cs プロジェクト: Core2D/PDFsharp
        /// <summary>
        /// Creates a path geometry from a polygon.
        /// </summary>
        public static PolyLineSegment CreatePolyLineSegment(SysPoint[] points, XFillMode fillMode, bool closed)
        {
            PolyLineSegment seg = new PolyLineSegment();
            int count = points.Length;
            // For correct drawing the start point of the segment must not be the same as the first point.
            for (int idx = 1; idx < count; idx++)
                seg.Points.Add(new SysPoint(points[idx].X, points[idx].Y));
#if !SILVERLIGHT && !NETFX_CORE
            seg.IsStroked = true;
#endif
            return seg;
        }
コード例 #30
0
 public void DrawClosedCurve(XPen pen, XBrush brush, XPoint[] points, double tension, XFillMode fillmode)
 {
 }