internal static void DrawAndFillEllipse(
            this Gdi32.HDC hdc,
            Gdi32.HPEN pen,
            Gdi32.HBRUSH brush,
            int left,
            int top,
            int right,
            int bottom)
        {
            using var penSelection = pen.IsNull ? default : new Gdi32.SelectObjectScope(hdc, pen);

                                     using var brushSelection = brush.IsNull ? default : new Gdi32.SelectObjectScope(hdc, brush);

                                                                Gdi32.Ellipse(hdc, left, top, right, bottom);
        }
Example #2
0
        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(DeviceContext, DeviceContext.Hdc);

            if (pen != null)
            {
                // 1. Select the pen in the DC
                Gdi32.SelectObject(hdc, new HandleRef(pen, pen.HPen));
            }

            if (brush != null)
            {
                Gdi32.SelectObject(hdc, new HandleRef(brush, brush.HBrush));
            }

            // 2. call the function
            Gdi32.Ellipse(DeviceContext, nLeftRect, nTopRect, nRightRect, nBottomRect);
        }