Hello Stoyo,
I am creating the node like this: [code] DiagramLink newLink = diagram.Factory.CreateDiagramLink(node, destinationNode); [/code]
The diagram code look like this: [code]diagram.NodeActivated += new NodeEventHandler(diagram_NodeActivated); diagram.NodeDeactivated += new NodeEventHandler(diagram_NodeDeactivated); diagram.NodeDeleting += new NodeValidationEventHandler(diagram_NodeDeleting); diagram.NodeClicked += new NodeEventHandler(diagram_NodeClicked); diagram.LinkCreated += new LinkEventHandler(diagram_LinkCreated); diagram.LinkDeleting += new LinkValidationEventHandler(diagram_LinkDeleting); diagram.LinkClicked += new LinkEventHandler(diagram_LinkClicked); diagram.LinkDeselected += new LinkEventHandler(diagram_LinkDeselected); diagram.DragOver += new DragEventHandler(diagram_DragOver); diagram.Drop += new DragEventHandler(diagram_Drop); diagram.LinkHeadShape = ArrowHead.Triangle; diagram.Bounds = new Rect(0,0,2000,2000); diagram.ShowGrid = true; diagram.GridSizeX = 15; diagram.GridSizeY = 15; diagram.AlignToGrid = true; diagram.ShowAnchors = ShowAnchors.Auto; diagram.AllowDrop = true; diagram.AllowUnanchoredLinks = false; diagram.AllowUnconnectedLinks = false; diagram.Behavior = Behavior.DrawLinks;[/code]
The nodes are dragged onto the diagram. The xaml code is: [code]<diagram:NodeListView x:Name="shapeList" BorderBrush="Transparent" BorderThickness="0" Background="Transparent" Margin="2"> <!--<diagram:ShapeNode x:Name="shapeKbaBox" Shape="DividedEvent" Bounds="2,2,25,25" Brush="AliceBlue" diagram:NodeListView.Label=" KBA Element "/>--> <diagram:TableNode x:Name="shapeKbaTable" ConnectionStyle="Both" ColumnCount="2" RowCount="4" Bounds="2,2,50,50" Brush="LightSteelBlue" diagram:NodeListView.Label=" KBA Element " Style="RoundedRectangle" Grid.IsSharedSizeScope="True" IgnoreLayout="False" Obstacle="False" CellFrameStyle="None" CellCustomDraw="None" AllowDrop="True" /> </diagram:NodeListView> [/code]
Using the diagram_Drop event I do: [code] node.AllowIncomingLinks = false; TableNode tNode = (node as TableNode); tNode.Bounds = new Rect(tNode.Bounds.Left - 70, tNode.Bounds.Top - 100, 140, 140); node.AnchorPattern = kbaAnchorPattern; [/code]
The anchor patterns assigned to each Node looks like this: [code]AnchorPattern kbaAnchorPattern = new AnchorPattern(new AnchorPoint[] { new AnchorPoint(0, 0, true, true,MarkStyle.Circle,new SolidColorBrush(Colors.Red)), new AnchorPoint(0, 100, true, true,MarkStyle.Circle,new SolidColorBrush(Colors.Red)), new AnchorPoint(100, 0, true, true,MarkStyle.Circle,new SolidColorBrush(Colors.Red)), new AnchorPoint(100, 100, true, true,MarkStyle.Circle,new SolidColorBrush(Colors.Red)), new AnchorPoint(50, 0, true, true,MarkStyle.Circle,new SolidColorBrush(Colors.Red)), new AnchorPoint(100, 50, true, true,MarkStyle.Circle,new SolidColorBrush(Colors.Red)), new AnchorPoint(50, 100, true, true,MarkStyle.Circle,new SolidColorBrush(Colors.Red)), new AnchorPoint(0, 50, true, true,MarkStyle.Circle,new SolidColorBrush(Colors.Red)) }); [/code]
I have a pattern that specifies which nodes should be linked. If a user has not added the required links, the rest are filled in for the user. The links crated in code are not staying connected.
After inspecting the properties of the links, I have noticed (for example) on the user created link: * OriginAnchor = -1 and OriginIndex = 2 On the code created link: * OriginAnchor = 5 and OriginIndex = -1
I suspect this has something to do with the problem?
Thanks again. Darren
|