MonoGame.Forms - Create your Editor Environment!

Everything is. I transfer the XNA project. But nothing is displayed. Only color of a background changes (established for control only).

I’m not sure if I understood you correctly.

Please download the project on GitHub:

and start the MonoGame.Forms.Tests.DX project, which is the sample project demonstrating the library.

If this is working for you then try to create a custom control with a simple polygon and see if it’s showing up.

In your project the primitive is displayed, but only with BasicEffect and without color. Does not work with the loaded effect.
In my project nothing is displayed. Perhaps because of my Camera component.
Deep alteration of your code exceeds my opportunities. I will look for other way.

Sorry for machine translation and thanks for the answer.

Sorry to hear that it’s not working for you as expected.

I think it would be nice to have a small 3D sample in the demo project. Can’t tell when this will happen though.

Anyway, I wish you good luck with your project!

MonoGame.Forms 2.2.0 - Renaming Classes and Bugfixes


  • Renamed DrawWindow to InvalidationControl.
  • Renamed DrawService to InvalidationService.
  • Renamed UpdateWindow to MonoGameControl.
  • Renamed UpdateService to MonoGameService.
  • Removed protected bool AutomaticInvalidation from GraphicsDeviceControl.
  • Fixed a bug which caused a crash when creating a new RenderTarget and the BackBufferWidth / -Height had a size of 0.
  • Ensures that a MonoGameControl invalidates automatically when using the GL library.

If you want to know the reasons for renaming the above mentioned classes, then please read this post:

Cheers!
Oh, and Happy new Year! :smiley:


NuGet
NuGet

2 Likes

MonoGame.Forms 2.3.0 - Video Support & OnMouseHoverUpdatesOnly


  • Added public GameTime to easily get the current game time of the game loop in a custom MonoGameControl.
  • Added public bool MouseHoverUpdatesOnly to enable controls updates when the mouse cursor is inside a custom MonoGameControl to save CPU power.
  • Added public void RunOneFrame() to run exactly one frame of a MonoGameControl to update its contents and immediately show the result to the user.
  • Updated the MonoGame.Framework to 3.8.0.270 and modified the VideoPlayer class to support video playback. [DX]

Video Example:

//Field
VideoPlayer _VideoPlayer;

//Loading
Video video = Editor.Content.Load<Video>("MyVideo");

//Instantiating
_VideoPlayer = new VideoPlayer(GraphicsDevice); //GraphicsDevice
_VideoPlayer.Play(video);

//Drawing
Editor.spriteBatch.Begin();
Editor.spriteBatch.Draw(_VideoPlayer.GetTexture(), new Vector2(0, 0), Color.White);
Editor.spriteBatch.End();

As you can see, you just need to give the new ctor of the VideoPlayer class the current GraphicsDevice.


It’s also possible to donate to the project now. This is taken from the Readme.md file:

Feel free to buy me a Lithium-ion battery so I can code like a machine!

… or simply show your support by donating what you want :>


I hope you like the new update and I wish you a nice weekend! :smiley:

Cheers,
Marcel Härtel

2 Likes

Hi Marcel,

Just tested this in Visual Studio 2017, and I cannot add any of the controls to a form in the designer.

I can run all your test apps from Git, they all work perfectly, but you cannot add a control to a form in the designer.

You cannot add it to the toolbox either.

Have you come across this at all?

Cheers
Paul

Hi @StainlessTobii,

Do you tried the tutorial from the readme file of the git repo?

It should successfully lead you through the creation process of a custom control. When you build your solution the corresponding toolbox item will appear automatically inside your toolbox.

If this doesn’t work for you, can you please tell me if you are receiving any sort of error messages when trying to drag and place a custom control?

Hi @BlizzCrafter,

That’s the frustrating thing. No error messages.

When you try to drag it into the designer view the cursor changes to the “no fecking way” cursor.

When you try and add it to the toolbox, it fails silently.

I have made a lot of custom controls before and never had this problem.

Cheers
Paul

Ok, so when you create your control class it generates the MonoGame.Forms control successfully but it isn’t possible for you to drag this control onto the designer.

I just tried the tutorial from the readme and it still works for me in Visual Studio 2015 and Visual Studio 2017. In the moment it’s not possible for me to reproduce this issue.

Some questions:

Are you using the NuGet or source from GitHub?
Are you creating a fresh Windows Forms project with just MonoGame.Forms specific stuff referenced?
Can you drag and drop Windows Forms native controls from the toolbox onto the designer?
Can you upload your project somewhere so I can take a look?

NuGet package
New windows form project
Yes
No, but I may be able to do a new one and put it somewhere.

Also the project from github won’t allow me to drag a control onto a form, so I don’t think it’s nuget.

Hope this helps
Paul

Hm, this sounds strange to me. In the moment I can’t explain why this is not working for you.

If it’s realy just a fresh Windows Forms project with the installed MonoGame.Forms library, then it will work on my machine.

But yes, upload it somewhere and I will take a look. Would be nice if I could help you.

MonoGame.Forms 2.3.0.1 - Hotfix Mouse.GetState()


  • Updated the MonoGame.Framework to bring back Mouse.GetState() functionallity from the MonoGame.Framework, which got overriden by the newer develop branch of MonoGame.Framework 3.8.0.270.

I just released this update as a hotfix because I detected that Mouse.GetState() always had the default values.

Then I realised that an old PR from @nkast:

wasn’t merged so far. Back in time this PR solved the problem, that when using the MonoGame.Framework independently from its Game class, the user wouldn’t have had any mouse input events through Mouse.GetState() in his editor environment anymore.

This PR seemed good to me to become merged, but instead it became closed and I don’t know why, because it’s actually pretty helpful and, as far as I can see, it wouldn’t have had broken game specific stuff. But who knows, maybe i’m wrong.

Here, just for you to compare (current develop branch vs. fix from nkast).


Anyway, this problem is fixed now for MonoGame.Forms (again :P).

Cheers,
Marcel

PS: NuGets updated accordingly (2.3.0.1).

is there any framerate limit like, wpf?

It’s limited to 60fps.

Question : Any pro and cons between WPF and Winform.
Which 1 is preferred for editor like solution ?

Both will work to create an editor but there there are many differences between them.

  • WPF is a newer technology, WinForms is older.
  • WPF uses an XML based language called XAML, WinForms generates code based designer files.
  • If you use WPF you’ll learn about things like MVVM using a declarative Binding based approach, WinForms is all C# code (at first it feels easier, but many people prefer the declarative XAML based approach).
  • You can embed MonoGame into either, but doing so requires different code (if you look around you can find other people that have done this).
  • Both technologies are Windows based, although there are projects around to try and make them multi-platform (I’ve never seen one that works really well though).
2 Likes

@craftworkgames put it well together, but just for the sake of completeness I also want to mention the awesome imgui library (C++).

There is also a .Net wrapper called ImGui.Net.

From the readme file:

This is a .NET wrapper for the immediate mode GUI library, Dear ImGui (GitHub - ocornut/imgui: Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies).
ImGui.NET lets you build graphical interfaces using a simple
immediate-mode style. ImGui.NET is a .NET Standard library, and can be
used on all major .NET runtimes and operating systems.

There is a sample program which shows you how to use it together with MonoGame.

The advantage here is that you can integrate it into a DesktopGL project which makes your editor available on multiple platforms without extra work.

I also managed to make it work with MonoGame.Forms so you would have additional designing options in a WindowsForms environment, where it’s often painful to design things (like a property grid).

Another advantage is that you can still use WindowsForms controls / user controls or file dialogs which makes working with directories and files pretty easy.

But in the end it really depends on your ambition and technology knowledge. I would say:

  1. Are you skilled with WPF? Then try to create your editor with the MonoGame.WpfInterop.
  2. You just want a little tool window for manipulating level files? Maybe then MonoGame.Forms is simple enough.
  3. You want a full blown multi platform editor? Maybe then you should try the ImGui.Net library with the MonoGame.Framework.
  4. Are you experienced with WindowsForms but not with WPF and you want fast results without missing designing capabilities? Well, I can show you how to integrate ImGui.Net into a MonoGame.Forms project.

Hope this helps with your decision.

2 Likes

Thanks for all the detail information !! :grinning:

1 Like

how rendertarget work on MonoGame.Forms. When i try to use do my rendertarget, it show red color output. 2nd Question can Mouse.GetState() work in Monogame.form?