[Mono-list] Basic Cario drawing
msporysz06 at gmail.com
Sun Jul 8 18:58:07 UTC 2012
I'm hoping this is a right list.
I'm relatively new to C# & mono, and not so quick at comprehending
some design aspects especially GUI related.
I have an idea for project, but i've hit the wall pretty early. It is
Cairo related. First, for covering the basics I'm trying to draw
something easy on designated area after button is pressed, but program
is crashing after button is pressed with following error:
The program 'Plutno' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadDrawable (invalid Pixmap or Window parameter)'.
(Details: serial 552 error_code 9 request_code 53 minor_code 0)
Short testing program code:
public class Rysownik: Gtk.Window
public Rysownik (): base(Gtk.WindowType.Toplevel)
box = new VBox();
draw = new Button("Draw!");
canvas = new DrawingArea();
draw.Clicked += OnDrawButton;
canvas.ExposeEvent += OnCanExposeEvent;
void OnDrawButton (object sender, EventArgs e)
p1 = new PointD (5,5);
p2 = new PointD (6,6);
p3 = new PointD (7,7);
p4 = new PointD (9,10);
void OnCanExposeEvent (object o, ExposeEventArgs args)
DrawingArea ar = (DrawingArea) o;
ctx = Gdk.CairoHelper.Create(ar.GdkWindow);
public override void Dispose ()
((IDisposable) ctx.Target).Dispose ();
((IDisposable) ctx).Dispose ();
If i move drawing code to OnCanExposeEvent it works, but this is "one
shot" action only when window is rendered on desktop, right?
I want to draw after button is pressed.
More information about the Mono-list