public void DrawRectangle(WindowsPen pen, int x, int y, int width, int height) { Debug.Assert(pen != null, "pen == null"); HandleRef hdc = new HandleRef(dc, dc.Hdc); if (pen != null) { dc.SelectObject(pen.HPen, GdiObjectType.Pen); } DeviceContextBinaryRasterOperationFlags rasterOp = dc.BinaryRasterOperation; if (rasterOp != DeviceContextBinaryRasterOperationFlags.CopyPen) { rasterOp = dc.SetRasterOperation(DeviceContextBinaryRasterOperationFlags.CopyPen); } IntUnsafeNativeMethods.SelectObject(hdc, new HandleRef(null, IntUnsafeNativeMethods.GetStockObject(IntNativeMethods.HOLLOW_BRUSH))); // Add 1 to widht and height to create the 'bounding box' (convert from point to size). IntUnsafeNativeMethods.Rectangle(hdc, x, y, x + width, y + height); if (rasterOp != DeviceContextBinaryRasterOperationFlags.CopyPen) { dc.SetRasterOperation(rasterOp); } }
public void DrawRectangle(WindowsPen pen, int x, int y, int width, int height) { Debug.Assert(pen != null, "pen == null"); HandleRef hdc = new HandleRef(DeviceContext, DeviceContext.Hdc); if (pen != null) { DeviceContext.SelectObject(pen.HPen, GdiObjectType.Pen); } Gdi32.R2 rasterOp = DeviceContext.BinaryRasterOperation; if (rasterOp != Gdi32.R2.COPYPEN) { rasterOp = DeviceContext.SetRasterOperation(Gdi32.R2.COPYPEN); } Gdi32.SelectObject(hdc, Gdi32.GetStockObject(Gdi32.StockObject.HOLLOW_BRUSH)); // Add 1 to width and height to create the 'bounding box' (convert from point to size). IntUnsafeNativeMethods.Rectangle(hdc, x, y, x + width, y + height); if (rasterOp != Gdi32.R2.COPYPEN) { DeviceContext.SetRasterOperation(rasterOp); } }
public void DrawRectangle(WindowsPen pen, int x, int y, int width, int height) { HandleRef hdc = new HandleRef(this.dc, this.dc.Hdc); if (pen != null) { this.dc.SelectObject(pen.HPen, GdiObjectType.Pen); } DeviceContextBinaryRasterOperationFlags binaryRasterOperation = this.dc.BinaryRasterOperation; if (binaryRasterOperation != DeviceContextBinaryRasterOperationFlags.CopyPen) { binaryRasterOperation = this.dc.SetRasterOperation(DeviceContextBinaryRasterOperationFlags.CopyPen); } IntUnsafeNativeMethods.SelectObject(hdc, new HandleRef(null, IntUnsafeNativeMethods.GetStockObject(5))); IntUnsafeNativeMethods.Rectangle(hdc, x, y, x + width, y + height); if (binaryRasterOperation != DeviceContextBinaryRasterOperationFlags.CopyPen) { this.dc.SetRasterOperation(binaryRasterOperation); } }