This project has moved and is read-only. For the latest updates, please go here.

Make some shapes unselectable.

Oct 29, 2013 at 4:01 AM
Edited Oct 29, 2013 at 4:03 AM
I want to make some shape types unselectable. (Ex. Rectangle type should not be selectable)
I tried UnselectAll() method, but it works abnormally.
private void display1_ShapesSelected(object sender, EventArgs e)
Please help me. Could you give sample code?
Oct 29, 2013 at 9:22 AM
Edited Oct 29, 2013 at 9:23 AM
"UnselectAll" is the opposite of "SelectAll" and as far as I know, it does what it's expected to do:
Unselect all selected shapes (clear the selection).

In your case, you have to handle the ShapesSelected event of the display component and unselect the shapes that should not be selectable:
private void display_ShapesSelected(object sender, EventArgs e) {
    Display display = currentDisplay;
    // Find all selected shapes of type "Box" and store them in a list
    List<Dataweb.NShape.GeneralShapes.Box> selectedBoxes = new List<Dataweb.NShape.GeneralShapes.Box>();
    foreach (Shape s in display.SelectedShapes) {
        if (s is Dataweb.NShape.GeneralShapes.Box)
            selectedBoxes.Add(s as Dataweb.NShape.GeneralShapes.Box);
    // Now unselect all boxes in the list...
    foreach (Dataweb.NShape.GeneralShapes.Box box in selectedBoxes)