This project is read-only.

Xen 2.0 in WinForms

Mar 23, 2011 at 10:49 PM

Hi everybody,

We are new to Xen and... We want to build a WinForms level editor, but as it turns out it's not so easy to embed a Xen 2.0 application in the form. As i could see the WinFormsHostControl is not included in the Xen 2.0 library, and most of the code was commented out. I tried implementing it myself, but saw only failure. Please help us with the implementation!!!

Regards, IvanGrozni

Apr 2, 2011 at 11:05 PM

Hi. Sorry I haven't replied here, I've had a cold recently.
I simply didn't have time to get this done, and when I was porting the code to XNA 4 beta MS hadn't released any winforms samples. So sorry about that.

I may be needing winforms myself sometime in the future - but it's not immediate. In any case, there are XNA 4 samples that use winforms now, but I can't say I've looked to deeply into them. Xen 1.8 simply had a class that implemented IXNAAppWrapper, if you look for that class in the 1.8 source it should be fairly simple. However I'm not sure how difficult it'd be to port over to XNA 4.

Apr 9, 2011 at 11:01 PM

Hey. I'm sure you have figured this out already, but it's pretty easy to get winforms going again (I had to get it going today for a small new project I'm working on). It's a 5 minute job, the compiler pretty much tells you where things are wrong.

For those who haven't;

Basically, just bring the WinFormsHost.cs file back into the main Xen project (it should still be in the directory).
It'll need a couple of minor tweaks, nothing major:
The events are templated now to EventHandler and the window handle needs to be set on the PresentationParameters instead of being passed into the GraphicsDevice constructor.
The depth state is also set slightly differently. But it's pretty easy to figure out.
I think an exception handler had to be removed, but that was basically it for the winforms host file.

The only other changes were uncommenting WinFormsHostControl code in Application.cs. Otherwise, I believe that's it. It should be good to go.

Apr 10, 2011 at 9:20 AM

Ohh and I completely forgot: set fullscreen to FALSE in the present params, otherwise it crashes :)

Apr 11, 2011 at 8:28 AM

Thx a lot for the answers, but i haven't had time lately to check it out. I will be sure to try it today. Wish me luck. :)