RhinoWindows Documentation

Hello,

I’m using the RhinoWindows.dll in order to create and setup some custom DockBars in Rhino WIP, but I’m not able to find any documentation, summaries, or examples, so I have some questions:


1.- Im not able to add a WPF control, its always blank when I add it through base.SetContentFrameworkElement(ctrl) method

    public DockBarCustom(PlugIn plugIn, string name, FrameworkElement wpfControl, DockBarDockLocation location, DockBarDockStyle style)
        : base(plugIn, ctrl.GetType().GUID, name)
    {
        var options = new DockBarCreateOptions
        {
            DockLocation = location,
            DockStyle = style,
            Visible = true,
        };
        base.SetContentFrameworkElement(ctrl);
        base.Create(options);
    }

Although If I use Windows Forms and using method: base.SetContentControl(ctrl) it’s working perfectly.
Question: Is there something that I am doing wrong in the code above?


2.- To move the DockBars programatically I found 2 methods:

 MyDockBar.Dock(DockLocation, Rectangle);
 MyDockBar.StartResize(DockBarResizeHitTest, Point);

Question: Is the point or rectangle starting point relative to Rhinoceros main window top-left point, or is an absolute screen coordinate?


Enric
Best Regards

Hosting a WPF element inside of a WinForms control requires an ElementHost.

https://msdn.microsoft.com/en-us/library/ms754008(v=vs.90).aspx

Note though that for Rhino WIP we’re using Eto.Forms for commands and plug-ins that have a GUI. The obvious target is to have commands with their GUI eventually run on both Rhino for Windows and Rhino for Mac.

It would be best if developers started using Eto.Forms as well.

@curtisw and @maxsoder probably can give samples on how to do that.

/Nathan

@JohnM, can you provide any help with the above question?

The dock location is in the coordinate system of the docking container. What exactly are you trying to do with the dock bar? It is the Rhino DockBar is essentially a MFC CControllBar.

Typically I would recommend creating a dock bar in your plug-in’s OnLoad override and I would suggest setting its visibility state to false then I would create a plug-in command to display/hide/toggle it. I suggest this because the Rhino frame work will save the visibility state and location when it closes and apply those values the next time it starts. If there is a visible plug-in provided dock bar then the plug-in is demand loaded and Rhino checks to see if the dock bar was created then it positions it and displays it as appropriate. If the user hides the dock bar then restarts Rhino and your plug-in shows the dock bar Rhino will hide it causing a flicker on the screen.

You also might be interested in checking out the Rhino.UI.Panels class, most of our new modeless docking UI is heading in that direction.

Thanks for your answers guys! @JohnM I’m trying to stack 3 or 4 DockBars by code and set a different size to each one.

Thanks again, and best regards.

Hi @JohnM

Did you guys solve the problems with the method SetContentFrameworkElement? (point 1 @henrydm asked).

I tried to use it passing as a parameter a WPF control and it still does not show anything a Dockbar.

Regards,

Do not use SetContentFrameworkElement, it is for internal use. Use the following:

SetContentControl(new RhinoWindows.Controls.WpfElementHost(new DockBarPanel(), null));

Thank you @JohnM!

I tried it but I got a crash when calling Create:

public DockBar(Rhino.PlugIns.PlugIn plugin, Guid id, string name, DockBarDockLocation location, DockBarDockStyle style) : base(plugin, id, name)
    {
        var options = new DockBarCreateOptions
        {
            DockLocation = location,
            DockStyle = style,
            Visible = true,
        };
        SetContentControl(new RhinoWindows.Controls.WpfElementHost(new MyControl(), null));
        Create(options);
    }

System.Runtime.InteropServices.COMException occurred_
HResult=0x88980406_
Message=UCEERR_RENDERTHREADFAILURE (Exception from HRESULT: 0x88980406)_
Source=PresentationCore_

Regards,

Sorry about that, I gave you the wrong host, you should use RhinoWindows.Controls.WpfHost not WpfElementHost. I have attached a simple test plug-in that creates two control bars, one hosting a Windows Forms control and another hosting a WPF control.
WpfInControlBar.zip (331.2 KB)

1 Like

Thank you for the answer and the sample it worked fine!

Regards,