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

Question on migrating to v3 #289

Closed glinkot closed 1 year ago

glinkot commented 1 year ago

I've got the following code running in v2.1.6. I see the new 'anchor' concept. What's the recommended way now to get children/parents as I'm doing below? (assuming a child is the source and parent is target).

` public PortModel InPort; // Coming in from children public PortModel OutPort; // Heading out to parents

    public List<ObjectiveNodeModel?> ChildNodes
    {
        get
        {
            // Maybe I should return ID here, because I'm casting the basic node to an objectivenodemodel - things I've added like diagram, DataId won't be populated?  Or will they, because thats
            // what they really are?  Would have to test that one.
            // If it doesn't preserve the extras, return just Id then create a 'get node' method that you use as needed.

            if (usingPorts)
            {
                return diagram.Links.Where(x => x.TargetPort == this.InPort).Select(y => (ObjectiveNodeModel)y.SourcePort.Parent).ToList();

                //var incomingLinks = this.Links.Where(x => x.TargetPort == this.InPort);
                //return incomingLinks.Select(x => (ObjectiveNodeModel)x.SourceNode).ToList();
            }
            else
            {
                return diagram.Links.Where(x => x.TargetNode == this).Select(y => (ObjectiveNodeModel)y.SourceNode).ToList();
            }
        }
    }

    public List<ObjectiveNodeModel?> ParentNodes
    {
        get
        {
            if (usingPorts)
            {
                return diagram.Links.Where(x => x.SourcePort == this.OutPort).Select(y => (ObjectiveNodeModel)y.TargetPort.Parent).ToList();
            }
            else
            {
                return diagram.Links.Where(x => x.SourceNode == this).Select(y => (ObjectiveNodeModel)y.TargetNode).ToList();
            }
        }
    }`
zHaytam commented 1 year ago

Hello,

Very simple, check out this example:

I am rewriting the website and documentation, once that's done 3.0.0 will be official, sorry for the trouble!

glinkot commented 1 year ago

Great, thanks for that!