Links not loading correctly

Hi

This if for GoXam 2.1.1.5.

I have a diagram that’s using the GraphLinksModel model. After the diagram has loaded, the links are either positioned out of place or are not connected to the nodes they’re supposed to be connected to.

Below is a screenshot with the issues bordered in red:

However, if I move one of the affected nodes, the links seem to “snap” back into place:

This is the code I’m using to load the model:

protected virtual Task LoadModelAsync(string xmlDiagramData)
{
return Task.Factory.StartNew(() => {

            XElement root = XElement.Parse(xmlDiagramData);
            Model.Load<BaseGraphLinksModelNodeData<TNodeKey>, BaseGraphLinksModelLinkData<TNodeKey, TPortKey>>(root, LoadNode, LoadLink);
        }, CancellationToken.None, TaskCreationOptions.None, UISynchronizationContext.Instance.CreateUITaskScheduler());
    }

protected virtual BaseGraphLinksModelNodeData LoadNode(XElement nodeElement)
{
Guard.ArgumentNotNull(nodeElement, “nodeElement”);
BaseGraphLinksModelNodeData node = null;

        if(nodeElement.Name == NodeElementName) {

            var elementData = new ElementData(nodeElement, ElementData.ElementType.Node, this);
            node = NodeLoaderChain.Execute(elementData) as BaseGraphLinksModelNodeData<TNodeKey>;                                
        }

        return node;
    }

    protected virtual BaseGraphLinksModelLinkData<TNodeKey, TPortKey> LoadLink(XElement linkElement)
    {
        Guard.ArgumentNotNull(linkElement, "linkElement");
        BaseGraphLinksModelLinkData<TNodeKey, TPortKey> link = null;

        //TODO:
        //Need to change this to use ChainOfResponsibility instead
        if(linkElement.Name == LinkElementName) {

            var elementData = new ElementData(linkElement, ElementData.ElementType.Link, this);
            link = LinkLoaderChain.Execute(elementData);                               
        }
       
        return link;
    }

Here’s the XML data of the diagram when I attempt to load it:

<Node Key=“9” Category=“SwimlaneHorizontal” IsSubGraph=“true” Location=“350 100” Text=“Customer” NodeType=“SwimlaneNode”

Width=“1570” /> <Node Key=“10” Category=“SwimlaneHorizontal” IsSubGraph=“true” Location=“350 250” Text=“Sales” NodeType=“SwimlaneNode”

Width=“1570” /> <Node Key=“12” Category=“SwimlaneHorizontal” IsSubGraph=“true” Location=“350 400” Text=“Credit & Invoicing”

NodeType=“SwimlaneNode” Width=“1570” /> <Node Key=“13” Category=“SwimlaneHorizontal” IsSubGraph=“true” Location=“350 550” Text="Production

Control" NodeType=“SwimlaneNode” Width=“1570” /> <Node Key=“14” Category=“SwimlaneHorizontal” IsSubGraph=“true” Location=“350 700”

Text=“Copying” NodeType=“SwimlaneNode” Width=“1570” /> <Node Key=“15” Category=“SwimlaneHorizontal” IsSubGraph=“true” Location=“350 850”

Text=“Assembly & Shipping” NodeType=“SwimlaneNode” Width=“1570” /> <Node Key=“4” Category=“Shape” Location="-360 100" Text=“Start”

NodeType=“ShapeNode” Height=“30” Width=“60” Shape=“159” /> <Node Key=“2” Location="-250 100" Text=“Order Generated” NodeType=“ProcessNode”

ProcessStatus=“1” IsTemporary=“true” /> <Node Key=“3” Location="-250 250" Text=“Order Completed” NodeType=“ProcessNode” ProcessStatus=“1”

IsTemporary=“true” />

<Node Key=“7”

Category=“Shape” Location=“30 400” Text=“Credit OK?” NodeType=“ShapeNode” Shape=“114” /> <Node Key=“8” Location=“30 250” Text="Credit

Problem Addressed" NodeType=“ProcessNode” ProcessStatus=“1” IsTemporary=“true” /> <Node Key=“11” Category=“Shape” Location=“180 250”

Text=“Credit OK?” NodeType=“ShapeNode” Shape=“114” /> <Node Key=“16” Location=“180 400” Text=“Credit Approved” NodeType=“ProcessNode”

ProcessStatus=“1” IsTemporary=“true” /> <Node Key=“17” Location=“360 400” Text=“Invoice Prepared” NodeType=“ProcessNode” ProcessStatus=“1”

IsTemporary=“true” />

<Node

Key=“20” Category=“Shape” Location=“350 550” Text=“In Stock?” NodeType=“ShapeNode” Shape=“114” /> <Node Key=“21” Location=“460 700”

Text=“Production Scheduled” NodeType=“ProcessNode” ProcessStatus=“1” IsTemporary=“true” /> <Node Key=“22” Location=“610 700” Text="Diskettes

Copied" NodeType=“ProcessNode” ProcessStatus=“1” IsTemporary=“true” /> <Node Key=“23” Location=“610 860” Text=“Packages Assembled”

NodeType=“ProcessNode” ProcessStatus=“1” IsTemporary=“true” /> <Node Key=“24” Location=“750 860” Text=“Order Picked” NodeType=“ProcessNode”

ProcessStatus=“1” IsTemporary=“true” /> <Node Key=“25” Location=“1010 860” Text=“Order Shipped” NodeType=“ProcessNode” ProcessStatus=“1”

IsTemporary=“true”> 83:Measure <Node Key=“26”

Location=“890 400” Text=“Invoice Sent” NodeType=“ProcessNode” ProcessStatus=“1” IsTemporary=“true” /> <Node Key=“27” Location=“1010 100”

Text=“Process Payment” NodeType=“ProcessNode” ProcessStatus=“1” IsTemporary=“true” /> <Node Key=“28” Category=“Shape” Location=“1070 100”

Text=“End” NodeType=“ShapeNode” Height=“30” Width=“60” Shape=“159” /> <Node Key=“29” Category=“Shape” Location=“750 400” Text="Shipped

Order?" NodeType=“ShapeNode” Width=“90” Shape=“114” /> <Link From=“4” To=“2” FromPort=“R” ToPort=“L” Points="100 100 110 100 110 100 110 100

110 100 120 100" /> <Link

From=“3” To=“5” FromPort=“B” ToPort=“T” Points=“180 290 180 300 180 325 180 325 180 350 180 360” /> <Link From=“5” To=“6” FromPort=“R”

ToPort=“L” Points=“240 400 250 400 255 400 255 400 260 400 270 400” /> <Link From=“6” To=“7” FromPort=“R” ToPort=“L” Points="390 400 400 400

405 400 405 400 410 400 420 400" /> <Link From=“7” To=“8” FromPort=“T” ToPort=“B” Text=“No” Points="460 360 460 350 460 323.6683349609375

460 323.6683349609375 460 300 460 290" /> <Link From=“8” To=“11” FromPort=“R” ToPort=“L” Points="520 250 530 250 545 250 545 250 560 250 570

250" /> <Link From=“11” To=“19” FromPort=“R” ToPort=“L” Text=“No” Points="650 250 660 250 702.303466796875 250 702.303466796875 250 745 250

755 250" /> <Link

From=“7” To=“16” FromPort=“R” ToPort=“L” Points=“500 400 510 400 525 400 525 400 540 400 550 400” /> <Link From=“16” To=“18” FromPort=“B”

ToPort=“T” Points=“610 440 610 450 610 475 610 475 610 500 610 510” /> <Link From=“18” To=“20” FromPort=“R” ToPort=“L” Points="670 550 680

550 705 550 705 550 730 550 740 550" /> <Link From=“16” To=“17” FromPort=“R” ToPort=“L” Points="670 400 680 400 700 400 700 400 720 400 730

400" /> <Link From=“20” To=“21” FromPort=“R” ToPort=“T” Text=“No” Points="820 550 830 550 891.6798095703125 550 891.6798095703125 650 890

650 890 660" /> <Link

From=“23” To=“24” FromPort=“R” ToPort=“L” Points=“1100 860 1110 860 1110 860 1110 860 1110 860 1120 860” /> <Link From=“24” To=“25”

FromPort=“R” ToPort=“L” Points=“1240 860 1250 860 1310 860 1310 860 1370 860 1380 860” /> <Link From=“22” To=“23” FromPort=“B” ToPort=“T”

Points=“1040 740 1040 750 1040 780 1040 780 1040 810 1040 820” /> <Link From=“20” To=“23” FromPort=“B” ToPort=“L” Text=“Yes” Points="780 590

780 600 780 860 875 860 970 860 980 860" /> <Link From=“27” To=“28” FromPort=“R” ToPort=“L” Points="1500 100 1510 100 1510 100 1460 100 1460

100 1470 100" /> <Link

From=“29” To=“26” FromPort=“R” ToPort=“L” Text=“Yes” Points=“1225 400 1235 400 1242.5 400 1242.5 400 1250 400 1260 400” /> <Link From=“29”

To=“24” FromPort=“B” ToPort=“T” Text=“No” Points=“1180 440 1180 450 1180 630 1180 630 1180 810 1180 820” /> <Link From=“26” To=“27”

FromPort=“T” ToPort=“L” Text=“Invoice” Points=“1320 360 1320 350 1320 100 1345 100 1370 100 1380 100” /> <Link From=“25” To=“27”

FromPort=“T” ToPort=“B” Text=“Product” Points=“1440 820 1440 810 1440 480 1440 480 1440 150 1440 140” />

Any suggestions on what the problem could be?

Thanks
Justin

Is this for WPF 4.5?

I see you have Points="…" information on your link data. How are you initializing the Link.Route.Points?

Hi Walter

This is for Silverlight.

I’m not doing anything with the Points data. I’m relying on the layout system to plot the links relative to the nodes thay are connected to. Should I be doing something with Points data?

Here is the link template:

<go:LinkPanel
go:Part.SelectionAdorned=“true”
go:Part.SelectionElementName=“Path”
go:Part.SelectionAdornmentTemplate="{StaticResource DefaultLinkSelectionAdornmentTemplate}"
ivGoXam:DoubleClickTextEditBehaviour.Part="{Binding Part}"
go:Part.Reshapable=“True”>
go:Link.Route
<go:Route
Routing=“Orthogonal”
Curve=“JumpOver”
Corner=“5”
RelinkableFrom=“True”
RelinkableTo=“True”
/>
</go:Link.Route>

<go:LinkShape Stroke=“Transparent” StrokeThickness=“10” />
<go:LinkShape x:Name=“Path” Stroke=“Black” StrokeThickness=“1” />

            <TextBlock Text="{Binding Data.Text, Mode=TwoWay}"  go:Part.TextEditable="True" Foreground="Black"   go:LinkPanel.Offset="0 -10" go:LinkPanel.Orientation="Upright" />
        </go:LinkPanel>
    </DataTemplate>

Thanks
Justin

It just seems odd to have that property on your link data, especially since the Links are Reshapable by the user, unless some code put that information there. So some code could be reading that “Points” list, too. Could you check that that is not the case, or if it is the case, that the Link.Route.Points list is being written and read with the correct values in the correct manner, as shown in several of the sample apps?

Hi Walter

Yes, you are correct. I forgot that we are using the same CustomPartManager that is that being used in the “Draggable Links” sample. We need to store the Points data because links are reshapable and because we have ValidUnconnectedLinks = Go.Model.ValidUnconnectedLinks.Allowed set on the Model.

This is the first time we’ve encountered this problem and unfortunately the user that created this diagram cannot recall the steps he took in order to get it to break the link placement. If I move each node slightly, so that the links “snap” back into place and then re-save the diagram, everything is fine when I reload the diagram. So I’m not sure if it’s the saved Points data in the original diagram that are bad or if there’s something I’m forgetting to do when loading the diagram.

Any suggestions?

Thanks
Justin

Well, you can look at the points values in the saved model to see if they are legitimate given the locations of the nodes.

I’m guessing the Points data somehow got screwed up. But because I can’t reproduce it, I can’t determine if it’s a bug or some action taken by the user. I’ll have to play with it a bit more and will let you know if I discover anything.