The attachment contains a more self-contained test case. This no longer requires MonoDevelop.

It compiles with:
gmcs /r:System.Drawing.dll -pkg:gtk-dotnet-2.0 test.cs
using System;
using System.Drawing;
using GLib;
using Gtk;
using Gtk.DotNet;

// Compile with:
// gmcs /r:System.Drawing.dll -pkg:gtk-dotnet-2.0 test.cs

public class MainWindow: Gtk.Window
{
	private Gtk.DrawingArea canvas;
	
	public MainWindow (): base (Gtk.WindowType.Toplevel)
	{
		canvas = new Gtk.DrawingArea();
		canvas.SetSizeRequest(200, 200);
		Add(canvas);
		
		ShowAll();
		
		DeleteEvent += new Gtk.DeleteEventHandler(OnDeleteEvent);
		canvas.ExposeEvent += new Gtk.ExposeEventHandler(OnCanvasExposeEvent);
		
		GLib.Timeout.Add(10, frame);
	}
	
	private void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}
	
	private bool frame()
	{
		// Redraw our window rapidly
		QueueDraw();
		return true;
	}
	
	private void OnCanvasExposeEvent (object o, Gtk.ExposeEventArgs args)
	{
		Gdk.Window win = args.Event.Window;
		Gdk.Pixmap pm = new Gdk.Pixmap(win, 200, 200);
		
		// Clear the background
		Gdk.GC whitegc = new Gdk.GC(win);
		whitegc.Foreground = canvas.Style.White;
		pm.DrawRectangle(whitegc, true, 0, 0, 200, 200);
		
		// Commenting this out appears to not hang
		DrawThrobber(Gtk.DotNet.Graphics.FromDrawable(pm));
		
		// Draw the pixmap
		win.DrawDrawable(whitegc, pm, 0, 0, 1, 1, 200, 200);
	}
	
	// This just draws a bouncing rectangle
	private int counter = 100;
	private void DrawThrobber (System.Drawing.Graphics g)
	{
		int pos = Math.Abs((counter % 200) - 100);
		counter++;
		
		Rectangle r = new Rectangle(40 + pos, 50, 20, 100);
		g.DrawRectangle(Pens.Blue, r);
	}
	
	public static void Main (string[] args)
	{
		Application.Init ();
		MainWindow win = new MainWindow ();
		win.Show ();
		Application.Run ();
	}
}

Reply via email to