MonoGame.Forms - Create your Editor Environment!

Ah, I see what you did there :smiley: This is normal behavior, because you shouldn’t double click on that class to open it. Instead you should do a right click and choose “show code”, or click one time with the left mouse button and press “F7” to see the code of this control class.

For me it stops debugging instantly when closing the window. Maybe you have different tasks open or high cpu usage?

Ah, I see what you did there
This is normal behavior, because you shouldn’t double click on that
class to open it. Instead you should do a right click and choose “show
code”, or click one time with the left mouse button and press “F7” to
see the code of this control class.

@BlizzCrafter, there’s an actual convention to fix that - I have no idea WTF it is because I’ve never done that. It’s along the same lines as the other service stuff in a winform and I’m a WPF person myself (winforms is too inferior to MFC in performance to bother with - beyond just 2 orders of magnitude … as I call it, the land of flicker).

It does exist however.

Thanks for the hint, I will seach for it.

Oh, this sound really bad. You mean when rendering stuff, right? I experienced the same with WinForms and some smaller applications. There are also techniques to avoid flickering like double buffering and such.

At least with the MonoGame.Forms library you don’t need wory about flickerin, but as an interesting fun fact: When you use the double buffering technique in a MonoGame.Forms project then you are again in the land of flicker :smiley:

I wish I remembered what it was, I know it’s there because it was covered when I did MCAD ages ago. I’ll have to see if I have the textbooks around still - though I suspect I chucked them for being ancient and no longer relevant.

That’s the problem with winforms, a constant ping-pong fight with flickering. I absolutely loved Sony’s ATF library, hands down the best WinForms library/app-skeleton out there, but buddha does it flicker something fierce.

1 Like

Forgive my ignorance, how can I create a new SpriteFont for use with MonoGame.Forms?

I understand the code however I am not clear on
how to properly add the SpriteFont so it is recognized by the project.

DrawFont = Editor.Content.Load(“DrawFont”);

Is the Pipeline tool still useful?

Yes, you just need to compile your SpriteFont with the PipelineTool and copy the output to the Content folder of your MonoGame.Forms project (ContentRoot).

You can then load it normaly with the line you have posted above.

It is also possible to integrate the ContentRespond file as a MonoGameContentReference to make it possible to directly compile and use your content per PipelineTool in a MonoGame.Forms project.

I think this would be very helpful when working with MonoGame.Forms, right? Maybe I should write a short tutorial about that.

Done!

I wrote a PipelineTool integration tutorial. Read it here:

This should boost your “content compiling workflow” by alot!


Happy editing and christmas holidays everyone! :santa::snowflake::gift::christmas_tree:

Cheers,
Marcel “sqrMin1” Härtel

I have successfully used this new tutorial to add some fonts to my project.
This got me over the line.
Thanks so much!

I have a small painting application working well, however there are some notable issues I am experiencing, even with completely new projects with the DrawTest object added and not much else.

  • GUI objects including MenuStrips and don’t show up properly on startup (aren’t drawn properly)
  • Message Boxes don’t show properly (sort of hidden behind the DrawTest)
  • Timers don’t trigger unless I set the DrawTest control to invisible
  • And related issues

However the official example projects don’t seem to suffer from these issues.

Please try to exchange the DrawWindow with an UpdateWindow.

I will later write a seperate post about the current situation with Draw- and UpdateWindows, regarding future updates of MonoGame.Forms.

Looks good for the moment. Thanks again.

1 Like

Hello MonoGame!

I quickly want to write down my current thinkings about the next update of MonoGame.Forms.

I experienced that more and more people coming to MonoGame.Forms are struggeling to choose the right forms control to start with or rather how they are technically working or rather what I originally thought about the usage of such controls.

Basically you have two different controls you can inherit from. They are the DrawWindow and UpdateWindow.

The naming of these controls is unprecisely today, because originally MonoGame.Forms worked differently. I overhauled the whole work flow / editing experience of this library, but never changed the naming of classes like them.

So, I plan to rename them to “InvalidationControl” (DrawWindow) and “MonoGameControl” (UpdateWindow) in the next update.


Why “InvalidationControl”?

Simply because it’s exactly like that: it’s a control meant to do your own custom invalidations as soon as you have changes to commit.

This special control is very performant, because it only needs your CPU power this single time it gets invalidated by YOU (after the output is drawn to the surface, it consumes 0% CPU).

You would typically use it like that (example TileMap editing):

  1. Move MouseCursor to InvalidationControl
  2. Place a tile in the control view
  3. Call Invalidate(); on this control
  4. Output gets rendered to the surface
  5. Job is done - no CPU usage

This is exactly like the DrawWindow works today, but with the difference that the property AutomaticInvalidation is turned on by default. This leeds to slow downs and not reacting user interfaces anymore, because of the massive (automatic) invalidations taking place.

However it turned out that most of the people just want to “jump start” into the editing experience MonoGame.Forms has to offer without worring about the invalidations or even CPU usage.

Why “MonoGameControl”?

Simply because it has the complete “Initialize / Update / Draw”-concept instead of the InvalidationControl, which becomes updated through invalidations. This control is bit like “shoot and forget”. You just inherit from this control in your custom class, override the corresponding functions, don’t need to worry about invalidations or performance and just be a happy editor! :wink:


That’s why I will rename the controls in question. The user will surly take the MonoGameControl instead of the InvalidationControl, because if in doubt what the InvalidationControl should be, he would take a look at the GitHub wiki how this control works. On top of it I will also change the xml commentary of this class to make this information clearly available in code.

In the demo project I showed how to use AutomaticInvalidation togehter with a DrawWindow, but i’m thinking of making this option unavailable for a DrawWindow. At least it will be turned off by default in the next update.

Hope this will make using this library more easy and innovative.

Thanks for reading!

Cheers,
Marcel Härtel

May I render models and UserPrimitives?

Yes, but there are no built-in service classes for that.

This means you need to do everything related to 3D on your own - just like with a new MonoGame project.

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