static void Main(string[] args) { Logger.Instance.log("Application started."); try { Application.EnableVisualStyles(); MainForm form = new MainForm(); form.Show(); Logger.Instance.log("Creating Game1 object."); using (Game1 game = new Game1(form.getHandle())) { game.Run(); } } catch (Exception e) { Logger.Instance.log("Exception caught: \n\n " + e.Message + "\n\n" + e.StackTrace); if (e.InnerException != null) Logger.Instance.log("Inner Exception: " + e.InnerException.Message); MessageBox.Show("An exception was caught. Application will end. Please check the file log.txt."); } finally { Logger.Instance.log("Application ended."); } }
public Game1(IntPtr drawSurface) { Logger.Instance.log("Game1 creation started."); Instance = this; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; Content.RootDirectory = "Content"; Logger.Instance.log("Creating Winform."); this.drawSurface = drawSurface; graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings); winform = (Forms.Form)Forms.Form.FromHandle(Window.Handle); winform.VisibleChanged += new EventHandler(Game1_VisibleChanged); winform.Size = new System.Drawing.Size(10, 10); Mouse.WindowHandle = drawSurface; resizebackbuffer(MainForm.Instance.pictureBox1.Width, MainForm.Instance.pictureBox1.Height); winform.Hide(); Logger.Instance.log("Winform created."); Logger.Instance.log("Game1 creation ended."); }
private static void runApp() { Application.EnableVisualStyles(); MainForm form = new MainForm(); form.Show(); Logger.Instance.log("Creating Game1 object."); using (Game1 game = new Game1(form.getHandle())) { game.Run(); } }