[Mono-list] System.Graphics and GTK# applications
Francisco M. Marzoa
fmmarzoa at gmx.net
Sun Nov 14 08:50:09 EST 2010
Thanks for your help, Dimitar.
This wants to work, but it didn't fully. It seem that I can draw an
square on a DrawingArea, but it's erased just after drawing it. :-?
Please, take a look at this code:
public partial class MainWindow : Gtk.Window
public MainWindow () : base(Gtk.WindowType.Toplevel)
g = Gtk.DotNet.Graphics.FromDrawable (drawingarea1.GdkWindow);
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
a.RetVal = true;
protected virtual void Redraw (object o, Gtk.ExposeEventArgs args)
Pen p = new Pen (Color.Red);
g.DrawRectangle (p, 10, 10, 100, 100);
Is a GTK# solution I've created with Monodevelop: it has just a
MainWindow, within which there's a VBox container with just one row,
within which there's a DrawingArea named as default "drawingarea1".
Also the Redraw method is connected to the Expose signal on
drawingarea1, so it's redrawn everytime the MainWindow resizes (Miguel
de Icaza told me to use that event for this task in a previous message.
Now, when I run the application there's nothing drawn on the window, but
if I drag a corner of the mainwindow resizing it continously, I can see
from time to time a flickering red square within, that dissapears when I
stop to drag the corner.
So it seems like the rectangle where drawn, but it's "erased" just after
Do you know where the problem may be??
Thanks a million in advance,
El 13/11/10 18:47, Dimitar Dobrev escribió:
> Add a reference to gtkdotnet and use Graphics.FormDrawable, which returns a
> Graphics object for drawing on the widget with the specified GdkWindow. This
> works on Windows and Linux but not on Mac OS X. I'm looking for a way to use
> it on the latter as well.
More information about the Mono-list