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

Prevent moving / resizing / rotating of shapes

Mar 27, 2014 at 7:50 PM
Is there any way to prevent moving, resizing or rotating the shapes?
Mar 28, 2014 at 9:11 AM
Edited Mar 28, 2014 at 9:12 AM
You have several options on how to prevent the shapes from moving/resizing/rotating:
  • Do not assign a SelectionTool to the display so the user cannot interact with the shapes. In this scenario, you also should not assign the DiagramSetController to the ToolboxController. For an example, see "NShapeViewer" demo program.
  • Adjust the permission settings. This is useful for restricting certain shapes while others are not restricted. Please have a look at the SecurityDemo and/or watch the feature spotlight video.
  • Create your own shape library, derive shapes from the standard shapes and override the HasControlPointCapability() method of your shapes.
Mar 28, 2014 at 12:37 PM
Overriding the HasControlPointCapability() method does the trick.

However, in multiselect mode all control points disapper. Is this behaviour by design?
Furthermore, is it possible to resize multiple shapes at once? I was unable to do that and I'm not sure if this is by design or not.

My code for preventing the rotation:
        public override bool HasControlPointCapability(ControlPointId controlPointId, ControlPointCapabilities controlPointCapability)
            if (controlPointCapability == ControlPointCapabilities.Rotate)
                // prevent rotating the shapes
                return false;

            return true;
Mar 28, 2014 at 1:29 PM
Edited Mar 28, 2014 at 1:32 PM
This issue is partially "by design", partially buggy:
The "by design" part checks whether all selected shapes are of the same type. If not, only their common handles are displayed.
The buggy part does not draw all common handles. When moving the mouse over the place where a handle should be, you will see the cursor changing. You can also perform the drag action (resize multiple boxes for example). This is only a graphical issue.

Please note that ControlPointCapabilities are Flags. Please perform checks this way:
if ((controlPointCapability & ControlPointCapabilities.Rotate) != 0) {
  // ...
Mar 28, 2014 at 1:37 PM
Thank you for your detailed explanation and for the hint.