Hi there
I'm getting some strange behaviour with the code below:
Private Sub LaneGrid_CellBoundsChanged(ByVal sender As Object, ByVal e As CellBoundsEventArgs)
If e.NewBounds.Y <> e.OldBounds.Y Then
For Each actNode As ActivityNode In diagram.Nodes
If e.OldBounds.Contains(actNode.GetCenter) Then
Dim vertMoveDist = e.NewBounds.Y - e.OldBounds.Y
actNode.Bounds = New RectangleF(actNode.Bounds.X, actNode.Bounds.Y + vertMoveDist, actNode.Bounds.Width, actNode.Bounds.Height)
End If
Next
End If
'reset the diagram size to match the grid
SetBoundsToGrid()
End Sub
What I am trying to achieve is: when a user resizes a lane (i.e. a diagram.lanegrid rowheader) the nodes in all of the lanes below the lane that was resized should move down by the amount that the lane was resized by.
The problem comes with comparing the new and old Y values:
Assume a grid with two lanes (i.e two cells)
Lane 0: X = 0, Y = 0, Height = 20, Width = 100
Lane 1: X = 0, Y = 20, Height = 20, Width = 100
If I resize lane 0 from height of 20 to height of 30, lane 1's newbounds.Y will correctly show as 30, but the oldbounds.Y is not 20.
All the other values for the oldbounds (X, width, height) are correct but the Y is not.
Is this a bug or am I being an idiot?
On a related note, am I right to be doing this in the first place or is there some built in features to do the above - i.e. to keep the nodes in their lanes when a lane is resized? It isn't that useful to resize a lane and for all of the nodes below to stay put while their lanes move I guess.
Many thanks
Tom
Edit for the benefit of anyone else looking at this later: The activityNode is a custom type derived from the ShapeNode class. The code above should work in the same way for anything derived from DiagramNode.
Edit2: I have a workround for this so no panic.