I decided to put some work into creating an editor that I can later use for building the levels and perhaps even include with my game. XNA gave me a hard time getting it to work inside a Windows.Forms application and I had to rewrite several of the XNA classes until I had a properly working XNA UserControl allowing me to render my game world inside the editor window.

Of course, the editor had to look modern and neat, with dockable panels and color gradients all over the place. As it turned out, there is no built-in solution for docking windows in the .NET Framework, so, given my plans to release the game's source code, I had to find a solution that was both free and provided a decent user experience.
There's one such library on SourceForge which looks very promising and provides the same look and feel the Visual Studio 2005 IDE has: DockPanelSuite. I ran into some issues with RC2, so I decided against it for the time being. When 1.0 goes final before my game is shipped, I'll definitely will go back to this one as its by far the most promising component of this kind.
This brought me to DockingLibrary provided by a kind developer which goes under the name Darwen. It includes full source code, looks still good on Windows Vista and doesn't even have a license to begin with.
There's another free docking library: Docking Windows. However, it doesn't include source code, so I could not assess its quality.
XNA UserControl Tutorial ?
Hello,
Your tool already looks very nice and makes me think that a tutorial about XNA + WinForms interop would be helpful for many people.
I've already tried some kind of integration myself. Do you trigger the 3D refresh with a Timer ?
Thomas
Thinking About It
Thanks, I'm not sure if it's suited for a tutorial as I basically had to duplicate the entire XNA graphics manager, game class and game loop (which, granted, wasn't too hard with a little help from .NET Reflector, but perhaps is a little bit in the legally gray area).
I'll see if I can release this piece of code as a downloadable kit so others can use it, too.
The refresh is done via the Application.Idle event and by using the Control's normal OnPaint() method.custom XNA Game Classes! Need Help
Hello :)
I am currently facing the exact same problem that you had integrating XNA into WinForms.
I need a Xna Control as well, to use it in my editor.
I already rewrote the GameComponent and DrawableGameComponent Classes, but i have problems rewriting Game :/
If you could just send me some source, you would definitly safe my day :) You don't need to clean it up or document it.
Please, Help me if you can :>
Thanks
You can contact me via email ( address specified above).
Well then, here it is!
Okay, I've packaged my XNA UserControl and a (somewhat unpolished) demo game that shows how to use it here:
www.nuclex.org/downloads/developers/kits/xna-usercontrol
To use it in your own projects, you need to add a reference to Nuclex.GameControl.dll and then create a new UserControl that inherits from the
Nuclex.GameControlbase class. You can then act as if that UserControl was your normal game class (eg. overrideLoadGraphicsContent(),Update(),Draw()and so on).Have fun!
-Markus-
Post new comment