MonoGame.Forms - Create your Editor Environment!

Heyya @DexterZ :wink:

Take a look at this post (expand it to see a picture):

In MonoGame.Forms this is a property since v1.5.7. You can set it during design time.

2 Likes

Cool that was fast… I’ll take a look… many thanks Sir ^_^y

Early Celebration - 10k views!

Despite the fact that MonoGame.Forms birthday is in November, we have already reached 10.000 views here in the MonoGame community!

I want to thank you all for your support and great suggestions / ideas to make this library more awesome by doing a recap with some important milestones and stats we’ve achieved.

So… Let’s start!


MonoGame.Forms library recapitulation

  • Age: 11 Months
  • Support: 11 Months

Stats:

MonoGame Community:

  • 10.000 Views
  • 62 Likes on:
  • 142 Replies with:
  • 36 Minutes estimated read time and:
  • 95 Links posted

GitHub:

  • 270 Commits
  • 51 Stars
  • 155 Wiki Pages
  • 18 Releases
  • ~840 Views (per month)
  • ~150 Unique Visitors (per month)

NuGet:

MonoGame.Forms (old Core):

  • 2014 Total Downloads
  • 6 Downloads Per Day (avg)

MonoGame.Forms.DX:

  • 204 Total Downloads
  • 2 Downloads Per Day (avg)

MonoGame.Forms.GL:

  • 161 Total Downloads
  • 2 Downloads Per Day (avg)

Most Important Milestones:

GitHub Releases:

  • Native Mouse & Keyboard Input [ 1.5 ]
  • Window Resizing [ 1.6 ]
  • Antialising (MSAA) [ 1.6.5.3 ]
  • Render Target Manager (DX) [ 1.6.7.1 ]
  • DirectX and OpenGL (Multi Platform Support) [ 2.0 ]
  • Audio Support [ 2.1 ]

I hope you enjoyed this little recap and that you raise a little glass or two! :beers: :coffee: :tea: :tropical_drink: :grin:

Have a nice day and take care! :heart:

Long live MonoGame.Forms! (hrhrhr)

7 Likes

Hi, sqrMin1. Here’s the situation I bumped into when following github’s README.md:
vs2017 complained that it can’t instantiate abstract class MonoGame.Forms.Controls.DrawWindow when adding DrawTest into toolbox.

Hey @Jack-Ji and thanks for your message!

I just tried the tutorial from the Readme with Visual Studio 2017 and for me it works.

Please try to delete any possible references from the designer class and close visual studio. Reopen it and clean & rebuild your solution. Then try again to place the generated DrawTest control directly onto the form.

Trying this with VS17 helped me to find a different (and interesting) bug by the way:

I don’t know why it is like that but when creating a MonoGame control the OnCreateControl() function is getting called 2 times instead of 1 time like in VS15, but the second time it getting called the ClientSize.Width and ClientSize.Height are both 0, which leads to a -> System.ArgumentOutOfRangeException: “Texture width must be greater than zero” in the SwapChainRenderTarget ctor.

For me this is a weired behavior of VS17. Does anyone know why VS17 is doing this? Would be nice to know.

Anyway, I will push a fix soon by checking that the ClientSize is greater than 0 before creating the control.

Edit: The fix is up! Corresponding nuget packages are updated accordingly.

Hey @BlizzCrafter, thanks for your response!

I’ve tried several things including what you said, it seems after close and reopen vs2017 and rebuild solution solves the problem.

And the vs2017 still complains about instantiation error of abstract class MonoGame.Forms.Controls.DrawWindow when double clicking DrawTest.cs. Looks like the instantiation error has nothing to do with toolbox adding, a little annoying though.

Edit: Another problem worth mentioning: vs2017 won’t stop debugging after window is closed.

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.