[Gtk-sharp-list] Namespace problem using Gtk.DotNet

Peter Johanson peter at peterjohanson.com
Thu Feb 5 13:49:36 EST 2009


On Thu, Feb 05, 2009 at 06:39:37PM +0000, Hywel Thomas wrote:
> I'm updating the NPlot Gtk code to use the Gtk.DotNet library, and 
> finding that the compiler won't recognise Gtk.DotNet with the current 
> NPlot.Gtk namespace.  The code below shows the essence of the problem
> 
> using System;
> using System.Drawing;
> using Gtk;

Add the following:

using DNGraphics = Gtk.DotNet.Graphics;

> 	   Gdk.Rectangle area = args.Event.Area;
> 	   using (Graphics g = 
> Gtk.DotNet.Graphics.FromDrawable(args.Event.Window)){

Then this becomes:

using (Graphics g = DNGraphics.FromDrawable(args.Event.Window)){

This uses a little/less known feature of C# know as "type aliases":

http://msdn.microsoft.com/en-us/library/aa664765(VS.71).aspx

in case you're not familiar with it.

-pete



More information about the Gtk-sharp-list mailing list