Blazor-Diagrams / Blazor.Diagrams

A fully customizable and extensible all-purpose diagrams library for Blazor
https://blazor-diagrams.zhaytam.com
MIT License
919 stars 176 forks source link

Hide/show ports when unlocked/locked #243

Closed jchown closed 1 year ago

jchown commented 1 year ago

On my nodes which have a variable number of inputs, I have an "empty" port ready to receive a new connection.

I'd like to hide these ports when they aren't used - i.e. when the diagram is locked.

I tried something like<div hidden="@(port.HideIfLocked && Node.Locked)"> around the PortRenderer in my node component, but it doesn't respond to Locked change states.

I appreciate that this may be a lack of understanding of Blazor rather than your library, but I can't see what the difference is between the Locked property and any other?

zHaytam commented 1 year ago

Hello, which version are you using?

jchown commented 1 year ago

I'm using v2.1.6

zHaytam commented 1 year ago

Amd how do you set the Locked property?

jchown commented 1 year ago

I lock/unlock the entire diagram:

    private void SetLocked(bool locked)
    {
        foreach (var node in diagram.Nodes)
        {
            node.Locked = locked;

            foreach (var port in node.Ports)
                port.Locked = locked;
        }

        foreach (var link in diagram.Nodes)
            link.Locked = locked;
    }
zHaytam commented 1 year ago

Please add a call to Node.Refresh() at the end in order to refresh the UI

jchown commented 1 year ago

Aha! Yes, that fixed it. Many thanks!