Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic how to position node??????? (Read 2109 times)
duclm
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Sep 2nd, 2011
how to position node???????
Sep 2nd, 2011 at 2:57am
Print Post  
Hi,
I am new to MindFusion.
I am trying to create a series of nodes and place them in with predefined locations. For some reason, it does not work.

Dim nodeMap As New Dictionary(Of String, DiagramNode)
Dim bounds As New Rect(600, 600, 100, 200)
Dim myShape As Shape

myShape = GetShape(r("NodeTypeDesc"))


Dim DiagramNode = diagram.Factory.CreateShapeNode(New Rect(New Size(bounds.Width, bounds.Height)), myShape)



DiagramNode.Bounds = New Rect(500, 500, 50, 200)


'Dim DiagramNode = New CustomNodeStart()


DiagramNode.Image = New BitmapImage(New Uri("ac0026-64.png", UriKind.Relative))


DiagramNode.ImageAlign = ImageAlign.TopCenter



DiagramNode.Text = r("FlowChartItemDesc").ToString


DiagramNode.Uid = r("FlowChartItemId").ToString



'objNode = New clsNode(r("FlowChartItemId"), r("NodeTypeDesc"), r("FlowChartItemDesc").ToString, New Rect(0, 0, 90, 50), myShape, r("FlowChartParentId"), r("FlowChartChildId"))


'm_objNodeCollection.Add(objNode)


nodeMap(r("FlowChartItemId").ToString) = DiagramNode


diagram.Nodes.Add(DiagramNode)


i am not sure if i am doing any wrongs?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: how to position node???????
Reply #1 - Sep 2nd, 2011 at 4:44am
Print Post  
Hi,

What does not work exactly?

This line will move the node to position 500,500, which could be outside the visible part of the diagram depending on the diagram origin point and measure unit:

DiagramNode.Bounds = New Rect(500, 500, 50, 200)

Also you shouldn't call diagram.Nodes.Add(DiagramNode) in this case, since CreateShapeNode automatically adds the node. Call Nodes.Add only after using the node class constructor to create nodes.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
duclm
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Sep 2nd, 2011
Re: how to position node???????
Reply #2 - Sep 2nd, 2011 at 5:53am
Print Post  
oh sorry i forgot to comment out that line
diagram.Nodes.Add(DiagramNode)
it should not be there.

Anyway, i didnot specify height and width for my diagram. I also tried to change value of DiagramNode.Bounds and the position of my node is still the same....
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: how to position node???????
Reply #3 - Sep 2nd, 2011 at 6:03am
Print Post  
Does the node stay at the top-left of the diagram regardless of its Bounds value? In such case check if you aren't calling the ResizeToFitItems method later - it will set diagram.Bounds to the union of all nodes, and so the left-most nodes will appear close to the border. If you need to preserve the diagram origin, you could do something like this:

dim diagramBounds = diagram.GetContentBounds(...)
diagramBounds.X = 0
diagramBounds.Y = 0
diagram.Bounds = diagramBounds

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
duclm
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Sep 2nd, 2011
Re: how to position node???????
Reply #4 - Sep 2nd, 2011 at 6:18am
Print Post  
Thank you, i will try that and let you know.
Good weekend...
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint