private void DrawEllipse(WindowsPen pen, WindowsBrush brush, int nLeftRect, // x-coord of upper-left corner of rectangle int nTopRect, // y-coord of upper-left corner of rectangle int nRightRect, // x-coord of lower-right corner of rectangle int nBottomRect) { // y-coord of lower-right corner of rectangle HandleRef hdc = new HandleRef(this.dc, this.dc.Hdc); if (pen != null) { // 1. Select the pen in the DC IntUnsafeNativeMethods.SelectObject(hdc, new HandleRef(pen, pen.HPen)); } if (brush != null) { IntUnsafeNativeMethods.SelectObject(hdc, new HandleRef(brush, brush.HBrush)); } // 2. call the function IntUnsafeNativeMethods.Ellipse(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect); }