Simple.cs 737 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // taken from the gtk# samples
  2. namespace MyApp
  3. {
  4. using Gtk;
  5. using System;
  6. public class Simple
  7. {
  8. public static int Main(string[] args)
  9. {
  10. Application.Init();
  11. Window win = new Window("Simple gtk# app");
  12. win.DefaultWidth = 300;
  13. win.DefaultHeight = 300;
  14. win.DeleteEvent += new DeleteEventHandler(Window_Delete);
  15. Button btn = new Button("Simple button");
  16. btn.Clicked += new EventHandler(print_line);
  17. win.Add(btn);
  18. win.ShowAll();
  19. Application.Run();
  20. return 0;
  21. }
  22. static void print_line(object obj, EventArgs args)
  23. {
  24. Console.WriteLine("Simple button was clicked!");
  25. }
  26. static void Window_Delete(object obj, DeleteEventArgs args)
  27. {
  28. Application.Quit();
  29. args.RetVal = true;
  30. }
  31. }
  32. }