|
Group: Forum Members
Posts: 16,
Visits: 1
|
Thank you for the very quick reply - and my apologies for not responding sooner.
The code you provided allowed me to add a solution that the product manager is happy with - and so things are mostly good. It isn't exactly as I described, but he is content.
I tried a different solution, which kind of works, but sometimes causes an exception. Since the other solution works, we aren't too worried, but I am kind of interested in what I'm missing/doing wrong.
In the nDrawingView1_Click event I check to see if the control key and the alt key is down. If so, I try to cycle through the shapes under the mouse (in our case, we have a class attached to the tag to store some custom properties) and then try to do a single select on the next shape under the mouse. Most of the time this works. Sometimes I get an exception. I am thinking that maybe the _click event is the wrong event? Is there a better one? here is the code:
if ((Control.ModifierKeys & Keys.Control) == Keys.Control) {
if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt) { try { ////////////////////////////////////// // Get a list of nodes under the // mouse ointer NPointF location = nDrawingView1.GetMousePositionInDevice(); NHitTestContext hitTestContext = nDrawingView1.ProvideDocumentHitTestContext(); NNodeList nodes = nDrawingDocumentEditors.HitTest(location, -1, NFilters.Shape2D, hitTestContext); if (nodes != null) { if (nodes.Count > 1) { ///////////////////////////////////// // Go through each node and grab // its tag. int MyNodesSelectedIndex = 0; for (int ii = 0; ii < nodes.Count; ii++) { NShape LclShape; LclShape = nodes[ii] as NShape; if (LclShape != null) { MentorCustomShapeTagBase LclTag; LclTag = LclShape.Tag as MentorCustomShapeTagBase; if (LclTag != null) { ///////////////////////////////////// // Compare the current tag with the // tag on the property grid. If it // is the right one, select the next // one or wrap to the beginning of the // list if (propertyGrid1.SelectedObject != null) { if (LclTag == propertyGrid1.SelectedObject) { MyNodesSelectedIndex = ii + 1; if (MyNodesSelectedIndex >= nodes.Count) { MyNodesSelectedIndex = 0; } break; } } } } // end if } try { nDrawingView1.Selection.SingleSelect(nodes[MyNodesSelectedIndex]); } catch (Exception ex) { string LclString = ex.Message;
}
} } } catch (Exception ex) { string LclString = ex.Message; // for debug purposes } } }
|