Open tarp-jusf opened 6 months ago
After looking into this, it seems that DragNewLinkBehavior is being used multiple places. So replacing this behavior will make the whole thing break.
A solution could be to change the RegisterBehavior function replace the class associtated with a certain type of behavior.
That way when you use e.g GetBehavior
After even more investigation, the LinkWidget, which uses DragNewLinkBehavior, is used by the LinkRenderer. The LinkRenderer is not replaceable, unlike other controls that are.
I think there's some architecture design that's gone awry, and trying to change things to fit, becomes a cascade of changes.
There might be some ground-up work that needs to be rethought.
Hello, thank you for opening this issue.
First of all, regarding your specific need, wouldn't using the Options.Links.Factory
(https://github.com/Blazor-Diagrams/Blazor.Diagrams/blob/master/src/Blazor.Diagrams.Core/Options/DiagramLinkOptions.cs#L30) option solve your issue? If the factory returns null (instead of a link instance), then nothing happens. You can simply check whether it's an outgoing port and response accordingly.
Secondly, you are right. The fact that other components use behaviors directly is an issue since that would stop users from essentially replacing said behavior, and that's not what I want the library to do, since I emphasize heavily on customizability.
I was thinking for a while about creating interfaces or abstract classes for the base behaviors, so that:
I'll probably start working on that soon, let me know what you think!
I'm using an external service to create connections. It would be interesting to customize existing behavior.
@zHaytam thanks for this great library.
I have created some derived behaviors and, to not break so much your implementation I changed the GetBehavior function and, if the asked one not found, check if has a derived one.
I have tried making a custom DragNewBehavior, because I only want to be able to drag links from outgoing Ports. This results in the RenderLinkTree call to experience a NullReferenceError.
I have tried copying the DragNewBehavior code to check if it was my code, but it also breaks. I traced some code while debugging and copied the tracelog up until the error.