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

Hywel Thomas hywel at controlspecials.demon.co.uk
Thu Feb 5 13:39:37 EST 2009


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;

namespace NPlot.Gtk { // so that we expose NPlot.Gtk.PlotSurface2D

    public class PlotSurface2D
    {
	DrawingArea da_;
	System.Drawing.Bitmap bitmap_cache;
		
	public PlotSurface2D ()
	{
	   da_ = new DrawingArea ();
	   da_.ExposeEvent += new ExposeEventHandler(da_ExposeEvent);
	}

	private void da_ExposeEvent(object o, ExposeEventArgs args)
	{
	   Gdk.Rectangle area = args.Event.Area;
	   using (Graphics g = 
Gtk.DotNet.Graphics.FromDrawable(args.Event.Window)){
		Rectangle bounds = new Rectangle (area.X, area.Y, area.Width, 
area.Height);
		g.DrawImage (bitmap_cache, bounds, bounds, GraphicsUnit.Pixel);
	   }
	   args.RetVal = true;
	}
    }

} // namespace

This won't compile, giving an error message "The type or namespace name 
'DotNet' does not exist in the namespace 'NPlot.Gtk' (are you missing an 
assembly reference?) (CS0234).  It ias as if the NPlot.Gtk namespace is 
hiding the Gtk.DotNet namespace, yet it is happy with the Gtk reference 
to DrawingArea.  Miguel's original 'FromDrawable' was in the Gdk 
namespace.  Is there an obvious way to get round this?  I've tried all 
combinations of 'using' statements, to no avail, and have the correct 
gtk-dotnet reference added to the project.

-- hywel thomas


More information about the Gtk-sharp-list mailing list