We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Coordenates X Y in a textnode

Hi,

I need to know, when I move a textnode with a keyboard or a mouse event, its coordenates X and Y. Its so important for me to know the correct coordenates because I save them in an .xml document that I use for configurate a display in a PLC.

I used an event :

void EventSink_NodeDoubleClick(NodeMouseEventArgs evtArgs)

Node node = evtArgs.Node;

 int valorX = (int)node.PinPoint.X - (int)node.PinPointOffset.Width;
 int valorY = (int)node.PinPoint.Y - (int)node.PinPointOffset.Height;

But if I try to get the coordenates in a diagram1_mousedown:

private void diagram1_MouseDown(object sender, MouseEventArgs e)

(Node)this.diagram1.Controller.GetNodeUnderMouse(new Point(e.X, e.Y))

int valorX = (int)node.PinPoint.X - (int)node.PinPointOffset.Width;
 int valorY = (int)node.PinPoint.Y - (int)node.PinPointOffset.Height;

I don't get the same values!! Could you help me??




1 Reply

NG Naganathan Ganesh Babu Syncfusion Team January 27, 2017 06:58 AM UTC

Hi Blanca, 
Thanks for contacting Syncfusion support. 
We have created a simple sample to achieve your requirement. We suggest you to use Diagram.Model.EventSink’s “PinpointChanging/PinpointChanged” events and Node’s “BoundingRectangle” property to get the node’s coordinates value while performing the drag/drop operation using mouse/keyboard. Please refer to the below sample and code example. 
Code example: 
[C#] 
diagram1.Model.EventSink.PinPointChanged += new PinPointChangedEventHandler(EventSink_PinPointChanged); 
diagram1.Model.EventSink.PinPointChanging += new PinPointChangingEventHandler(EventSink_PinPointChanging); 
void EventSink_PinPointChanging(PinPointChangingEventArgs evtArgs) 
{ 
Node node = evtArgs.NodeAffected as Node; 
float x = node.BoundingRectangle.X; 
float y = node.BoundingRectangle.Y;             
} 
 
void EventSink_PinPointChanged(PinPointChangedEventArgs evtArgs) 
{ 
Node node = evtArgs.NodeAffected as Node; 
float x = node.BoundingRectangle.X; 
float y = node.BoundingRectangle.Y; 
MessageBox.Show("X Value : " + x.ToString() + "\n" + "Y Value : " + y.ToString(), "Nodes Coordinates", MessageBoxButtons.OK); 
} 
Sample: 
Regards, 
Naganathan K G 


Loader.
Up arrow icon