I'm currently trying to create a mapeditor using monogame and winforms in C#. I'm working in Visual Studio 2015 on a Windows 7 machine. I created a winforms project and proceeded by adding the following references: MonoGame.Framework, OpenTk and OpenTK.GLControl. Then I included the following files from the XNA Winforms Sample: GraphicsDeviceControl.cs, GraphicsDeviceService.cs and ServiceContainer.cs. When this was done I followed this tutorial to port the XNA Sample to MonoGame. This far everything works.
Then I created this test class to see that it works:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TileMapEditor
{
class Test : GraphicsDeviceControl
{
ContentManager content;
SpriteBatch spriteBatch;
Texture2D t;
protected override void Initialize()
{
content = new ContentManager(Services, "Content");
spriteBatch = new SpriteBatch(GraphicsDevice);
t = content.Load<Texture2D>("Gameplay/Player");
}
protected override void Draw()
{
spriteBatch.Begin();
spriteBatch.Draw(t, new Rectangle(10, 10, t.Width, t.Height), Color.White);
spriteBatch.End();
}
}
}
Then I built the project so this class would show up in the forms designer toolbox. This worked as well so I proceeded by draging the class onto the form in the designer. This showed up as normal as well. Then I built the project once again and hoped that my texture would show up, however, I only got a black window as big as the class I added in the designer, see this picture: prnt.sc/b33my9 (Can't make a 3rd link since I don't have enough rep) I can also mention that Visual Studio 2015 says that the field 'GraphicsDeviceService.parameters' in GraphicsDeviceService.cs is never used. I don't know if that is a part of my problem or not. I also tried to replace my code in the Draw function with this line:
GraphicsDevice.Clear(Color.Blue);
but I still got the same black window. I've also tried the ported xna sample in the MGWinFormsControls project located in this gitub repo: github.com/jaquadro/MonoGame-WinFormsControls and the result is that the 'GraphicsDeviceService.parameters' warning is gone but I still can't get anything except a black window.
Is there anyone that know what I should do to fix this?
Thanks in advance!