This project is read-only.

GUIs using XEN?

Jan 7, 2009 at 2:16 PM
Hello there, I'm new to XNA and I've been looking over XEN for a while, trying to learn how to use it in a project; but seeing as WinForms is in experimental support phase, I was wondering what could be used for UI in a game using XEN? Sorry for the stupid question and general ignorance.

Thanks in advance.
Jan 8, 2009 at 5:33 AM
Edited Jan 8, 2009 at 5:34 AM

Hi.

While the winforms support is experimental, it does work, so embedding your application in a windows form should be an OK course of action. There may be some unexpected hickups, and there are some minor restrictions - but overall it should work OK.

As for xen based UIs, early on I made a decision I wasn't going to implement mouse based UIs in xen, simply because I didn't feel they wouldn't get that much widespread use (Especially given XNA games are mainly targeted at the xbox as well).
With that said, there is Xen.Ex.Graphics2D, which contains a number of classes for drawing rectangle based elements to the screen (in a hierarchy too, each element can have child elements). This includes text as well. The intention is to use these to display your controller based interface.

I hope this helps. Let me know if I've missed something

Jan 8, 2009 at 9:05 PM
Clear, thank you for the reply.
But I'm unsure how to embed a XEN app into a windows form, is it possible you provided a simple example? sorry for the inconvenience and thank you.
Jan 8, 2009 at 10:42 PM

Hello. Currently there isn't a tutorial on it. However it's fairly simple:

There is a new class, Xen.WinFormsHostControl. This is a WinForms Control, so you add a single instance of this class to your windows form (In the WinForms Desiger Toolbox, where you'd choose buttons, textboxes, etc, there should be a 'Xen Components' group right up the top, and WinFormsHostControl should be there).

Once you have that added to your form, you change the way the application is run.

Normally, in your Program.cs Main() method, you'd call:

MyXenApp app = new MyXenApp();
app.Run();

And the Run() method will block until you close the app (because Run() starts a message loop).

To run a windows form, you do something like this:

MyForm form = new MyForm();
Application.Run(form);

With Xen in WinForms, you do:

MyForm form = new MyForm();
MyXenApp app = new MyXenApp();
app.Run(form.GetXenHostControl());
Application.Run(form); 

So this time, the xen Run(formHost) method doesn't start the message loop itself.

Hope that helps.