[Mono-osx] Using System.Drawing in a Cocoa# View
Brock.Reeve at ni.com
Tue Nov 13 16:12:22 EST 2007
Looking at the code for System.Drawing, if I define the
MONO_GDIP_USE_COCOA_BACKEND environment variable and call
Graphics.FromHwnd it will create a quartz context using the Cairo backend.
If I then use that graphics object to draw inside of the View's Draw
method it should draw something. I am not seeing it draw anything. If I
use the Cocoa# BezierPath I can get it to draw. Not sure why the
System.Drawing stuff doesn't work from Cocoa#. Here is some Cocoa #code.
Maybe someone has tried this before. I was seeing a lot of CGContext*:
invalid context messages, but it seems like I have a valid context from
some of my writelines in System.Drawing.Graphics.
public void Draw(Rect aRect)
//Must define MONO_GDIP_USE_COCOA_BACKEND on the MacOS
Graphics graphics = Graphics.FromHwnd(NativeObject);
graphics.FillRectangle(Brushes.Black, new Rectangle(0, 0, 100,
BezierPath.FillRect(new Rect(0, 0, 100, 100));
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-osx