ShapeBaseLocalToParent Method

Converts a value from the local coordinate space into the coordinate space of the parent shape.

Namespace:  Aspose.Words.Drawing
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0


public PointF LocalToParent(
	PointF value


Type: System.DrawingPointF

Return Value

Type: PointF


Shows how to create and work with a group of shapes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

GroupShape group = new GroupShape(doc);

// Every GroupShape by default is a top level floating shape
Assert.AreEqual(WrapType.None, group.WrapType);

// Top level shapes can have this property changed
group.AnchorLocked = true;

// Set the XY coordinates of the shape group and the size of its containing block, as it appears on the page
group.Bounds = new RectangleF(100, 50, 200, 100);

// Set the scale of the inner coordinates of the shape group
// These values mean that the bottom right corner of the 200x100 outer block we set before
// will be at x = 2000 and y = 1000, or 2000 units from the left and 1000 units from the top
group.CoordSize = new Size(2000, 1000);

// The coordinate origin of a shape group is x = 0, y = 0 by default, which is the top left corner
// If we insert a child shape and set its distance from the left to 2000 and the distance from the top to 1000,
// its origin will be at the bottom right corner of the shape group
// We can offset the coordinate origin by setting the CoordOrigin attribute
// In this instance, we move the origin to the centre of the shape group
group.CoordOrigin = new Point(-1000, -500);

// Populate the shape group with child shapes
// First, insert a rectangle
Shape subShape = new Shape(doc, ShapeType.Rectangle);
subShape.Width = 500;
subShape.Height = 700;

// Place its top left corner at the parent group's coordinate origin, which is currently at its centre
subShape.Left = 0;
subShape.Top = 0;

// Add the rectangle to the group

// Insert a triangle
subShape = new Shape(doc, ShapeType.Triangle);
subShape.Width = 400;
subShape.Height = 400;

// Place its origin at the bottom right corner of the group
subShape.Left = 1000;
subShape.Top = 500;

// The offset between this child shape and parent group can be seen here
Assert.AreEqual(new PointF(1000, 500), subShape.LocalToParent(new PointF(0, 0)));

// Add the triangle to the group

// Child shapes of a group shape are not top level

// Finally, insert the group into the document and save
doc.Save(ArtifactsDir + "Shape.InsertGroupShape.docx");

See Also