Hot reload in VS not working with ETO forms?

I tried it with normal commands, adding 123 to the command with HotReload.

image

But with the ETO panels I couldn’t use Hot Reload to apply quick changes. e.g. here I would like to remove the 123.

image

Is it normal that ETO panels couldn’t be updated with hot reloads?

To see the changes applied during a hot reload, the changed code needs to be run again. In this case, I guess, you need to create a new instance of the panel, or call some method that reloads the layout of the panel.

1 Like

ahh I see. Thanks. I guess the panel needs to be reloaded using a method

Hi, I tried looking in Rhinocommons and I couldn’t find anything under Panels class to reload the Panel, neither could I create another instance of Panels.

Can someone help me with this?

below is the code:

namespace Terrain.Commands
{
    public class OpenTerrainPanelsCommand : Command
    {
        public static OpenTerrainPanelsCommand Instance { get; private set; }

        public override string EnglishName => "Terrain";

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Panels.RegisterPanel(PlugIn, typeof(Views.TerrainPanel), "Sample", Properties.Resources.TerrainIcon, PanelType.PerDoc);
            var panel_id = Views.TerrainPanel.PanelId;
            var visible = Panels.IsPanelVisible(panel_id);

            if (!visible)
                Panels.OpenPanel(panel_id);
            else
                Panels.ClosePanel(panel_id);
            // TODO: complete command.
            return Result.Success;
        }
    }
}

One way is to set the Content property of a panel inside a method that you can call, rather than in the constructor. For example:

public class SamplePanel : Panel
{
    public SamplePanel(RhinoDoc doc)
    {
        SetContent();
    }

    void SetContent()
    {
        Content = new StackLayout()
        {
            Orientation = Orientation.Vertical,
            Items =
            {
                new Label { Text = "Hello world" },
                new Button((s, e) => SetContent()) { Text = "Update panel" }
            }
        };
    }
}

If you change the text of the label in your ide and hot reload, pressing the button will update the panel and show the new text without having to restart Rhino.

It doesn’t have to be a button in the panel, it could be called by any code that you can trigger easily. In your code you seem to show/hide the panel, so you could add this:

#if DEBUG
    protected override void OnShown(EventArgs e)
    {
        base.OnShown(e);
        SetContent();
    }
#endif

This will update the panel every time you re-open it while in debug mode, but this code will be omitted on release.

The problem remains that, when I change the Panel, like adding a new slider in the ETO form, I would like to test it out with Hot Reload.
I cannot make a SetContent method every time I add something new. it would be quite clumpsy.
Is it true? Not sure though.

What do you mean with making a SetContent method every time you add something? You just have to edit the same SetContent method. In my example above, you just have to add one extra line:

    void SetContent()
    {
        Content = new StackLayout()
        {
            Orientation = Orientation.Vertical,
            Items =
            {
                new Label { Text = "Hello world" },
                new Button((s, e) => SetContent()) { Text = "Update panel" },
                new Slider()
            }
        };
    }

and a slider will appear under the button, without having to re-open Rhino.

I see!
Let me try it out! Many thanks!!!

@Wiley you can also reload the panel by unchecking/checking its name in the Options list:

Hello,

I’m a relatively inexperienced developer and am having similar problems with a WPF / Rhino application in Visual Studio 22 (community).

The problem is hard because VS22 will hot reload successfully on a prior project but not a new project using a new (the most recent) rhino c# template.

Note: I’ve read the MS documentation [ here ] and everything checks out fine. I can apply hot reload on an old project but not the new template.

Has anyone encountered this problem before? What have I missed?

Can you give us some more context, like pasting your codes?

So, I tried to perform this reload in a hacky way, thorough the use of Rhino.UI.Panels.ClosePanel and Rhino.UI.Panels.OpenPanel, but it just doesn’t work, but when I do this manually it does. Is there any automatic implementation for this?