ShapeBase
ShapeBase class
Base class for objects in the drawing layer, such as an AutoShape, freeform, OLE object, ActiveX control, or picture.
To learn more, visit the Working with Shapes documentation article.
public abstract class ShapeBase : CompositeNode
Properties
Name | Description |
---|---|
AllowOverlap { get; set; } | Gets or sets a value that specifies whether this shape can overlap other shapes. |
AlternativeText { get; set; } | Defines alternative text to be displayed instead of a graphic. |
AnchorLocked { get; set; } | Specifies whether the shape’s anchor is locked. |
AspectRatioLocked { get; set; } | Specifies whether the shape’s aspect ratio is locked. |
BehindText { get; set; } | Specifies whether the shape is below or above text. |
Bottom { get; } | Gets the position of the bottom edge of the containing block of the shape. |
Bounds { get; set; } | Gets or sets the location and size of the containing block of the shape. |
BoundsInPoints { get; } | Gets the location and size of the containing block of the shape in points, relative to the anchor of the topmost shape. |
BoundsWithEffects { get; } | Gets final extent that this shape object has after applying drawing effects. Value is measured in points. |
CanHaveImage { get; } | Returns true if the shape type allows the shape to have an image. |
CoordOrigin { get; set; } | The coordinates at the top-left corner of the containing block of this shape. |
CoordSize { get; set; } | The width and height of the coordinate space inside the containing block of this shape. |
Count { get; } | Gets the number of immediate children of this node. |
CustomNodeId { get; set; } | Specifies custom node identifier. |
DistanceBottom { get; set; } | Returns or sets the distance (in points) between the document text and the bottom edge of the shape. |
DistanceLeft { get; set; } | Returns or sets the distance (in points) between the document text and the left edge of the shape. |
DistanceRight { get; set; } | Returns or sets the distance (in points) between the document text and the right edge of the shape. |
DistanceTop { get; set; } | Returns or sets the distance (in points) between the document text and the top edge of the shape. |
virtual Document { get; } | Gets the document to which this node belongs. |
Fill { get; } | Gets fill formatting for the shape. |
FirstChild { get; } | Gets the first child of the node. |
FlipOrientation { get; set; } | Switches the orientation of a shape. |
Font { get; } | Provides access to the font formatting of this object. |
Glow { get; } | Gets glow formatting for the shape. |
HasChildNodes { get; } | Returns true if this node has any child nodes. |
Height { get; set; } | Gets or sets the height of the containing block of the shape. |
HeightRelative { get; set; } | Gets or sets the value that represents the percentage of shape’s relative height. |
Hidden { get; set; } | Gets or sets a boolean value indicating whether the shape is visible. |
HorizontalAlignment { get; set; } | Specifies how the shape is positioned horizontally. |
HRef { get; set; } | Gets or sets the full hyperlink address for a shape. |
override IsComposite { get; } | Returns true as this node can have child nodes. |
IsDecorative { get; set; } | Gets or sets the flag that specifies whether the shape is decorative in the document. |
IsDeleteRevision { get; } | Returns true if this object was deleted in Microsoft Word while change tracking was enabled. |
IsGroup { get; } | Returns true if this is a group shape. |
IsHorizontalRule { get; } | Returns true if this shape is a horizontal rule. |
IsImage { get; } | Returns true if this shape is an image shape. |
IsInline { get; } | A quick way to determine if this shape is positioned inline with text. |
IsInsertRevision { get; } | Returns true if this object was inserted in Microsoft Word while change tracking was enabled. |
IsLayoutInCell { get; set; } | Gets or sets a flag indicating whether the shape is displayed inside a table or outside of it. |
IsMoveFromRevision { get; } | Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled. |
IsMoveToRevision { get; } | Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled. |
IsSignatureLine { get; } | Indicates that shape is a SignatureLine . |
IsTopLevel { get; } | Returns true if this shape is not a child of a group shape. |
IsWordArt { get; } | Returns true if this shape is a WordArt object. |
LastChild { get; } | Gets the last child of the node. |
Left { get; set; } | Gets or sets the position of the left edge of the containing block of the shape. |
LeftRelative { get; set; } | Gets or sets the value that represents shape’s relative left position in percent. |
MarkupLanguage { get; } | Gets MarkupLanguage used for this graphic object. |
Name { get; set; } | Gets or sets the optional shape name. |
NextSibling { get; } | Gets the node immediately following this node. |
abstract NodeType { get; } | Gets the type of this node. |
ParentNode { get; } | Gets the immediate parent of this node. |
ParentParagraph { get; } | Returns the immediate parent paragraph. |
PreviousSibling { get; } | Gets the node immediately preceding this node. |
Range { get; } | Returns a Range object that represents the portion of a document that is contained in this node. |
Reflection { get; } | Gets reflection formatting for the shape. |
RelativeHorizontalPosition { get; set; } | Specifies relative to what the shape is positioned horizontally. |
RelativeHorizontalSize { get; set; } | Gets or sets the value of shape’s relative size in horizontal direction. |
RelativeVerticalPosition { get; set; } | Specifies relative to what the shape is positioned vertically. |
RelativeVerticalSize { get; set; } | Gets or sets the value of shape’s relative size in vertical direction. |
Right { get; } | Gets the position of the right edge of the containing block of the shape. |
Rotation { get; set; } | Defines the angle (in degrees) that a shape is rotated. Positive value corresponds to clockwise rotation angle. |
ScreenTip { get; set; } | Defines the text displayed when the mouse pointer moves over the shape. |
ShadowFormat { get; } | Gets shadow formatting for the shape. |
ShapeType { get; } | Gets the shape type. |
SizeInPoints { get; } | Gets the size of the shape in points. |
SoftEdge { get; } | Gets soft edge formatting for the shape. |
Target { get; set; } | Gets or sets the target frame for the shape hyperlink. |
Title { get; set; } | Gets or sets the title (caption) of the current shape object. |
Top { get; set; } | Gets or sets the position of the top edge of the containing block of the shape. |
TopRelative { get; set; } | Gets or sets the value that represents shape’s relative top position in percent. |
VerticalAlignment { get; set; } | Specifies how the shape is positioned vertically. |
Width { get; set; } | Gets or sets the width of the containing block of the shape. |
WidthRelative { get; set; } | Gets or sets the value that represents the percentage of shape’s relative width. |
WrapSide { get; set; } | Specifies how the text is wrapped around the shape. |
WrapType { get; set; } | Defines whether the shape is inline or floating. For floating shapes defines the wrapping mode for text around the shape. |
ZOrder { get; set; } | Determines the display order of overlapping shapes. |
Methods
Name | Description |
---|---|
abstract Accept(DocumentVisitor) | Accepts a visitor. |
abstract AcceptEnd(DocumentVisitor) | When implemented in a derived class, calls the VisitXXXEnd method of the specified document visitor. |
abstract AcceptStart(DocumentVisitor) | When implemented in a derived class, calls the VisitXXXStart method of the specified document visitor. |
AdjustWithEffects(RectangleF) | Adds to the source rectangle values of the effect extent and returns the final rectangle. |
AppendChild<T>(T) | Adds the specified node to the end of the list of child nodes for this node. |
Clone(bool) | Creates a duplicate of the node. |
CreateNavigator() | Creates navigator which can be used to traverse and read nodes. |
GetAncestor(NodeType) | Gets the first ancestor of the specified NodeType . |
GetAncestor(Type) | Gets the first ancestor of the specified object type. |
GetChild(NodeType, int, bool) | Returns an Nth child node that matches the specified type. |
GetChildNodes(NodeType, bool) | Returns a live collection of child nodes that match the specified type. |
GetEnumerator() | Provides support for the for each style iteration over the child nodes of this node. |
GetShapeRenderer() | Creates and returns an object that can be used to render this shape into an image. |
override GetText() | Gets the text of this node and of all its children. |
IndexOf(Node) | Returns the index of the specified child node in the child node array. |
InsertAfter<T>(T, Node) | Inserts the specified node immediately after the specified reference node. |
InsertBefore<T>(T, Node) | Inserts the specified node immediately before the specified reference node. |
LocalToParent(PointF) | Converts a value from the local coordinate space into the coordinate space of the parent shape. |
NextPreOrder(Node) | Gets next node according to the pre-order tree traversal algorithm. |
PrependChild<T>(T) | Adds the specified node to the beginning of the list of child nodes for this node. |
PreviousPreOrder(Node) | Gets the previous node according to the pre-order tree traversal algorithm. |
Remove() | Removes itself from the parent. |
RemoveAllChildren() | Removes all the child nodes of the current node. |
RemoveChild<T>(T) | Removes the specified child node. |
RemoveSmartTags() | Removes all SmartTag descendant nodes of the current node. |
SelectNodes(string) | Selects a list of nodes matching the XPath expression. |
SelectSingleNode(string) | Selects the first Node that matches the XPath expression. |
ToString(SaveFormat) | Exports the content of the node into a string in the specified format. |
ToString(SaveOptions) | Exports the content of the node into a string using the specified save options. |
Remarks
This is an abstract class. The two derived classes that you can instantiate are Shape
and GroupShape
.
A shape is a node in the document tree.
If the shape is a child of a Paragraph
object, then the shape is said to be “top-level”. Top-level shapes are measured and positioned in points.
A shape can also occur as a child of a GroupShape
object when several shapes are grouped. Child shapes of a group shape are positioned in the coordinate space and units defined by the CoordSize
and CoordOrigin
properties of the parent group shape.
A shape can be positioned inline with text or floating. The positioning method is controlled using the WrapType
property.
When a shape is floating, it is positioned relative to something (e.g the current paragraph, the margin or the page). The relative positioning of the shape is specified using the RelativeHorizontalPosition
and RelativeVerticalPosition
properties.
A floating shape be positioned explicitly using the Left
and Top
properties or aligned relative to some other object using the HorizontalAlignment
and VerticalAlignment
properties.
Examples
Shows how to insert a floating image to the center of a page.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a floating image that will appear behind the overlapping text and align it to the page's center.
Shape shape = builder.InsertImage(ImageDir + "Logo.jpg");
shape.WrapType = WrapType.None;
shape.BehindText = true;
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
shape.HorizontalAlignment = HorizontalAlignment.Center;
shape.VerticalAlignment = VerticalAlignment.Center;
doc.Save(ArtifactsDir + "Image.CreateFloatingPageCenter.docx");
See Also
- class CompositeNode
- namespace Aspose.Words.Drawing
- assembly Aspose.Words