internal void SetApplication(Application app, XNAWinFormsHostAppWrapper formsWrapper, WinFormsHostGraphicsDeviceService device) { this.device = device; this.application = app; this.winFormWrapper = formsWrapper; this.winFormWrapper.Exiting += new EventHandler(winFormWrapper_Exiting); }
void winFormWrapper_Exiting(object sender, EventArgs e) { if (this.winFormWrapper != null) this.winFormWrapper.Exiting -= new EventHandler(winFormWrapper_Exiting); this.device = null; this.application = null; this.winFormWrapper = null; }
internal XNAWinFormsHostAppWrapper(XNALogic logic, Application parent, WinFormsHostControl host) { this.parent = parent; this.logic = logic; this.control = host; System.Windows.Forms.Control parentControl = this.control; while (parentControl != null) { if (parentControl is System.Windows.Forms.Form) { this.parentForm = (System.Windows.Forms.Form)parentControl; break; } parentControl = parentControl.Parent; } if (parentForm == null) { throw new ArgumentException("Unable to find Parent Form for display handle"); } parentForm.MouseWheel += new System.Windows.Forms.MouseEventHandler(parentControl_MouseWheel); parentForm.FormClosed += new System.Windows.Forms.FormClosedEventHandler(parentForm_FormClosed); formsDeviceService = new WinFormsHostGraphicsDeviceService(this, this.control.ClientSize.Width, this.control.ClientSize.Height); services = new GameServiceContainer(); services.AddService(typeof(IGraphicsDeviceService), formsDeviceService); services.AddService(typeof(IGraphicsDeviceManager), formsDeviceService); presentation = RenderTargetUsage.PlatformContents; content = new ContentManager(services); int width = 0; int height = 0; SurfaceFormat format = SurfaceFormat.Color; width = control.ClientSize.Width; height = control.ClientSize.Height; parent.SetWindowSizeAndFormat(width, height, format, DepthFormat.Depth24Stencil8); parent.SetupGraphicsDeviceManager(null, ref presentation); formsDeviceService.CreateDevice(presentation, host); host.SetApplication(parent, this, formsDeviceService); host.BeginInvoke((EventHandler) delegate { parent.SetGraphicsDevice(GraphicsDevice); logic.Initialise(); logic.LoadContent(); }); }
void winFormWrapper_Exiting(object sender, EventArgs e) { if (this.winFormWrapper != null) { this.winFormWrapper.Exiting -= new EventHandler(winFormWrapper_Exiting); } this.device = null; this.application = null; this.winFormWrapper = null; }
/// <summary> /// Disposes the control. /// </summary> protected override void Dispose(bool disposing) { if (application != null) application.Shutdown(); application = null; device = null; winFormWrapper = null; base.Dispose(disposing); }
/// <summary> /// Disposes the control. /// </summary> protected override void Dispose(bool disposing) { if (application != null) { application.Shutdown(); } application = null; device = null; winFormWrapper = null; base.Dispose(disposing); }
internal XNAWinFormsHostAppWrapper(XNALogic logic, Application parent, WinFormsHostControl host) { this.parent = parent; this.logic = logic; this.control = host; System.Windows.Forms.Control parentControl = this.control; while (parentControl != null) { if (parentControl is System.Windows.Forms.Form) { this.parentForm = (System.Windows.Forms.Form)parentControl; break; } parentControl = parentControl.Parent; } if (parentForm == null) throw new ArgumentException("Unable to find Parent Form for display handle"); parentForm.MouseWheel += new System.Windows.Forms.MouseEventHandler(parentControl_MouseWheel); parentForm.FormClosed += new System.Windows.Forms.FormClosedEventHandler(parentForm_FormClosed); formsDeviceService = new WinFormsHostGraphicsDeviceService(this, this.control.ClientSize.Width, this.control.ClientSize.Height); services = new GameServiceContainer(); services.AddService(typeof(IGraphicsDeviceService), formsDeviceService); services.AddService(typeof(IGraphicsDeviceManager), formsDeviceService); presentation = RenderTargetUsage.PlatformContents; content = new ContentManager(services); int width = 0; int height = 0; SurfaceFormat format = SurfaceFormat.Color; width = control.ClientSize.Width; height = control.ClientSize.Height; parent.SetWindowSizeAndFormat(width, height, format, DepthFormat.Depth24Stencil8); parent.SetupGraphicsDeviceManager(null, ref presentation); formsDeviceService.CreateDevice(presentation, host); host.SetApplication(parent, this, formsDeviceService); host.BeginInvoke((EventHandler)delegate { parent.SetGraphicsDevice(GraphicsDevice); logic.Initialise(); logic.LoadContent(); }); }