TX Text Control provides a very powerful drawings feature to insert many different types of shapes into documents. The ribbon Insert tab provides an out-of-the-box UI to add shapes to a document:

TX Text Control shapes

Adding Single Shapes

In order to insert these shapes programmatically, several steps are required:

// create a drawing control that contains the shape(s)
TXTextControl.Drawing.TXDrawingControl drawing =
new TXTextControl.Drawing.TXDrawingControl(3000, 3000);
// create a new donut shape
TXTextControl.Drawing.Shape shape =
new TXTextControl.Drawing.Shape(TXTextControl.Drawing.ShapeType.Donut);
// set the color and border width
shape.ShapeFill.Color = Color.Red;
shape.ShapeOutline.Color = Color.Yellow;
shape.ShapeOutline.Width = 200;
// add the shape to the drawing control
drawing.Shapes.Add(
shape,
TXTextControl.Drawing.ShapeCollection.AddStyle.Fill);
// create a new drawing frame object from the created drawing control
TXTextControl.DataVisualization.DrawingFrame frame =
new TXTextControl.DataVisualization.DrawingFrame(drawing);
// add the frame to the document
textControl1.Drawings.Add(frame, -1);
view raw api.cs hosted with ❤ by GitHub

TX Text Control shapes

The above code inserts a shape at the current input position. If you want the user to "draw" the created shape onto the document, the following implementation of the DrawingCollection.Add TX Text Control .NET for Windows Forms
DataVisualization Namespace
DrawingCollection Class
Add Method
Inserts a new drawing in a Text Control document.
method can be used:

textControl1.Drawings.Add(frame, TXTextControl.FrameInsertionMode.DisplaceText);
view raw api.cs hosted with ❤ by GitHub

Adding Container Group Frames

The following code shows how to insert more shapes into a group frame. If the container group frame is moved, all contained shapes are moved together:

// create a drawing control that contains the shape(s)
TXTextControl.Drawing.TXDrawingControl drawingGroup =
new TXTextControl.Drawing.TXDrawingControl(3000, 3000);
// create a new donut shape
TXTextControl.Drawing.Shape donut =
new TXTextControl.Drawing.Shape(TXTextControl.Drawing.ShapeType.Donut) {
Location = new Point(100, 100),
Size = new Size(500,500)
};
TXTextControl.Drawing.Shape diamond =
new TXTextControl.Drawing.Shape(TXTextControl.Drawing.ShapeType.Diamond);
// add the shape to the drawing control
drawingGroup.Shapes.Add(donut);
drawingGroup.Shapes.Add(diamond);
// create a new drawing frame object from the created drawing control
TXTextControl.DataVisualization.DrawingFrame frame =
new TXTextControl.DataVisualization.DrawingFrame(drawingGroup);
// add the frame to the document
textControl1.Drawings.Add(
frame,
textControl1.InputPosition.Location,
TXTextControl.FrameInsertionMode.DisplaceText);
view raw api.cs hosted with ❤ by GitHub

The following screenshot shows the activated group container frame with the 2 inserted shapes:

TX Text Control shapes

Adding Additional Shapes to Containers

If the container frame is activated (dashed frame border), additional shapes can be added. The following code inserts a new shape into an activated container frame:

// create a new donut shape
TXTextControl.Drawing.Shape shape =
new TXTextControl.Drawing.Shape(TXTextControl.Drawing.ShapeType.Donut);
// set the color and border width
shape.ShapeFill.Color = Color.Red;
shape.ShapeOutline.Color = Color.Yellow;
shape.ShapeOutline.Width = 200;
if (textControl1.Drawings.GetActivatedItem() != null)
{
// add the shape to the drawing control
((TXDrawingControl)textControl1.Drawings.GetActivatedItem().Drawing).Shapes.Add(shape);
}
view raw api.cs hosted with ❤ by GitHub

If you want the user to draw the additional shape into the container, the MouseCreation TX Text Control .NET for Windows Forms
Drawing Namespace
Drawing Enumerations Enumerations
Drawing.ShapeCollection.AddStyle Enumeration Enumeration
Determines the location and size in which a shape is added to the TX Drawing Control.
member must be used in the Shapes.Add TX Text Control .NET for Windows Forms
Drawing Namespace
ShapeCollection Class
Add Method
Adds an object of the type Shape to the collection.
method.

((TXDrawingControl)textControl1.Drawings.GetActivatedItem().Drawing).Shapes.Add(
shape,
ShapeCollection.AddStyle.MouseCreation);
view raw api.cs hosted with ❤ by GitHub

TX Text Control shapes