Program.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. game = new Game1();
  22. game.Run();
  23. }
  24. public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
  25. {
  26. return true;
  27. }
  28. public override NSApplicationTerminateReply ApplicationShouldTerminate (NSApplication sender)
  29. {
  30. NSAlert alert = NSAlert.WithMessage("Warning", "Yes", "No", null, "Do you really want to close?");
  31. var button = alert.RunModal();
  32. if ( button == 0 )
  33. {
  34. return NSApplicationTerminateReply.Cancel;
  35. }//if
  36. else
  37. {
  38. return NSApplicationTerminateReply.Now;
  39. }//else
  40. }
  41. }
  42. }