PdfSharp.Drawing.XGraphics.DrawEllipse C# (CSharp) Method

DrawEllipse() public method

Draws an ellipse defined by a bounding rectangle.
public DrawEllipse ( XPen pen, double x, double y, double width, double height ) : void
pen XPen
x double
y double
width double
height double
return void
    public void DrawEllipse(XPen pen, double x, double y, double width, double height)
    {
      if (pen == null)
        throw new ArgumentNullException("pen");

      // No DrawArc defined?
      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
          this.gfx.DrawArc(pen.RealizeGdiPen(), (float)x, (float)y, (float)width, (float)height, 0, 360);
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
        {
          double radiusX = width / 2;
          double radiusY = height / 2;
          this.dc.DrawEllipse(null, pen.RealizeWpfPen(), new System.Windows.Point(x + radiusX, y + radiusY), radiusX, radiusY);
        }
#endif
      }

      if (this.renderer != null)
        this.renderer.DrawEllipse(pen, null, x, y, width, height);
    }

Same methods

XGraphics::DrawEllipse ( XBrush brush, Rectangle rect ) : void
XGraphics::DrawEllipse ( XBrush brush, RectangleF rect ) : void
XGraphics::DrawEllipse ( XBrush brush, XRect rect ) : void
XGraphics::DrawEllipse ( XBrush brush, double x, double y, double width, double height ) : void
XGraphics::DrawEllipse ( XBrush brush, int x, int y, int width, int height ) : void
XGraphics::DrawEllipse ( XPen pen, Rectangle rect ) : void
XGraphics::DrawEllipse ( XPen pen, RectangleF rect ) : void
XGraphics::DrawEllipse ( XPen pen, XBrush brush, Rectangle rect ) : void
XGraphics::DrawEllipse ( XPen pen, XBrush brush, RectangleF rect ) : void
XGraphics::DrawEllipse ( XPen pen, XBrush brush, XRect rect ) : void
XGraphics::DrawEllipse ( XPen pen, XBrush brush, double x, double y, double width, double height ) : void
XGraphics::DrawEllipse ( XPen pen, XBrush brush, int x, int y, int width, int height ) : void
XGraphics::DrawEllipse ( XPen pen, XRect rect ) : void
XGraphics::DrawEllipse ( XPen pen, int x, int y, int width, int height ) : void

Usage Example

    /// <summary>
    /// Demonstrates the use of XGraphics.DrawBeziers.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      int n = 2;
      int count = 1 + 3 * n;
      XPoint[] points = new XPoint[count];
      Random rnd = new Random(42);
      for (int idx = 0; idx < count; idx++)
      {
        points[idx].X = 20 + rnd.Next(600);
        points[idx].Y = 50 + rnd.Next(800);
      }

      // Draw the points
      XPen pen = new XPen(XColors.Red, 0.5);
      pen.DashStyle = XDashStyle.Dash;
      for (int idx = 0; idx + 3 < count; idx += 3)
      {
        gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx]));
        gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 1]));
        gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 2]));
        gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 3]));
        gfx.DrawLine(pen, points[idx], points[idx + 1]);
        gfx.DrawLine(pen, points[idx + 2], points[idx + 3]);
      }

      // Draw the curve
      gfx.DrawBeziers(properties.Pen2.Pen, points);
    }
All Usage Examples Of PdfSharp.Drawing.XGraphics::DrawEllipse