11 May 2005

Compiling my first gtk-sharp app in Mono

Started dabbling with mono and gtk-sharp,
and here is a simple app which works.



// project created on 5/11/2005 at 3:37 PM
// 050511 yky Copied and modified from: http://gtk-sharp.sourceforge.net/button.png

using System;
using Gtk;
using GtkSharp;

class MainClass
{
public static void Main(string[] args)
{
Application.Init ();
Window win = new Window( WindowType.Toplevel );
win.Title = "Hello";
win.DeleteEvent += new DeleteEventHandler( Window_Delete );
Button btn = new Button("Click Here");
btn.Clicked += new EventHandler( btn_click );
win.Add( btn );
//win.EmitAdd( btn );
win.ShowAll();
Application.Run ();
}

static void btn_click ( object obj, EventArgs args )
{
Console.WriteLine( "Button Clicked" );
(obj as Button).Label = DateTime.Now.ToString();
}

static void Window_Delete( object obj, EventArgs args)
{
//SignalArgs sa = (SignalArgs) args; // 050511 yky Doesnt work with my ver of mono. 1.1.6
Application.Quit();
//sa.RetVal = true;
}
}



And compiled with this:

mcs Main.cs -pkg:gtk-sharp

wowee..