Link not snapping to Port

I need a link which will only be connected to a FromPort and is drawn freely with mouse out on canvas, NOT snapping to the nearest port…

See if the MovableLinkApp sample gives you what you need. From you problem statement, I’m not sure it does entirely.

My previous post I put together in a hurry before running from the office yesterday; here are more details:

Godiagram Winforms, ver 4.1.0.4

The enclosed graphics illustrates the challenge.

I have nodes (circles) connected with “ordinary” links, connecting to ports on the to and from nodes. All good.
I also need “arrows” (yellow in fig) connected to a FromPort on a node but not to any ToNode.
The arrow is currently implemented based on a GoLabeledLink. I also
have a Label connected to the “Arrow” LinkClass, which can be
moved around where I want to put it (e.g. values 37 and 41 in figure).
The label part works fine.
I see two alternatives for creating the yellow arrows when building the diagram:

a) drag a predifined arrow with default length and a dummy label from
palette onto canvas, and then using mouse, connect drag the from end to
fromPort and position the arrow tip where ever it fits best.

b) select a linktype from a menu item (GoView.NewLinkClass =
typeof(ArrowLinktype) ) and then start drawin in a FromPort on a node,
and complete the arrow where I release the mouse button.

I’ve checked to MoveableLinks app, and the key there seems to be
overriding the PickNearestPort method, but it seems to be totally “Port
oriented” since it returns an IGoPort…

Maybe another approach would be better…?

ok… presumably, you want mouse-down on the node to create a black link to another node. If that’s true, I can see a couple of options here.



1) create the yellow arrow links with a right-click on the node. You could use the code in MovableLinkApp to support links with no “toPort”. (You will have to do the routing, since routing depends on 2 ports. I think you could override UpdateRoute to do this.



2) Use the drag-a-link-from-palette strategy that MovableLinkApp does. The Dragging tool there allows a link to be dragged to a port and connect to it.



do these yellow links EVER connect to a port? If not, you’ll have to make sure they don’t see a valid “to port” when linking.



Another (probably simpler) approach would be to make the number (37 or 41) be a real node and connect the link to that. That’s more or less how you have 37 in the drawing above anyway. This would save you from doing any custom routing code, or dealing with links with only a port on one end. (If you picked this approach, you could customize the linking tool to create the right type of link based on the node you connected to.)

the idea was to have Yellow links NEVER connect to a port.

But I agree; probably the best solution will be to create a node type holding the result data (e.g. 37 & 41) and hook the yellow link from black circle to result node in a std goDiagram way. Functionality will then adhere more to how GoDiagram regular use, which is good.

Thanks for input; a classical example where a second opinion removes the fog and clutter of one-man-thinking-on-his-own… Thumbs%20Up