MonoGame.Forms - Create your Editor Environment!

This is a great project @BlizzCrafter thanks for continuing to support this! I’m working on a Level Editor for our game and it was extremely simple to plug in and get things up and running!

However, I’m having an issue I was hoping you could shed a light on. Most everything seems to be working fine, but for some reason I seem completely unable to load any Effect files. Is there a specific shader model that needs used or some special handling I missed somewhere? Whenever I attempt to load an effect file through the editor’s content manager it throws a SharpDX exception. Of course it’s the entirely useless “The parameter is incorrect” message so I’m not sure what the actual issue is, but it fails on loading instead of setting anything which I found interesting.

This has happened when trying to load the same shaders I use (and are working fine) in my game, and I’ve also tried to make an extremely simple shader to nail down the problem, but even as something as basic as the following still throws an exception:

float4 RedPixel(float2 coords: TEXCOORD0) : COLOR0
{
    return float4(1, 0, 0, 1);
}

technique CrazySimple
{
    pass P0
    {
        PixelShader = compile ps_4_0 RedPixel();
    }
}

My best guess is that there’s an issue somewhere because everything I have is building against MonoGame 3.7.1, but the only reference to MonoGame.Framework in my LevelEditor project is the included DLL from Forms. Is this possibly an issue from MGCB.exe being built against 3.7.1?

Also just to mention, Effects seem to be the only thing I’m having trouble with. Fonts, Models, etc all seem to be loading and working as expected.

Of course as soon as I posted my above question I found the issue. I needed to ensure the GraphicsProfile was set to HiDef instead of Reach. Feel free to ignore me!

Ah, thanks for your message! Nice, that you already found a solution.

Sometimes it’s also possible to resolve such errors when compiling the shader with a different target or feature level like ps_4_0_level_9_1.

Have a nice day :slight_smile:

MonoGame.Forms 2.4.0 Released

  • Added DX targets file to the DX nuspec.
  • Now importing the MonoGame.Content.Builder.targets and MonoGame.Common.props file and setting the MonoGamePlatform property in all MonoGame.Forms.target files (DX, GL).
  • Added MonoGame.Content.Builder content/libs/nuspecs/targets for DX and GL platform.
  • Added MonoGamePlatform property and importing MonoGame specific targets.
  • Correctly using the NativeLibs directory when including files.
  • Added MonoGame.Framework source code for the Windows platform to allow users to recompile it with custom modifications.
  • Updated post build events.
  • Register keystrokes immediately after setting AlwaysEnableKeyboardInput to true.
  • Always setting the KeyboardInput when the meta value changes.
  • Added additional NullReferenceException checks regarding the Editor service class.
  • It’s now possible to define custom clear options when using BeginAntialising, EndAntialising, BeginRenderTarget and EndRenderTarget (graphics.Clear(custom parameters)).
  • Changed the depth of the clear options to 1f as the default.
  • Added real disposing checks in all controls.

Thank you very much!

Cheers,
:: Marcel :sparkling_heart:

1 Like

Hey! I’ve followed the instructions, and tried a few times to get this to work. However I keep getting a large error thrown when trying to add the object to a windows form. Any help?

Hi, can you post the error message here or make a screenshot of it?

Which Visual Studio version are you using?

You also need to do a full rebuild of the solution the first time after you created a MonoGame.Forms control.

Oh, and welcome to the community! :slight_smile:

Visual Studio 2019 - Version 16.6.5

I did rebuild and still get this error thrown. I appreciate your help!

This error seems strange to me.

  • Please try to create a fresh WindowsForms project and choose .NetFramework 4.5.1
  • After that install MonoGame.Forms 2.4.0 from nuget using the nuget package explorer.
  • Create a new class and inherit from MonoGameControl.
  • Save and completly rebuild your solution.
  • Drag & Drop the newly created control from the toolbox to the designer.

I just did it like that with Visual Studio 2019 and it directly worked for me without any errors.

I repeated this process a few times. The component will not show up in the toolbox now :confused:

Is there a way I could ask you about this on discord? I am really excited to use your project

It’s better to discuss such problems here in the forum so that other users which might have the same problem can easily find a solution.

Is it somehow possible for you to upload your project so I can take a look? For example to GitHub.

Here’s my project:
https://github.com/tinkerpox/EridanusA

You project works for me. I tested this with the newest version of Visual Studio 2019 (16.7.0)

Please try the following:

  1. Open the project you linked to me.
  2. Expand Form1.cs
  3. Double-Click on Form1.Designer.cs
  4. Exchange line 23-59 with the following code:
#region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.drawTest1 = new EridanusA.DrawTest();
            this.SuspendLayout();
            // 
            // drawTest1
            // 
            this.drawTest1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.drawTest1.Location = new System.Drawing.Point(0, 0);
            this.drawTest1.MouseHoverUpdatesOnly = false;
            this.drawTest1.Name = "drawTest1";
            this.drawTest1.Size = new System.Drawing.Size(711, 360);
            this.drawTest1.TabIndex = 0;
            this.drawTest1.Text = "drawTest1";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(711, 360);
            this.Controls.Add(this.drawTest1);
            this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);

        }

        #endregion

        private DrawTest drawTest1;
  1. Save & Rebuild the solution.
  2. Double-Click on Form1.cs
  3. Tell me what happens or what do you see after that.

Yes this works for me! I do not know why it won’t show up in the toolbox, thank you!

It seems there is something wrong with your toolbox. You can google for “reset toolbox” or “clear toolbox cache”. This might help.

You shouldn’t edit the designer.cs file itself all the time, because this could lead to project errors. I just wanted to test this out with you.

If you can’t use the toolbox in the future then you should add your MonoGame.Forms controls like this:

public Form1()
{
    InitializeComponent();

    // Do it like this
    this.Controls.Add(new DrawTest() { Dock = DockStyle.Fill });
}

:champagne: MonoGame.Forms 3.0.0 Released :confetti_ball:

Changelog

Removed:

  • Dropped the GL project, because there are already much faster available alternatives like this Gtk one.
  • All nugets besides the MonoGame.Forms.DX one got deprecated - still available on the market, but not reccomended anymore.
  • Removed the Content.Builder project, because it is not needed anymore - With MonoGame.Forms 3 it is and stays an all-in-one-solution, which also automatically contains content compilation the classical way via a .mgcb file and PipelineTool-Support. Simply remove it if you don’t need it!
  • Removed the customly compiled MonoGame.Framework library from the MonoGame.Forms project.

Changed:

  • Changed License from MIT to MS-PL to avoid mixed licenses in the project.
  • Setting the MonoGameContentReference property correctly, so that the compiled content gets copied to the output directory.
  • Better build configurations with updated nuget generation.

Added:

  • Added a new template project to the Visual Studio Marketplace which contains templates for Visual Studio 2017, 2019 & 2022!. I removed the old one (with 6700 downloads) from the market, because it was not possible to update it. Thanks for all your support!
    – This template also contains item templates for the MonoGameControl and InvalidationControl now! This should boost your editor workflow by alot.
  • Added MonoGame.Framework.WindowsDX.9000 (created by @nkast) to the project which is faster, memory optimized, bugfixed and supports full mouse & keyboard input within WindowsForms. You can also update MonoGame.Forms to a new MonoGame version very easily from now on - just by updating the MonoGame.Framework.WindowsDX.9000 nuget package! It’s not neccessary anymore to do your own from-source-compilation-and-modification-experiments - just update and be happy :slight_smile: Big thanks to nkast for doing and maintaining this!

Impressions:

v3_00
A new project template for your Visual Studio.



New item templates boosting your editor workflow now (GameTimeControl & ThriftyControl).



GameTimeControl item template with explanations.



ThriftyControl (based on InvalidationControl) item template with explanations.


v3_04
Simple and easy project structure which combines both worlds: MonoGame and MonoGame.Forms. EDIT: There is a visual bug in this image at “MonoGamEditor”, but because of the awesome “E” in Editor, it’s not a bug … it’s a feature!! :wink: :wink:


Thank you very much for your attention; I hope you like this new update.

Take care and have a very nice and sunny day! :sunglasses: :sunny:

Cheers,

:: BlizzCrafter :sparkling_heart:

I’m curious why those improvements haven’t been pushed upstream to be part of the original MonoGame repo.

I’m not 100% sure, but I believe that there were simply some other priorities on the official MonoGame project.

I remember that some of the commits and PRs made by nkast simply got lost in time, because no one had time to take a deeper look into this.

I further believe that those commits were very specialized and maybe out of scope for the main project.

However, the WindowsDX.9000 project is in the end just exactly that - a collection of commits and PRs which originally got lost in time. And it turns out that this collection is worth gold for the MonoGame.Forms project. It’s exactly what this project needs.

The whole MonoGame Team and all contributors are doing a very awesome and excellent job in developing and maintaining the MonoGame project. Even side projects like WindowsDX.9000 are a proof of that fact in my opinion.

1 Like

I just pushed out a hotfix for the visual studio templates.

Reason:

The item template “ThriftyControl” had the “Name” and the “Description” properties mixed up. They should be correctly now.

Update directly through Visual Studio Extension Manager or download the new version here:
https://marketplace.visualstudio.com/items?itemName=BlizzCrafter.MonoGameForms1337

Hi, I am pretty new to MonoGame and have been trying to use MonoGame.Forms.

A problem that I ran into was that the MGCB editor would not open even when using the “Open With” option. No problem, I manually opened the editor and opened the file from there.

Now, say I add a file and have it copy to the Content folder, it does it and it works but VS doesn’t show the new files. In fact, I added a new folder using MGCB and VS didn’t make the changes (even after refreshing the solution explorer). The changes are there when viewing through the file explorer.

The real problem comes though when trying to build the content. If I build within the MGCB editor, literally nothing happens in the “Build Output” pane. Going over to the debug bin, no Content folder or .xnb files have been created either.

Note: if I manually build the content files in a normal MonoGame project and then copy the Content folder into the MonoGames.Forms debug bin, then it will actually work fine. I’m sure you can understand why that might be annoying though.

Is this a problem that has been solved already? What can I do or is that why the MonoGame.RuntimeBuilder exists?

Not sure if this will help you, but I created a project template for all my games, and when I use it I cannot open the MGCB from Visual Studio directly and some things break , I found a solution by copying a folder called “.config” which had a file called “dotnet-tools.json” which contains the following text:

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "dotnet-mgcb": {
      "version": "3.8.1.303",
      "commands": [
        "mgcb"
      ]
    },
    "dotnet-mgcb-editor": {
      "version": "3.8.1.303",
      "commands": [
        "mgcb-editor"
      ]
    },
    "dotnet-mgcb-editor-linux": {
      "version": "3.8.1.303",
      "commands": [
        "mgcb-editor-linux"
      ]
    },
    "dotnet-mgcb-editor-windows": {
      "version": "3.8.1.303",
      "commands": [
        "mgcb-editor-windows"
      ]
    },
    "dotnet-mgcb-editor-mac": {
      "version": "3.8.1.303",
      "commands": [
        "mgcb-editor-mac"
      ]
    }
  }
}

After adding that file and folder to my folder project, the MGCB editor opened from within Visual Studio and compiled correctly. Can you try that? the folder has to be inside your game project folder