Inconsistent DockLocation of WPF DockBar

Good afternoon,

I have followed a rhino developer sample for converting my existing WPF panel plugin for Rhino8 to a DockBar so I can “auto dock” and set the location of the graphical interface on launch.

This is the aforementioned sample: rhino-developer-samples/rhinocommon/cs/SampleCsDockBar at 7 · mcneel/rhino-developer-samples · GitHub

However I am experiencing inconsistency with the location of the DockBar. When I set DockLocation to DockBarDockLocation.Left, the majority of the time it is floating and only occasionally docked.

Here is a snippet of the code I am using to create the panel and adding it to the new DockBar:

[Guid("7BD2E77C-60A4-43B8-ABF1-97DD570973FD")]
public class PluginPanel : Panel { 
	public PluginPanel() {
		var pluginUserControl = new pluginUserControl();
		Content                = new Panel {Content = pluginUserControl.ToEto()};
		var model = Plugin.Instance.Model;
		pluginUserControl .DataContext = model;
	}
}

To then create the DockBar:

internal class PluginDockBar : DockBar {
	public static Guid BarId => new Guid("{7BD2E77C-60A4-43B8-ABF1-97DD570973FD}");
	public PluginDockBar() : base(Plugin.Instance, BarId, "Plugin") {
		var model = Plugin.Instance.Model;
		SetContentControl(new WpfHost(new PluginPanel(), model));
		var options = new DockBarCreateOptions {
			DockLocation = DockBarDockLocation.Left,
			Visible      = true,
		};
		Create(options);
	}
}

And launching the plugin:

public class LaunchPluginCommand : Command {
	///<returns>The command name as it appears on the Rhino command line.</returns>
	public override string EnglishName => "LaunchPlugin";

	///<summary>The only instance of this command.</summary>
	public static LaunchPluginCommand Instance { get; private set; } = new LaunchPluginCommand();

	public LaunchPluginCommand() {
		Instance = this;
	}

	protected override Result RunCommand(RhinoDoc doc, RunMode mode) {
		PluginDockBar dock = new PluginDockBar ();
		var res = RhinoWindows.Controls.DockBar.Show(PluginDockBar.BarId, false);
		return res;
	}

	public Result Run() => RunCommand(RhinoDoc.ActiveDoc, RunMode.Scripted);
}

“Plugin” is a substitute name for the actual name of the plugin. Every time I run the command to launch, it returns True when floating or docked.

Does anyone know why the DockBar’s DockLocation is Inconsistent?

Thanks,
JNash

Hi @jnash,

I’ll try to have a look at this sometime this week.

Thanks for your patience.

– Dale

Hi @jnash,

My apologies for abandoning this topic.

Are you still in need of assistance? Do you have a code sample, you can share, that repeat the unwanted behavior?

Thanks,

– Dale

Hi @dale

Sorry for the late reply.
While preparing a code sample to illustrate the issue, I gained a better understanding of how Rhino handles the DockBar component and their location on launch. My findings suggest that the system is functioning as intended, which is insightful but doesn’t fully address our primary concern.

We face a recurring challenge with some of our less technically inclined users: after each Rhino update, our plugin undocks, leading them to request our support team’s help to redock it remotely. Initially, my goal with using a DockBar was to ensure the plugin remained docked in the same location, regardless of updates or user adjustments.

I’ve attached the code sample, with which to demonstrate our issue.

If you:

  1. undock (float) the panel,
  2. close Rhino
  3. re-open Rhino
  4. run the sample’s DockBarTestCommand command;

Outcome: The panel remains floating.
Expectation: We expect the panel to dock

This behaviour leads me to seek a more robust solution.

Is there a way to ensure that no matter the user actions or updates, the panel always launches docked in the predetermined location?

Any guidance or alternative approaches would be greatly appreciated.

Thanks,
JNash

DockBarTest.zip (160.2 KB)
Apologies, I forgot to attach the code sample.

Hi @dale ,

This issue has been raised again by some of our users, and I’ve been asked to revisit it.
Am I right in thinking that encapsulating my existing panel into a Dockbar component is the best approach, or is there a better way to ensure my plugin auto-docks to a specific location on launch?

Thanks,
Jacob

Hi @jnash,

One option you might consider is taking advantage of the new Window Layout feature of Rhino 8.

Start Rhino 8 and load your plug-in. Organize the window layout however you want: command line to the bottom, panels docked to where you want, etc.

When you’re done organizing the layout, run the WindowLayout command and save the current layout - call it DockBarTest. Then, right-click on the window layout and export to a .rhw file.

Now that you’ve exported your window layout, restore the Default Window Layout and delete the DockBarTest layout you just created. Close Rhino.

Reopen Rhino 8 and script the “_-WindowLayout” command. Run the import option to import the file you just exported. Then make the layout current.

For example:

_-WindowLayout _Import "C:\Users\Dale\Downloads\DockBarTest.rhw" DockBarTest

If your plug-in did this the very first time it was loaded, perhaps this would resolve the issue?

Let me know what you think or if you have any questions.

– Dale

Hi @dale ,

We have actually last week released an update that utilises the new window layout feature to auto install and select a layout. This is great news if this will also fix this issue we have been seeing with the random undocking and disappearing of our panel.

Thanks,
Jacob