Setting available ports based on current

Hi all, new at this GoDiagram stuff so bare with me Embarrassed

I am developing a flow chart application, the charts are very simple, there are only 4 node types:

Start, End, Step and Decision.

I am trying to control the available ports for each node type based on the current connections. The start and end node are simple, they only allow one outgoing and one incoming respectively.

The step and decision nodes are proving more difficult.

  • A step node can have 1 outgoing connection, and 3 incoming connections.
  • The decision node can have 2 incoming connections, and two outgoing connections.

When either of these node types are added I want all of their ports to be available for any type (in/out) connections. Once the user starts to add connections between the nodes I want to validate their port settings and disable/enable ports to prevent the user from making any illegal connections between nodes.

Does anyone have experience doing this? And if so, which event should I be overriding to catch the link creation, and then how can I calculate which ports have connections, and which need to be disabled?

Any help with this is mucho appreciated!
Regards

What’s you base node class?

A GraphNode which inherits from the GoTextNode

<span =“apple-style-span”="" style=": rgb248, 248, 252; ">

Take a look at the LimitedNodePort class in the LimitedNode.cs/.vb file of the Demo1 sample.

Basically you need to override GoPort.CanLinkFrom and .CanLinkTo, to check the LinksCount property. You can override GraphNode.CreatePort to return an instance of your class, rather than the standard behavior as documented in the API reference.

Now… here’s the (sort of) tricky part.

LimitedNodePort implements a SourceLinksCount (which counts the items in the Port.SourceLinks IEnumerable).

What you want isn’t the port’s SourceLinks count… what you want is the node’s SourceLinks count (which will include all 4 of the GoTextNode ports).

So… change the SourceLinksCount (and DestinationLinksCount) to be the count of this.Node.SourceLinks (and this.Node.DestinationLinks).

Thanks for the reply Jake.

My project ‘Demo13’ does not contain a class named LimitedNode.cs? Would you have a copy of this class?

How do I override CanLinkFrom and CanLinkTo? I presume I can’t override them from within my GraphNode class?

Also while I have you, does GoDiagram have documentation on all the classes and class property’s? I haven’t found anything like this in my documentation. There are many properties which I am having to figure out as I go along, would be nice to have some reference material for each property.

Oh, sorry. You’re using Express?

The API reference for the built in nodes is available in Visual Studio help. For node (and other) classes in the samples, the code and comments are the reference.

The sample class LimitedNode isn’t in Express. But, I took a quick look, and that’s because it derives from GoGeneralNode, which isn’t part of Express.

The good news is that the <span =“Apple-style-span” style=": rgb248, 248, 252; “>CanLinkFrom and CanLinkTo strategy that I was outlining above should still work in Express. (at least I don’t see any reasons it won’t)
<span =“Apple-style-span” style=”: rgb248, 248, 252; “>

<span =“Apple-style-span” style=”: rgb248, 248, 252; ">So… grab a copy of the full GoDiagram Win kit, install that and look in the NodeLinkDemo sample.

Thanks Jake, I will take a look at this when I get around to trying to figure this issue out, its not a priority for me right now.