Something weird happens when I change the image of a GoBasicNode.
For starters I am creating a GoImage:
Public Sub ShowStatus(Node As GobasicNode, Status as String)
Dim image As New GoImage()
image.NameIsUri = True
image.Selectable = False
Dim margin As SizeF = Node.MiddleLabelMargin
image.SetSpotLocation(2, Node, 2, margin.Width / 2, margin.Height / 2)
Select Case Status 'let's assume that the status is 0 at first
Case "0"
image.Image = (An Image from my Resources)
Case "1"
image.Image = (An Image from my Resources)
Case "2"
image.Image = (An Image from my Resources)
Case Else
image.Image = (An Image from my Resources)
End Select
Node.Add(image) 'the Image is added to the node
End Sub
Everything good sofar.But when i try to change this image within the Node something kinda weird happens:
For example after a right click action where the image should change I do the following:
Node.Image.Remove() ‘the Image is removed from the node
ShowStatus(Node, 2)’.
So now that the Image in the Node has successfully changed the weirdest thing happens. The whole Node is moved a few pixels to the downright direction.Just a few pixels.Enough though for the user to notice it. When I reload the form the Node is in its right place.
What can I do to eliminate this tiny change?
Please help
Yes. Images are the same size. The whole Node moves slightly not just the image within. As you assumed, I have added the Image Property. Actually I am using the PersonNode from the DatasetDemo example(with a few changes and additions). Now that you mention it I do use the LayoutChildren to handle the layout and the problem is spotted in this function and specifically in the
back.Bounds = New Rectangle(center.X - newWidth / 2, center.Y - newHeight / 2, newWidth, newHeight)
I had a tiny change there where :
back.Bounds = New Rectangle(center.X - newWidth / 2, center.Y - newHeight / 2, newWidth + 5, newHeight + 5).
Those little fives turned out to do the damage…everytime something happend that would trigger the LayoutChildren would move the Node +5.
Those are now removed and nothing moves :)
Thanks for your help!!