コード例 #1
0
ファイル: WinFormsHost.cs プロジェクト: ARLM-Attic/xna-xen
 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);
 }
コード例 #2
0
		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);
		}
コード例 #3
0
		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;
		}
コード例 #4
0
ファイル: WinFormsHost.cs プロジェクト: ARLM-Attic/xna-xen
        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();
            });
        }
コード例 #5
0
ファイル: WinFormsHost.cs プロジェクト: ARLM-Attic/xna-xen
 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;
 }
コード例 #6
0
		/// <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);
		}
コード例 #7
0
ファイル: WinFormsHost.cs プロジェクト: ARLM-Attic/xna-xen
        /// <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);
        }
コード例 #8
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();
			});
		}