Giter Site home page Giter Site logo

blizzcrafter / monogame.forms Goto Github PK

View Code? Open in Web Editor NEW
272.0 9.0 28.0 52.58 MB

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.

License: Other

C# 100.00%
monogame windows-forms monogame-framework editor editors engine engines monogame-forms nuget monogame-community

monogame.forms's People

Contributors

blizzcrafter avatar sqrmin1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

monogame.forms's Issues

Mouse status getting

Hello Friend! Do you use native GTK# events or native SDL methods for getting mouse state?
What is monogame version did you apply?

[bug] SharpDX 4.2

Once I've updated SharpDX from 4.0.1 to 4,2 forms designer crashed, while project continued to compile fine. Tried a few workarounds but finally had to revert back to 4.0.1
If you could look into this, it would be much appreciated. They are reducing garbage generation in new release which is always very welcome.

latest monogame

Hello

Is it possible monogame forms can be used with latest monogame 3.8.1 and using .net 6.0 or are we always forced to use the modified monogame version as we can read in the docs?

Question

Hi, first thanks for this, it's just what I needed and it's well documented.
The only thing I need to know is if you can set a maximum frame rate (limit it).
Is this project always in sync with VSync?
Thank you

How do I create a spritefont?

How to create spritefont in MonoGame is explained, but I am not sure how to create spritefont in MonoGame.Forms.

However, the current version of MonoGame is .NET Standard 2.0, so the installation was skipped.
I am only using MonoGame.Forms and I would like to know how to create spritefont at this time.

My purpose is to adjust the font size, and I only need to support basic English ASCII for arial, which is the default font of Windows operating system.

I also tried printing the built-in Editor.font by scaling, but the output was not good.

Problems with WindowsFormHost on WPF

Just wanted to test using this in WPF (the existing WPF MonoGame control someone else makes has a lot of weird issues).

  1. The Draw method is called only one time.
  2. The Update method is never called.

anti-aliasing problem

In official MonoGame i can do this.
_graphics.PreferMultiSampling=false;
But how to disable/enable anti-aliasing in MonoGame.Form ?

Videos

Is there currently support for playing videos in DX version? Tried same code to get a video running under Forms.DX and native MonoGame 3.8 latest dev build. Works fine on native MG, fails with nullexceptionerror in Forms, while loaded video contains correct values for properties like duration, fps, location.

        private VideoPlayer vp = null;
        Video vid = Content.Load<Video>("MyVideo");

        vp = new VideoPlayer();
        vp.Play(vid);

Error while building project that uses MonoGame.Forms, on Linux

Hello,

I have a project that has MonoGame.Forms.DX as a dependency through NuGet, and it builds correctly under Windows, but fails to build under Linux.

When building this project under Linux (using msbuild, and after running nuget restore on the solution), it throws an error saying it could not find the "build" folder inside the MonoGame.Forms.DX package folder - presumably because this folder is named "Build" rather than "build", and ext4 is a case sensitive file system.

#13 2.249 /app/[redacted]/[redacted].csproj(553,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ../packages/MonoGame.Forms.DX.2.4.0/build/MonoGame.Forms.DX.targets.
#13 2.259 Done Building Project "/app/[redacted]/[redacted].csproj" (Rebuild target(s)) -- FAILED.

Renaming the folder from "Build" to "build" after restoring the packages works around this problem, and allows my project to build correctly.

monogame version

Hi

Is this code using the installed monogame package of my .net environment?
I'm now using monogame 3.8

What exactly is the license (and limitations of use) for this?

Hey there!

This is fabulous. I was hoping to add this to my a Winforms UI kit I'm creating as an additional control since I myself also work in Monogame - is this allowed? I'd be happy when my UI kit is released to write a tile-editor sample with your Monogame control as a form of level editor.

Here's a quick (outdated) image of the progress I've made so far.

cap 2

Edit: I see you've got the MIT license set. Are you okay with backlinks to this github page from within the source files?

Regards,

  • Eddie

is there a equivalent of Load, Unload, and Update for monogame forms?

is there a equivalent of Load, Unload, and Update for monogame forms?
I would like to contain my code inside these forms kinda like states.

Kinda like this..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TileTestForms
{
	public class Window : MonoGame.Forms.Controls.DrawWindow
	{
		protected override void Initialize()
		{
			base.Initialize();
		}

		protected override void LoadContent()
		{

		}

		protected override void UnLoadContent()
		{

		}

		protected override void Update()
		{

		}

		protected override void Draw()
		{
			base.Draw();
		}
	}
}

if not would that be possible to add?
it would make this even easier to build monogame editors

Resizable control?

Do you have an example on having a resizable form that when the draw/update control is resized, the backbuffer is resized too? Currently it looks like the viewport is resized to fit the control, which makes everything squished or zoomed.

[Net6] Nuget Package not usable in Net6 projects

It's somehow not possible to generate a working nuget package for Net6 projects.

I tried to generate one with this new .nuspec file:
https://github.com/BlizzCrafter/MonoGame.Forms/blob/Net6.0/MonoGame.Forms/MonoGame.Forms.nuspec

When trying to install the generated nuget package on a new Net6 project I get this error message:

error NU1202 Package MonoGame.Forms.DX 6.0.0 is not compatible with net6.0-windows7.0 (.NETCoreApp,Version=v6.0)
Package MonoGame.Forms.DX 6.0.0 does not support any target frameworks.

Which is surprising, because the target framework was clearly set in the .nuspec file.

If someone knows whats going on, then please drop a line here.

[DX] Texture appears scaled in MonoGameControl, but not in MonoGame project

So I have a texture which I'm drawing in a MonoGameControl. The texture is 48x48 pixels, but when I open the form it is drawn in a 59x59 size, and is noticeably blurry. You can download and zoom these images for reference:

Normal
Scaled

This happens with any texture I draw.
I have a MonoGame (latest develop branch) project. I draw the same texture and it is drawn correctly.

What I've tried:

-Setting Editor.graphics's backbuffer width and height to the size of the control on the form
-Setting the zoom of Camera to 1.0f
-Form.AutoScaleMode =AutoScaleMode. None;
-Form.DoubleBuffered = false;

My Environment:
C# 7.3
Visual Studio 2019
.NET Framework 4.8

Forms.GL doesn't exit debugging on close

Using Visual Studio 2015
OS: Win 7
Can provide other stats if necessary

I was having issues getting forms.dx to work so I switched to forms.gl and that seemed to help. Unfortunately, when I attempt to close the form the debugger remains running until I manually stop the process in VS. Attached is a fresh winforms project with just forms.gl installed from nuget and a single draw window on a form and it consistently presents the same issue. I've tested this on multiple pcs and each one has the same issue.

WindowsFormsApplication1.zip

DrawWindow's Draw() method causing screen update problems

EDIT: Btw using the DX version, if that matters.
Having a small problem with MonoGame.Forms. For some reason if my class that derives from DrawWindow, calls base.Draw(), then any other control will not automatically update for changes.

I can force a update if I move the window, so it might be blocking invalidation some how?

I've even tested it in other projects and different parts of the same project and get the same result.

Bellow is a picture showing what my programs window looks like when I click the tab that has the DrawWindow.

error

Not suitable for 3D renders

What is the DrawInterval property for the MonoGameControl ?!
I hope you're not using a System.Windows.Forms.Timer ?
My 3D renders very slow with this control, and I ported my whole MonoGame to your MonoGame.Forms because I needed a form with OpenGL, to enable antialiasing.
Official DirectX MonoGame already allows to catch the GameWindow as a System.Windows.Forms.Form, and allows to append System.Windows.Forms.Controls already.
This is impossible with OpenGL MonoGame though.
You could have specified that your solution renders too slow for 3D projects like mine.
It is not my project being wrong, because I tried to render an empty game in 1600x900 and the FPS drops to 5. Not good !

Fixed Time Step

As far as I was able to investigate there was no proper IsConstantTimeStep Property anywhere at the moment or at least not a conventional one. The DrawInterval Property alone is a possible alternative but I experienced a lot of inconsistencies in the framerate when i try to use it.

P.S My problem with DrawInterval might be caused by VerticalSync, but I also could not find the SynchronizeWithVerticalRetrace Property.

TextureBox?

is it possible to make a monogame texturebox control?
I tried to derive from DrawWindow and implement my wrapper class...

    [Serializable]
    public class Img : IDrawable
    {
        Texture2D Texture;

        public event EventHandler<EventArgs> DrawOrderChanged;
        public event EventHandler<EventArgs> VisibleChanged;

        public int W { get; set; }
        public int H { get; set; }

        public int DrawOrder => 0;

        public bool Visible => true;

        internal Img()
        {
            Texture = new Texture2D(Sys.Content.GetGraphicsDevice(), 8, 8);
            W = Texture.Width;
            H = Texture.Height;
        }
        internal Img(string filename)
        {
            FileStream stream = File.Open(filename, FileMode.Open);
            Texture = Texture2D.FromStream(Sys.Content.GetGraphicsDevice(), stream);
            W = Texture.Width;
            H = Texture.Height;
            stream.Dispose();

        }
        internal Img(int w, int h)
        {
            Texture = new Texture2D(Sys.Content.GetGraphicsDevice(), W, H);
            W = Texture.Width;
            H = Texture.Height;
        }

        public static implicit operator Img(Texture2D tex)
        {
            var img = new Img();
            img.Texture = tex;
            return img;
        }
        public static implicit operator Texture2D(Img img)
        {
            return img.Texture;
        }

        public void Draw(GameTime gameTime)
        {
            Gfx.Draw(this, 0, 0, 0, 0, W, H, 0);
        }
    }

however when using a ImageConverter attribute it makes the Img property unable to load a image.

using PureFramework.Library;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PureEditor.Controls
{
    public class TextureBox : MonoGame.Forms.Controls.DrawWindow
    {
        public TextureBox()
        {
        }

        [TypeConverter(typeof(ImageConverter))]
        public Img Img { get; set; }
       
    }
}

image

is there a way around this?

60 fps

Running one instance of UpdateWindow control on double buffered winform on mid-tier laptop (i7 8th gen, 16gb ram). Following code executes barely 10 times a second:

protected override void Update(GameTime gt) { Debug.WriteLine(DateTime.Now); }

Native MonoGame openGL game hits 60 cap without any problems. Is there any way to increase performance? Running project is allocating like 50 Mb of RAM only.
Thanks in advance.

Lost input

keyboard input doesn’t work when mouse out outside the form. Any solution?

Can It be used in .Net Core

Is it possible to use in net core? I have not managed to make it work.
The further I have managed to go is by using my own copy of MonoGame.Framework.WindowsDX, which at least builds. However I get this error on startup:
image
If instead of my own copy I use <PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.7.1.189" /> Then it straight up doesn't compile.
I'm trying to have a local copy of MonoGame.Forms and Monogame and be able to compile them on net core.

Exception has occurred: CLR/SharpDX.SharpDXException
An unhandled exception of type 'SharpDX.SharpDXException' occurred in SharpDX.dll: 'HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.'
at SharpDX.Result.CheckError()
at SharpDX.Direct3D11.Device.CreateTexture2D(Texture2DDescription& descRef, DataBox[] initialDataRef, Texture2D texture2DOut)
at SharpDX.Direct3D11.Texture2D..ctor(Device device, Texture2DDescription description)
at Microsoft.Xna.Framework.Graphics.RenderTarget2D.CreateTexture() in C:\Users\OscarA\Documents\git_Projects\MyGame\MonoGame\MonoGame.Framework\Platform\Graphics\RenderTarget2D.DirectX.cs:line 161
at Microsoft.Xna.Framework.Graphics.RenderTarget2D.GenerateIfRequired() in C:\Users\OscarA\Documents\git_Projects\MyGame\MonoGame\MonoGame.Framework\Platform\Graphics\RenderTarget2D.DirectX.cs:line 34
at Microsoft.Xna.Framework.Graphics.RenderTarget2D.PlatformConstruct(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Boolean mipMap, DepthFormat preferredDepthFormat, Int32 preferredMultiSampleCount, RenderTargetUsage usage, Boolean shared) in C:\Users\OscarA\Documents\git_Projects\MyGame\MonoGame\MonoGame.Framework\Platform\Graphics\RenderTarget2D.DirectX.cs:line 25
at Microsoft.Xna.Framework.Graphics.RenderTarget2D..ctor(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Boolean mipMap, SurfaceFormat preferredFormat, DepthFormat depthFormat, Int32 preferredMultiSampleCount, RenderTargetUsage usage, SurfaceType surfaceType, Boolean shared, Int32 arraySize) in C:\Users\OscarA\Documents\git_Projects\MyGame\MonoGame\MonoGame.Framework\Graphics\RenderTarget2D.cs:line 82
at Microsoft.Xna.Framework.Graphics.RenderTarget2D..ctor(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Boolean mipMap, SurfaceFormat format, DepthFormat depthFormat, Int32 preferredMultiSampleCount, RenderTargetUsage usage, SurfaceType surfaceType) in C:\Users\OscarA\Documents\git_Projects\MyGame\MonoGame\MonoGame.Framework\Graphics\RenderTarget2D.cs:line 58
at Microsoft.Xna.Framework.Graphics.SwapChainRenderTarget..ctor(GraphicsDevice graphicsDevice, IntPtr windowHandle, Int32 width, Int32 height, Boolean mipMap, SurfaceFormat surfaceFormat, DepthFormat depthFormat, Int32 preferredMultiSampleCount, RenderTargetUsage usage, PresentInterval presentInterval) in C:\Users\OscarA\Documents\git_Projects\MyGame\MonoGame\MonoGame.Framework\Platform\Graphics\SwapChainRenderTarget.cs:line 51
at Microsoft.Xna.Framework.Graphics.SwapChainRenderTarget..ctor(GraphicsDevice graphicsDevice, IntPtr windowHandle, Int32 width, Int32 height) in C:\Users\OscarA\Documents\git_Projects\MyGame\MonoGame\MonoGame.Framework\Platform\Graphics\SwapChainRenderTarget.cs:line 27
at MonoGame.Forms.Controls.GraphicsDeviceControl.OnCreateControl() in C:\Users\OscarA\Documents\git_Projects\MyGame\MonoGame.Forms\MonoGame.Forms.DX\Controls\GraphicsDeviceControl.cs:line 247
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

can monogame forms support the soundeffect?

can monogame forms support the soundeffect?
i load the wav xnb file,but it doesn't work,no sound play。
but i use it in a xna framework project,it can play sound well,with the same code。。

Mac / LinuX support (Mono WinForms)? Alternatives?

I'm assuming that the way this is implemented it's just not possible to ever have multiplatform support built upon Mono's WinForms implementation?

I'm doing research for editor of upcoming project, and would prefer to target all 3 desktop OS, not just Windows.

If not, the other obvious alternative is trying to build the entire GUI in the game itself, which is going to be a nightmare.

Any other thoughts on how to provide a rich cross-platform desktop editor for a monogame title the embeds the actual game rendering logic? Something for QT, GTK, etc?

Controls in two different forms | OpenGL

How does one render a Control in another (newly created) form?
Whenever I try to draw a Control inside a second form all the Controls get messed up and turn black after Invalidation. I've been trying to fix it for some time, messing around with Swap Chain Render Target, but with no result.
That problem doesn't persist when using DX library.

first
second

MonoGame Control on a Panel resets his scrollbars on MouseOver

Originally reported here:

http://community.monogame.net/t/monogame-forms-create-your-editor-environment/9954/138

Description:

I'm having an issue where whenever I move my mouse over a DrawWindow in my project, the scroll bar for the form containing it automatically resets.

Solution:

This is a WindowsForms bug and not realted to the MonoGame.Forms library.
You can fix it by creating your own Panel class and place your MonoGame control onto this Panel. See the following example.

public class PanelNoScrollOnFocus : Panel
{
    protected override System.Drawing.Point ScrollToControl(Control activeControl)
    {
        return DisplayRectangle.Location;
    }
}

Eto.Forms

does this work with eto.forms?
if not can support be added for it?

eto.forms is a cross platform gui library that the monogame pipeline is made from.
https://github.com/picoe/Eto

Does this work on VS 2017 and MonoGame 3.6?

hello I am having trouble getting this to work on VS 2017 and MonoGame 3.6.
when I try to install it from the nuget package manager it gives me this..

Severity Code Description Project File Line Suppression State
Error Could not install package 'MonoGame.Forms 1.6.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0

Events >.>

Hey, thought I should mention as looking through your documentation it still requires that old poopy method of inheriting a class to generate a control to use for rendering when you could simply have an invokable event that people can hook onto (The native winforms style development, after all you did all this in trying to use winforms to begin with didnt you? :P ) Ill throw a fork with that change u can pull from - Also as stated on the MonoGame thread concerning this, if they fix the stupid artificial block from using GL with multiple MonoGame Contexts im totally down for fixing up the GL support on this too :D

NullRef Exception in Draw() of MonoGameControl caused by form's WindowState.Maximized

Hello, I have a custom control inheriting from MonoGameControl (just like the tutorial). I override the methods and have this code in Draw:

protected override void Draw()
{
    base.Draw();

    Editor.spriteBatch.Begin(); // <--- NullReferenceException: Editor is null
    ControlContainer.Draw(Editor.spriteBatch);
    Editor.spriteBatch.End();
}

I tried debugging and I found the culprit is here:

protected override void Initialize()
{
    base.Initialize(); // <-- After this line it jumps directly to Draw(), and Editor is still null
    // All the code here is ignored
}

I'm using a WinForms project and the latest version of MonoGame.Forms.DX from nuget.

[question] Simple shapes

Hi @sqrmin1 this is not really an issue with MonoGame.Forms but rather a question regarding MonoGame itself to which I can't find an answer. Have you ever needed to render a simple shape like filled/wireframe triangle? If so, any pointer would help me a lot.
Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.