MonoGame.Forms - Create your Editor Environment!

MonoGame.Forms 1.5.7.0 Released!

  • It’s now possible to set the GraphicsProfile during Design-Time (see picture below)
  • Editors from DrawWindow and UpdateWindow are now hidden from the property grid
  • Disposing MouseWheel events to prevent memory leaks in the samples project
  • Added missing MonoGame.Framework assemblies to NuGet with automated referencing, when installing the package

GraphicsProfile

2 Likes

MonoGame.Forms 1.6.0.0 - Window Resizing!

  • The SwapChainRenderTarget now gets updated when resizing a Forms window, so that the drawn content won’t get stretched and distorted anymore.
  • DrawService and UpdateService are now both inheriting from IDisposable. Contents of the service classes are now getting disposed automatically.
  • The Camera2D component automatically reacts to the new window resizing feature.

NuGet: https://www.nuget.org/packages/MonoGame.Forms/1.6.0

2 Likes

You mean it is like GraphicsDeviceControl? But where is for OpenTK?

MonoGame.Forms 1.6.2.0 - Automatic Invalidation

  • Added the bool property “AutomaticInvalidation” to the DrawWindow and UpdateWindow / GameControl classes, so it’s possible to turn the invalidation of the controls on and off.

This is useful when working with NodeGraphEditors where the automatic invalidations would block the whole NodeGraph.

  • Disabling AutomaticInvalidation on an UpdateWindow now also blocks the GameLoop (update logic) to further enhance performance when using multiple MonoGame.Forms controls.

NuGet: https://www.nuget.org/packages/MonoGame.Forms/1.6.2


Progress Video
https://youtu.be/9PrY6TZn6bI

NodeGraphEditor Test
https://youtu.be/Mg_5vNfaygo

MonoGame.Forms 1.6.3.0 - DisplayStyle & DebugInfo per Control

  • Added DisplayStyle enumeration with the options to place the integrated display in the TopLeft or TopRight corner using the new SetDisplayStyle property, which defaults to TopLeft.
  • Moved Settings values to GFXService to turn the display options on and off for each custom control individual. The old static Settings class was removed from the class library.
  • Private display style members according to the changes in IGFXInterface, where the user shouldn’t be confused with basically internal properties.
  • The ServiceContainer class now checks if a specific service was already added to the services dictionary to prevent a crash after reinitializing a custom control.

NuGet: https://www.nuget.org/packages/MonoGame.Forms/

2 Likes

MonoGame.Forms 1.6.4.0 - Reinitialization & SwapChain Fixes

  • Fixed that on reinitializing a custom control of the type UpdateWindow, the GameLoop function was reatached multiple times to the Application.Idle event, which caused that the Update method in custom controls was also called multiple times accordingly.

  • Fixed that on reinitializing a custom control of the type UpdateWindow also reinitialized the StopWatch, which sets the elapsed time to 0 and so could possibly cause errors in the GameLoop.

  • Moved the bool AutomaticInvalidation to the GraphicsDeviceControl as it is used by all custom controls.

  • Added the protected event Action<SwapChainRenderTarget> to the GraphicsDeviceControl to reflect the changes on window resizing and giving the editor service classes the new SwapChainRenderTarget. This fixes a NullReferenceException when working with RenderTargets in custom controls.

  • It’s now possible to change the font color of the integrated display.

NuGet: https://www.nuget.org/packages/MonoGame.Forms/

2 Likes

Do you know if the mousewheel events work properly?
I have the following set up:

protected void MapComponent_OnMouseWheelUpwards(MouseEventArgs e)
{
//do something
}

And I have this in Initialize()

OnMouseWheelUpwards += MapComponent_OnMouseWheelUpwards;

But nothing actually happens when I use the mouse wheel. I noticed similiar code in the MapHost source from the samples, but when running it, the mousewheel also does not do anything.

Yes, it still works for me.

Please check if the mouse cursor is inside the control of the MapHost when using the mouse wheel. The event won’t be triggered if the mouse cursor is outside of the control.

You could check if the event triggers by placing a breakpoint in the OnMouseWheelUpwards event.

I’ve tried it with the mouse cursor inside the control, and it doesn’t trigger any breakpoints I put on the event. I tried getting a fresh copy of the sample project to make sure I hadn’t made any changes to it as well.

I can get around not using the mouse wheel, but I guess I just found it kinda weird since it looks like it should be working.

Just for clarification: does the OnMouseClick, OnMouseUp, OnMouseDown or OnMouseMove event working for you in the MapHost sample?

Correct. All of those do work, including clicking the mouse wheel button to re-center the map image. It just seems to be scrolling the mouse wheel that isn’t working.

Ok fine. Please try the following:

Place this code block:

protected override void OnMouseWheel(MouseEventArgs e)
{
      base.OnMouseWheel(e);
}

in the MapHost class and place a breakpoint inside this method.

See if it can reach this breakpoint.

I added that in and placed a breakpoint, but it still doesn’t seem to be working. Very weird.

It’s possible that the controls may not have input focus.

Let’s try this:

Put this code block additionally:

protected override void OnMouseEnter(EventArgs e)
{
        base.OnMouseEnter(e);

        if (!Focused) Focus();
}

protected override void OnMouseLeave(EventArgs e)
{
        base.OnMouseLeave(e);

        if (Focused) Parent.Focus();
}

in the MapHost class and test these events as well as the mouse wheel events from the previous posts.

That did it! Upon adding those, it hits the breakpoint I added in OnMouseWheel.

Thank you so much! :slight_smile:

This is great :slight_smile: I’m glad I could help.

Can you confirm that the breakpoints in OnMouseWheelUpwards and OnMouseWheelDownwards are working too now?

Yeah, both of those are working now as well.

1 Like

Okay nice.

I already applied a patch on the dev branch (not public). It will be available on the master branch in the next iteration of MonoGame.Forms, so you don’t need to fiddle around with OnMouseEnter and OnMouseLeave in your custom controls.

I will push out along other improvements soon.

Thanks for reporting the issue @mgtaa!

MonoGame.Forms 1.6.5.0 - MouseWheel Event Fixes and DebugPanel

  • Added the public Texture Pixel and the public Color DisplayBackColor to draw a panel behind the text of the integrated display and make them useable by the end user.
    Also rewrote the drawing logic of the integrated display accordingly.
  • Fixed that the MouseWheel events didn’t fire for some users, because custom controls didn’t get Focus() when the mouse cursor entered a custom control.
  • Set the cached float FontHeight in GFXService to public as it is also useful in custom controls, when working with the integrated display font.
  • Relative and absolute MousePositions switched from Microsoft.Xna.Framework.Vector2 to System.Drawing.Point, as it’s more fluent in a WindowsForms environment.
  • Added protected bool IsMouseInsideControl to the GraphicsDeviceControl, so that it’s easily possible to check if the mouse cursor is inside a (resized) control.

NuGet: NuGet Gallery | MonoGame.Forms 1.6.7.1


Better readable debug panel:


2 Likes

MonoGame.Forms 1.6.5.1 - Removed IGFXInterface and added global MousePositions

  • Access modifier of UpdateFrameCounter() and UpdateDisplay() are now internal.
  • Removed IGFXInterface as it’s not needed anymore.
  • Added internal void UpdateMousePositions to the GraphicsDeviceControl and calling it in the DrawWindow and UpdateWindow (GameControl) to make them available in all custom controls through the Editor service classes.
    • This makes it possible to use the relative- and absolute mouse positions in the DrawWindow (updated through invalidation).

NuGet: https://www.nuget.org/packages/MonoGame.Forms/