Nevron Open Vision Documentation
Shape Blocks

The shape block element (represented by the NShapeBlock class) is a special type of block that host only a single inline that derives from the NShapeInline abstract class. The purpose of this block is to allow you to insert blocks that contain an image or a widget directly in the document block tree without having to nest them in a paragraph. Shape blocks are commonly used to implement floating images in text documents.

Creating a Shape Block

You create a shape block by creating an instance of the NShapeBlock class. The following code snippet shows how to create a shape block that nests a raster image inline:

C#
Copy Code

NRasterImageInline imageInline = new NRasterImageInline();
imageInline.Image =
NImage.FromFile("c:\\SomeImage.bmp");

NShapeBlock shapeBlock = new NShapeBlock(imageInline);
shapeBlock.WrapMode =
ENWrapMode.Parallel;
shapeBlock.HorizontalAlignment =
ENAlign.Left;
section.Blocks.Add(shapeBlock);

The code also modifies the image wrap mode so text will flow around the newly inserted image.
Modifying the Shape Size

By default the shape block will use the dimensions of the nested image or widget. If you wish to instruct the block to scale this image or widget you can modify the inline properties PreferredWidth and PreferredHeight - for example:

C#
Copy Code

imageInline.PreferredWidth = new NMultiLength(ENMultiLengthUnit.Dip, 100);
imageInline.PreferredHeight =
new NMultiLength(ENMultiLengthUnit.Dip, 100);

will make the shape block 100dips wide and tall.

 

See Also

Inlines

Send Feedback