Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How get and set position of node? (Read 4339 times)
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
How get and set position of node?
Mar 9th, 2011 at 5:54pm
Print Post  
var Object = new MyCustomObject();
var node = new DiagramNodeAdapter(form, Object);
double PositionX = node.Bounds.X;
double PositionY = node.Bounds.Y;

If im not wrong i have the X and Y position of that node.

Now i need do some calcs, and reposition that node programtically.

How reposition the node?

This is the only one kind of node on the screen, i not have multile nodes of same kind juts only one.
But how can reposition?
I need reposition programatically on the screen after do some calcs with PositionX PositionY


I asume can be done using
node.Bounds = new Rect(newYvalue, newXvalue, W, H);


var Object = new MyCustomObject();
var node = new DiagramNodeAdapter(form, Object);
double PositionX = node.Bounds.X;
double PositionY = node.Bounds.Y;

//my calcs here with PositonX and positionY

node.Bounds = new Rect(newYvalue, newXvalue, W, H);

But this not work.


  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How get and set position of node?
Reply #1 - Mar 9th, 2011 at 7:08pm
Print Post  
Quote:
node.Bounds = new Rect(newYvalue, newXvalue, W, H);


I suppose you should swap the newYvalue, newXvalue argument positions. X comes first, then Y...
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: How get and set position of node?
Reply #2 - Mar 9th, 2011 at 7:25pm
Print Post  
I know, just a typo error.
node.Bounds = new Rect(X,  Y,  W,  H);

Anyway not work!
What im doing for move is correct?

Why node not moved?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How get and set position of node?
Reply #3 - Mar 9th, 2011 at 7:33pm
Print Post  
Because X,Y is the same as the node's initial position?
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: How get and set position of node?
Reply #4 - Mar 9th, 2011 at 7:42pm
Print Post  
Simple test
Onload i create the node:


var Object = new MyNode();



if (Object != null)



{



Object.ButtonClick1 += new RoutedEventHandler(Click1);



Object.ButtonClick2 += new RoutedEventHandler(Click2);



var node = new DiagramNodeAdapter(form, Object);



node.Bounds = new Rect(100, 100, 34, 40);



form.Nodes.Add(node);







}





Just for test i add  a simple button, and use code for move, but not work


private void button1_Click(object sender, RoutedEventArgs e)
{

var Object = new MyNode();

var node = new DiagramNodeAdapter(form, Object);


node.Bounds = new Rect(0, 0, 34, 40);
}


What im doing wrong? Tongue
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How get and set position of node?
Reply #5 - Mar 9th, 2011 at 7:54pm
Print Post  
The node you create in button1_Click is not the same as the one in OnLoad, and it's even not shown in the diagram.
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: How get and set position of node?
Reply #6 - Mar 9th, 2011 at 11:04pm
Print Post  
How can access to the node already created with code run onload and move programatically?

Thankyou for your patience!!
« Last Edit: Mar 10th, 2011 at 12:28am by PDM. »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How get and set position of node?
Reply #7 - Mar 10th, 2011 at 7:07am
Print Post  
Store a reference to it in a field of the form class:

DiagramNode node;

OnLoad()
{
     node = new DiagramNodeAdapter(...
}

OnClick()
{
     node.Bounds = ...
}

If this is always the first node your app creates, you could also access it through diagram.Nodes[0].
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint