Program.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using MonoMac.AppKit;
  2. using MonoMac.Foundation;
  3. namespace BackgroundThreadTester
  4. {
  5. class Program
  6. {
  7. static void Main (string [] args)
  8. {
  9. NSApplication.Init ();
  10. using (var p = new NSAutoreleasePool ()) {
  11. NSApplication.SharedApplication.Delegate = new AppDelegate();
  12. NSApplication.Main(args);
  13. }
  14. }
  15. }
  16. class AppDelegate : NSApplicationDelegate
  17. {
  18. Game1 game;
  19. public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
  20. {
  21. using (game = new Game1()) {
  22. game.Run ();
  23. }
  24. }
  25. public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
  26. {
  27. return true;
  28. }
  29. public override NSApplicationTerminateReply ApplicationShouldTerminate (NSApplication sender)
  30. {
  31. NSAlert alert = NSAlert.WithMessage("Warning", "Yes", "No", null, "Do you really want to close?");
  32. var button = alert.RunModal();
  33. if ( button == 0 )
  34. {
  35. return NSApplicationTerminateReply.Cancel;
  36. }//if
  37. else
  38. {
  39. return NSApplicationTerminateReply.Now;
  40. }//else
  41. }
  42. }
  43. }