[Mono-osx] Using System.Drawing in a Cocoa# View

Geoff Norton gnorton at novell.com
Tue Nov 13 16:40:19 EST 2007


   That code is unpublished and deprecated.  Its on my TODO list to  
get it working again.



On 13-Nov-07, at 4:12 PM, Brock Reeve wrote:

> 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.
>  [Export("drawRect:")]
>         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, 100));
> #else
>             Cocoa.Color.Black.Set();
>             BezierPath.FillRect(new Rect(0, 0, 100, 100));
> #endif
>         }_______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20071113/d178b0bb/attachment.html 

More information about the Mono-osx mailing list