I have two classes that derive from DiagramLink: DiagramSequenceLink and DiagramActionLink. These classes represent workflow sequences and actions that I am modeling in my application. The DiagramSequenceLink contains a List<DiagramActionLink>. In the form's Shown event handler I am populating the Diagram from the workflow by creating and adding links to the Diagram.
Here is the problem. The second time I open the form only the DiagramSequenceLink objects are added to the diagram's Links collection. The DiagramActionLink objects don't get added. That is, the Links.Count is the same after the Links.Add() invocation as it is before. (The first time I open the form after launching my program, all of the links get added to the Diagram's Links collection just fine.) The result is that on the second opening of the form, the sequence links are visible but the action links are not, even though all the action links exist and have the Diagram as their Parent. I know they are there because when I select a sequence link, all of the anchor points of all its action links become visible (when you select a sequence link, my program selects all its action links so they can be manipulated as a group).
Here are snippets of the ctors:
private List<DiagramActionLink> actionlinks; public DiagramSequenceLink(Diagram diagram, DiagramNode origin, DiagramNode destination, int anchor, WorkflowSequence workflowsequence) : base(diagram, origin, destination) { . . . diagram.Links.Add(this); foreach (WorkflowAction action in workflowsequence.Actions) { actionlinks.Add(new DiagramActionLink(Parent, origin, destination, anchor, action)); }
public DiagramActionLink(Diagram diagram, DiagramNode origin, DiagramNode destination, int anchor, WorkflowAction workflowaction) : base(diagram, origin, destination) { . . . diagram.Links.Add(this); [color=Green]// This is the call that fails on the second opening of the form[/color]
The WorkflowSequence and WorkflowAction clases model the workflow in my application.
I am at a loss to explain why the DiagramActionLink objects can be added to the Diagram the first time the form is shown, but not after the form has been closed and then re-opened. Does anybody have any ideas?
|