main.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. #if MONOMAC
  5. using MonoMac.AppKit;
  6. using MonoMac.Foundation;
  7. #elif IPHONE
  8. using MonoTouch.Foundation;
  9. using MonoTouch.UIKit;
  10. #endif
  11. namespace Microsoft.Xna.Samples.Draw2D
  12. {
  13. #if MONOMAC
  14. class Program
  15. {
  16. static void Main (string[] args)
  17. {
  18. NSApplication.Init ();
  19. using (var p = new NSAutoreleasePool ()) {
  20. NSApplication.SharedApplication.Delegate = new AppDelegate ();
  21. // Set our Application Icon
  22. NSImage appIcon = NSImage.ImageNamed ("monogameicon.png");
  23. NSApplication.SharedApplication.ApplicationIconImage = appIcon;
  24. NSApplication.Main (args);
  25. }
  26. }
  27. }
  28. class AppDelegate : NSApplicationDelegate
  29. {
  30. private Game1 game;
  31. public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
  32. {
  33. game = new Game1();
  34. game.Run();
  35. }
  36. public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
  37. {
  38. return true;
  39. }
  40. }
  41. #elif IPHONE
  42. [Register ("AppDelegate")]
  43. class Program : UIApplicationDelegate
  44. {
  45. private Game1 game;
  46. public override void FinishedLaunching (UIApplication app)
  47. {
  48. // Fun begins..
  49. game = new Game1();
  50. game.Run();
  51. }
  52. static void Main (string [] args)
  53. {
  54. UIApplication.Main (args,null,"AppDelegate");
  55. }
  56. }
  57. #else
  58. static class Program
  59. {
  60. private static Game1 game;
  61. /// <summary>
  62. /// The main entry point for the application.
  63. /// </summary>
  64. [STAThread]
  65. static void Main()
  66. {
  67. game = new Game1();
  68. game.Run();
  69. }
  70. }
  71. #endif
  72. }