![]() |
VOOZH | about |
dotnet add package MonoGame.Forms.DX --version 3.2.1
NuGet\Install-Package MonoGame.Forms.DX -Version 3.2.1
<PackageReference Include="MonoGame.Forms.DX" Version="3.2.1" />
<PackageVersion Include="MonoGame.Forms.DX" Version="3.2.1" />Directory.Packages.props
<PackageReference Include="MonoGame.Forms.DX" />Project file
paket add MonoGame.Forms.DX --version 3.2.1
#r "nuget: MonoGame.Forms.DX, 3.2.1"
#:package MonoGame.Forms.DX@3.2.1
#addin nuget:?package=MonoGame.Forms.DX&version=3.2.1Install as a Cake Addin
#tool nuget:?package=MonoGame.Forms.DX&version=3.2.1Install as a Cake Tool
MonoGame.Forms is the easiest way of integrating a MonoGame render window into your Windows Forms project. It should make your life much easier, when you want to create your own editor environment.
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;. If you want to turn off scaling of your whole application, then you need to add a Manifest-File.dotnet add package MonoGame.Forms.DX or use the Package Managerdotnet new install MonoGame.Forms.Templatesdotnet new mgf -n MyMonoGameFormsProjectdotnet new mgfn -n MyMonoGameFormsProjectdotnet new mgc -na MyMonoGameControldotnet new mgic -na MyInvalidationControlIn MonoGame you could draw someting to the screen with the spriteBatch. In MonoGame.Forms you will do the same but you need to use the EditorService for this.
In the MonoGame.Forms.Control classes this service is called Editor. So, in order to draw something to the spriteBatch you need to do this:
Editor.spriteBatch.DrawString();
Let's take a look at the final DrawTest class:
using Microsoft.Xna.Framework;
using MonoGame.Forms.Controls;
namespace nugetTest
{
public class DrawTest : MonoGameControl
{
string WelcomeMessage = "Hello MonoGame.Forms!";
protected override void Initialize()
{
}
protected override void Update(GameTime gameTime)
{
}
protected override void Draw()
{
Editor.spriteBatch.Begin();
Editor.spriteBatch.DrawString(Editor.Font, WelcomeMessage, new Vector2(
(Editor.graphics.Viewport.Width / 2) - (Editor.Font.MeasureString(WelcomeMessage).X / 2),
(Editor.graphics.Viewport.Height / 2) - (Editor.FontHeight / 2)),
Color.White);
Editor.spriteBatch.End();
}
}
}
Result:
It's pretty much like in the MonoGame.Framework!
Take a look at the MonoGame.Forms.Samples-Project, which is part of this repo, to learn more about how MonoGame.Forms works.
This specific control class doesn't need to override the Update() method, because it gets manually updated (by you!).
You simply need to call Invalidate() on a custom InvalidationControl for every change you want to see on it. After calling this, your control does not consume CPU power anymore. This is great when creating preview controls for textures and similar things!
Here are some sample pics from the Blazor branch:
👁 MonoGameControl
👁 InvalidationControl
👁 MultipleControls
👁 AdvancedInput
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0-windows7.0 net6.0-windows7.0 is compatible. net7.0-windows net7.0-windows was computed. net8.0-windows net8.0-windows was computed. net9.0-windows net9.0-windows was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
Showing the top 1 popular GitHub repositories that depend on MonoGame.Forms.DX:
| Repository | Stars |
|---|---|
|
lofcz/SimplexRpgEngine
Modular game engine built with MonoGame, with GMS2-like workflow and advanced level editor
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 3.2.1 | 1,087 | 10/10/2024 | |
| 3.2.0 | 1,207 | 8/25/2023 | 3.2.0 is deprecated. |
| 3.1.0 | 603 | 8/16/2023 | 3.1.0 is deprecated. |
| 3.0.0 | 1,686 | 4/21/2022 | 3.0.0 is deprecated. |
| 2.4.0 | 2,639 | 8/4/2020 | 2.4.0 is deprecated. |
| 2.3.9 | 1,447 | 2/24/2020 | 2.3.9 is deprecated. |
| 2.3.8 | 1,642 | 7/11/2019 | 2.3.8 is deprecated. |
| 2.3.7 | 1,628 | 6/10/2019 | 2.3.7 is deprecated. |
| 2.3.6 | 1,002 | 4/26/2019 | 2.3.6 is deprecated. |
| 2.3.5 | 1,007 | 3/28/2019 | 2.3.5 is deprecated. |
| 2.3.4 | 967 | 3/28/2019 | 2.3.4 is deprecated. |
| 2.3.3 | 937 | 3/25/2019 | 2.3.3 is deprecated. |
| 2.3.2 | 959 | 3/13/2019 | 2.3.2 is deprecated. |
| 2.3.1 | 1,123 | 1/25/2019 | 2.3.1 is deprecated. |
| 2.3.0.1 | 1,021 | 1/23/2019 | 2.3.0.1 is deprecated. |
| 2.3.0 | 1,107 | 1/19/2019 | 2.3.0 is deprecated. |
| 2.2.1 | 1,109 | 1/12/2019 | 2.2.1 is deprecated. |
| 2.2.0 | 1,092 | 1/4/2019 | 2.2.0 is deprecated. |
| 2.1.0.2 | 1,547 | 10/19/2018 | 2.1.0.2 is deprecated. |
| 2.1.0.1 | 1,206 | 9/27/2018 | 2.1.0.1 is deprecated. |