예제 #1
0
        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();
            });
        }
예제 #2
0
 protected override void LoadContent()
 {
     logic.LoadContent();
     base.LoadContent();
 }
		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();
			});
		}