officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-nestedshapecollection-dot-addline-x28-system-dot-drawing-dot-pointf-system-dot-drawing-dot-pointf-x29.md
Adds a line to a shape group or a drawing canvas.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
NestedShape AddLine(
PointF start,
PointF end
)
Function AddLine(
start As PointF,
end As PointF
) As NestedShape
| Name | Type | Description |
|---|---|---|
| start | PointF |
An object that specifies x- and y-coordinates of the start point relative to the top left corner of the parent object. The Document.Unit property defines the measurement units.
| | end | PointF |
An object that specifies x- and y-coordinates of the end point relative to the top left corner of the parent object. The Document.Unit property defines the measurement units.
|
| Type | Description |
|---|---|
| NestedShape |
The shape in the group or drawing canvas.
|
Call the ShapeCollection.InsertCanvas method to add a drawing canvas to a document. Use the Shape.CanvasItems property to access the collection of canvas items. The collection’s Add methods allow you to add shapes and pictures to the canvas.
Use the Shape.Line property to access a ShapeLine object that allows you to specify line settings.
The example below creates a drawing canvas with three shapes.
Document document = wordProcessor.Document;
// Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch;
// Insert a drawing canvas.
Shape canvas = document.Shapes.InsertCanvas(document.Range.Start, new RectangleF(1.5f, 1f, 6f, 1.5f));
// Access the collection of canvas items.
var canvasItems = canvas.CanvasItems;
// Add a rectangle to the canvas.
var shape1 = canvasItems.AddShape(ShapeGeometryPreset.Rectangle, new RectangleF(0f, 0f, 2f, 1.5f));
shape1.Fill.SetSolidFill(Color.FromArgb(0xA4, 0xFF, 0xFF));
shape1.Line.Color = Color.DarkGray;
shape1.Line.Thickness = 2;
// Add a line to the canvas.
var shape2 = canvasItems.AddLine(new PointF(2.1f, 0.8f), new PointF(3.7f, 0.8f));
ShapeLine lineFormat = shape2.Line;
// Specify the line color.
lineFormat.Color = Color.FromArgb(0xA1, 0xF9, 0xA1);
// Set the line width.
lineFormat.Thickness = 8;
// Add an arrowhead to the line end.
lineFormat.EndArrowType = LineArrowType.StealthArrow;
lineFormat.EndArrowWidth = LineArrowSize.Large;
lineFormat.EndArrowLength = LineArrowSize.Large;
// Add a parallelogram to the canvas.
var shape3 = canvasItems.AddShape(ShapeGeometryPreset.Parallelogram, new RectangleF(3.8f, 0f, 2f, 1.5f));
shape3.Fill.SetSolidFill(Color.FromArgb(0xFF, 0xA5, 0xA5));
shape3.Line.Color = Color.DarkGray;
shape3.Line.Thickness = 2;
Dim document As Document = wordProcessor.Document
' Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch
' Insert a drawing canvas.
Dim canvas As Shape = document.Shapes.InsertCanvas(document.Range.Start, New RectangleF(1.5F, 1F, 6F, 1.5F))
' Access the collection of canvas items.
Dim canvasItems As CanvasShapeCollection = canvas.CanvasItems
' Add a rectangle to the canvas.
Dim shape1 As NestedShape = canvasItems.AddShape(ShapeGeometryPreset.Rectangle, New RectangleF(0F, 0F, 2F, 1.5F))
shape1.Fill.SetSolidFill(Color.FromArgb(&HA4, &HFF, &HFF))
shape1.Line.Color = Color.DarkGray
shape1.Line.Thickness = 2
' Add a line to the canvas.
Dim shape2 As NestedShape = canvasItems.AddLine(New PointF(2.1F, 0.8F), New PointF(3.7F, 0.8F))
Dim lineFormat As ShapeLine = shape2.Line
' Specify the line color.
lineFormat.Color = Color.FromArgb(&HA1, &HF9, &HA1)
' Set the line width.
lineFormat.Thickness = 8
' Add an arrowhead to the line end.
lineFormat.EndArrowType = LineArrowType.StealthArrow
lineFormat.EndArrowWidth = LineArrowSize.Large
lineFormat.EndArrowLength = LineArrowSize.Large
' Add a parallelogram to the canvas.
Dim shape3 As NestedShape = canvasItems.AddShape(ShapeGeometryPreset.Parallelogram, New RectangleF(3.8F, 0F, 2F, 1.5F))
shape3.Fill.SetSolidFill(Color.FromArgb(&HFF, &HA5, &HA5))
shape3.Line.Color = Color.DarkGray
shape3.Line.Thickness = 2
Call the ShapeCollection.InsertGroup method to create a shape group. The Shape.GroupItems property returns the collection of group items. Use the collection’s Add methods to add shapes and pictures to the group.
Use the Shape.Line property to access a ShapeLine object that allows you to specify line settings.
The example below creates a shape group in the document.
Document document = wordProcessor.Document;
// Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch;
// Insert a shape group.
Shape group = document.Shapes.InsertGroup(document.Range.Start);
// Specify the group position relative to the left and top edges of the page.
group.Offset = new PointF(1.5f, 1f);
// Access the collection of group items.
var groupItems = group.GroupItems;
// Add a rectangle to the group.
var shape1 = groupItems.AddShape(ShapeGeometryPreset.Rectangle, new RectangleF(0f, 0f, 2f, 1.5f));
shape1.Fill.SetSolidFill(Color.FromArgb(0xA4, 0xFF, 0xFF));
shape1.Line.Color = Color.DarkGray;
shape1.Line.Thickness = 2;
// Add a line to the group.
var shape2 = groupItems.AddLine(new PointF(2.1f, 0.8f), new PointF(3.7f, 0.8f));
ShapeLine lineFormat = shape2.Line;
// Specify the line color.
lineFormat.Color = Color.FromArgb(0xA1, 0xF9, 0xA1);
// Set the line width.
lineFormat.Thickness = 8;
// Add an arrowhead to the line end.
lineFormat.EndArrowType = LineArrowType.StealthArrow;
lineFormat.EndArrowWidth = LineArrowSize.Large;
lineFormat.EndArrowLength = LineArrowSize.Large;
// Add a parallelogram to the group.
var shape3 = groupItems.AddShape(ShapeGeometryPreset.Parallelogram, new RectangleF(3.8f, 0f, 2f, 1.5f));
shape3.Fill.SetSolidFill(Color.FromArgb(0xFF, 0xA5, 0xA5));
shape3.Line.Color = Color.DarkGray;
shape3.Line.Thickness = 2;
Dim document As Document = wordProcessor.Document
' Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch
' Insert a shape group.
Dim group As Shape = document.Shapes.InsertGroup(document.Range.Start)
' Specify the group position relative to the left and top edges of the page.
group.Offset = New PointF(1.5F, 1F)
' Access the collection of group items.
Dim groupItems As GroupShapeCollection = group.GroupItems
' Add a rectangle to the group.
Dim shape1 As NestedShape = groupItems.AddShape(ShapeGeometryPreset.Rectangle, New RectangleF(0F, 0F, 2F, 1.5F))
shape1.Fill.SetSolidFill(Color.FromArgb(&HA4, &HFF, &HFF))
shape1.Line.Color = Color.DarkGray
shape1.Line.Thickness = 2
' Add a line to the group.
Dim shape2 As NestedShape = groupItems.AddLine(New PointF(2.1F, 0.8F), New PointF(3.7F, 0.8F))
Dim lineFormat As ShapeLine = shape2.Line
' Specify the line color.
lineFormat.Color = Color.FromArgb(&HA1, &HF9, &HA1)
' Set the line width.
lineFormat.Thickness = 8
' Add an arrowhead to the line end.
lineFormat.EndArrowType = LineArrowType.StealthArrow
lineFormat.EndArrowWidth = LineArrowSize.Large
lineFormat.EndArrowLength = LineArrowSize.Large
' Add a parallelogram to the group.
Dim shape3 As NestedShape = groupItems.AddShape(ShapeGeometryPreset.Parallelogram, New RectangleF(3.8F, 0F, 2F, 1.5F))
shape3.Fill.SetSolidFill(Color.FromArgb(&HFF, &HA5, &HA5))
shape3.Line.Color = Color.DarkGray
shape3.Line.Thickness = 2
See Also