Search code examples
c#winformsxnamonogameopentk

Monogame with winforms


I'm planning on creating a map editor for a C# game I'm building. I've done this previously using XNA and XNA's old GraphicsDeviceControl, GraphicsDeviceService and ServiceContainer. I want the ability to create a class and inherit from the GraphicsDeviceControl class and then drag that class onto the form from the toolbox just like this: Youtube Video

I've installed OpenTK using NuGet and followed this tutorial but when I create a class and inherit GraphicsDeviceControl it doesn't show up in the form toolbox. Am I doing something wrong? Isn't this possible using monogame? If it's possible, what should I do to get it working?

Thanks in advance!


Solution

  • I finally managed to get it working :D I added every class that exists in the project called MGWinFormsControls in this github repo to my project. I already had a monogame.framework as well as OpenTK and OpenTK.GlControl reference. Then I created a class and inherited from GraphicsDeviceControl. At first this didn't work but after only writing one line of code in the draw function in my class it worked. I just wrote GraphicsDevice.Clear(Color.Black). Now the class shows up in the toolbox