Get the Vertex(Node) Object user clicked on in MSAGL

1k views Asked by At

So, what is the way to retrieve the object that was under the mouse pointer when user clicked? I assume the gViewer must have some event to do that. In the tutorial i found this idea:

gViewer.SelectionChanged +=
        new EventHandler(gViewer_SelectionChanged);

with gViewer_SelectionChanged being an event handler defined like this:

void gViewer_SelectionChanged(object sender, EventArgs e)

Although i added using statments for all 3 MSAGL dll's, i can't find the Selection changedevent. Is there a special event for that, or am i looking the wrong way? Can it be that i need to handle some mouse event and get object based on it?

Sadly, there are only few MSAGL samples, no documentation and limited comments, so the more questions abount it here - the better.

2

There are 2 answers

0
nineveh.Y On

do you mean get the infomation of each object?

viewer.Click += GraphNode_Click;
...
private void GraphNode_Click(object sender, EventArgs e)
{
    GViewer viewer = sender as GViewer;
    if (viewer.SelectedObject is Node)
    {
        Node node = viewer.SelectedObject as Node;
        //...do works here
    }
}
0
Edward On

The code can not work:

viewer.Click += GraphNode_Click;

It should be like:

viewer.Click += EventHandler(Group_Click);