Nuget UrhoSharp.WinForms missing WinForms control

AlaskanDruidAlaskanDruid USMember

Is there a chance to update the UrhoSharp.WinForms Nuget packet to include the WinForms control it advertised? It would be sweet to be able to use UrhoSharp on Windows.

Posts

  • RayKoopaRayKoopa DEMember ✭✭
    edited September 7

    It won't appear in the Toolbox, but it's there after you've added the Nuget package. I don't think Nuget controls ever appear in the Toolbox due to how dumb and outdated the Toolbox is programmed (not finding referenced Nuget assemblies), and you might only be able to somehow get it there by manually selecting the assembly file of UrhoSharp.WinForms from your output folder, which is probably really ugly.

    I recommend to just do it as demonstrated in the samples. Basically, create a placeholder Panel in your Forms designer which you then reference from code-behind, where you'll add an UrhoSurface instance to it, then call it's Show method with the type of your Urho Application, optionally passing ApplicationOptions to it.

    If you wanna feel fancy, you can also create your own class inheriting from UrhoSurface, and then Show the application in the OnHandleCreated method override. But please check for being in DesignMode first or you crash VS the next time you open the designer. That's a nice way to piss off other developers in your team though.

    public class MapViewControl : UrhoSurface
    {
        protected async override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);
            if (!DesignMode)
                await Show<App>(); // Type of your Urho.Application class here
        }
    }
    

    If you compile this, it'll also appear in your Toolbox and you can drop it onto your form then.

    I noticed the control renders a little less smooth than a full Urho3D application, and I couldn't lock or grab my mouse inside of it aswell, but not sure if that needs another trick to be possible.
    Also, the WPF control is just a Windows.Forms wrapper, it doesn't do anything much better.

  • AlaskanDruidAlaskanDruid USMember

    Thank you for the update. I was looking to create a Windowed (and eventually, full screen) small proof of concept. If the windows control doesn't recognize the mouse.. That seems like a serious bug. I'll check the bug tracker to see if it's mentioned, and if not, I'll submit one.

    Until then, I might have to look for alternatives if/until this is fixed.

    Thanks for the heads up!

Sign In or Register to comment.