The following example creates a group, which contains three shapes:
Creating Groups |
Copy Code
|
---|---|
// create all shapes NBasicShapesFactory basicShapes = new NBasicShapesFactory(); NConnectorShapesFactory connectorShapes = new NConnectorShapesFactory(); // create the group NGroup group = new NGroup(); // create a rectangle that is scaled and repositioned NShape rect1 = basicShapes.CreateShape(ENBasicShapes.Rectangle); group.Shapes.Add(rect1); rect1.ResizeInGroup = ENResizeInGroup.ScaleAndReposition; rect1.SetBounds(new NRectangle(10, 10, 100, 100)); // create a rectangle that is only repositioned NShape rect2 = basicShapes.CreateShape(ENBasicShapes.Rectangle); group.Shapes.Add(rect2); rect2.ResizeInGroup = ENResizeInGroup.RepositionOnly; rect2.SetBounds(new NRectangle(120, 120, 100, 100)); // create a 1D shape NShape arrow = connectorShapes.CreateShape(ENConnectorShapes.SingleArrow); group.Shapes.Add(arrow); arrow.SetBeginPoint(new NPoint(10, 250)); arrow.SetEndPoint(new NPoint(220, 290)); |
When 2D shapes that reside in a group are resized by the user, NOV diagram takes into account the ResizeInGroup property of the shape that accepts values from the ENResizeInGroup enumeration:
When the user changes the end-points of 1D shapes that reside in a group, NOV Diagram expresses the respective end-point as factors of the group width and height. In this way when the group is resized the 1D shape is proportionally "stretched" by its end-points.
By default groups allow the drill-down selection of the shapes which they contain. The user performs drill down selection of the shapes contained inside a group by clicking on a grouped shapes multiple times. Each group can control the way in which drill-down selection is performed for that group vis the SelectionMode property that accepts values from the ENGroupSelectionMode enumeration:
When creating custom shapes by grouping other shapes it is often required to disable the selection of the shapes contained inside the group. The following code example disables the selection of the shapes contained inside a group:
Change group selection mode |
Copy Code
|
---|---|
group.SelectionMode = ENGroupSelectionMode.GroupOnly;
|
By default group allow the snapping to the shapes contained inside them. When creating custom shapes by grouping other shapes, it is often required to prevent the user from gluing connectors to the shapes contained inside the group. Because an end-point must be first snapped to a shape before it is glued to it, you can prevent the snapping to the group shapes by setting the SnapToShapes property to false:
Disabling Snapping to Shapes |
Copy Code
|
---|---|
group.SnapToShapes = false; |
By default the elements of a group (geometry, text-block, widget etc.) are displayed behind the content of the shapes contained in the group. You can however change that and display the group elements above the shapes, by setting the group ElementsZOrder to AboveShapes:
Displaying the group elements above the shapes |
Copy Code
|
---|---|
group.ElementsZOrder = ENGroupElementsZOrder.AboveShapes;
|