Skip to main content Skip to footer

Introducing Enhanced Custom Shape Support with Edit Points

Spread. NET v14 introduces Enhanced Custom Shape Support with Edit Points. This new feature allows you to edit the points for shapes. You can add and remove points. You can also edit the lines to make them smooth, curved, or straight. The picture you see below is a quick flow diagram I made using the Edit Point feature.

Introducing Enhanced Custom Shape Support with Edit Points

Download Now!<%/if%>

Getting Started with Edit Points

To enable the option to edit points, you need to first make sure you set "EnhancedShapeEngine" to "True." You can find this property under "Features."

Introducing Enhanced Custom Shape Support with Edit Points

After you enable the Enhanced Shape Engine, you can then edit points. Go to "Insert" and select a shape. For this example, we will choose a Square.

After Selecting and placing the shape in the designer, go to Shape Format and select edit points while the shape is selected.

Introducing Enhanced Custom Shape Support with Edit Points

Once you place the shape, you will see your options if you right click on a corner point.

Introducing Enhanced Custom Shape Support with Edit Points

If you click Smooth Point, you will see the manipulation of the shape as such:

Introducing Enhanced Custom Shape Support with Edit Points

You can also right-click in between the points to edit the lines. As you can see in the next picture, we make each line curved:

Introducing Enhanced Custom Shape Support with Edit Points

You can also add a point. We took a square in this picture and added a point between the top left and right edit points.

Introducing Enhanced Custom Shape Support with Edit Points

To remove points, you can use Ctrl + right-click or delete the point by right-clicking on the point and selecting "remove."

How to Use Edit Points with C# and VB

Now we will quickly review adding a shape and specifying the points through the API using C# and VB.

First, we will enable the Enhanced Shape Engine, and then we will add a star.

C#

// Enable EnhancedShapeEngine  
fpSpread1.Features.EnhancedShapeEngine = true;  
// Add FivePointedStar Shape     
fpSpread1.AsWorkbook().ActiveSheet.Shapes.AddShape(GrapeCity.Spreadsheet.Drawing.AutoShapeType.FivePointedStar, 100, 100, 100, 100);

VB

' Enable EnhancedShapeEngine  
FpSpread1.Features.EnhancedShapeEngine = True  
' Add FivePointedStar Shape  
FpSpread1.AsWorkbook().ActiveSheet.Shapes.AddShape(GrapeCity.Spreadsheet.Drawing.AutoShapeType.FivePointedStar, 100, 100, 100, 100)

Introducing Enhanced Custom Shape Support with Edit Points

Next, we are going to insert a node on the bottom right point of the star.

C#

fpSpread1.AsWorkbook().ActiveSheet.Shapes[0].Nodes.Insert(6, GrapeCity.Spreadsheet.Drawing.SegmentType.Curve, GrapeCity.Spreadsheet.Drawing.EditingType.Corner, 50, 100, 50, 130, 100, 100);

VB

fpSpread1.AsWorkbook().ActiveSheet.Shapes(0).Nodes.Insert(6, GrapeCity.Spreadsheet.Drawing.SegmentType.Curve, GrapeCity.Spreadsheet.Drawing.EditingType.Corner, 50, 100, 50, 130, 100, 100)

Introducing Enhanced Custom Shape Support with Edit Points

We can then remove the node we inserted using the following line:

C#

fpSpread1.AsWorkbook().ActiveSheet.Shapes[0].Nodes.Delete(6); 

VB

fpSpread1.AsWorkbook().ActiveSheet.Shapes(0).Nodes.Delete(1)

Introducing Enhanced Custom Shape Support with Edit Points

If you would like to use the Free Form Builder, you can do so as such:

C#

IFreeFormBuilder freeform = fpSpread1.AsWorkbook().ActiveSheet.Shapes.BuildFreeform(EditingType.Corner, 160, 10);  
freeform.AddNodes(SegmentType.Curve, EditingType.Corner, 180, 30, 200, 50, 250, 100);  
freeform.AddNodes(SegmentType.Curve, EditingType.Auto, 280, 10);  
freeform.AddNodes(SegmentType.Curve, EditingType.Auto, 280, 200);  
freeform.AddNodes(SegmentType.Line, EditingType.Auto, 160, 10);  
freeform.ConvertToShape();

VB

Dim freeform As IFreeFormBuilder = fpSpread1.AsWorkbook().ActiveSheet.Shapes.BuildFreeform(EditingType.Corner, 160, 10)  
freeform.AddNodes(SegmentType.Curve, EditingType.Corner, 180, 30, 200, 50, 250, 100)  
freeform.AddNodes(SegmentType.Curve, EditingType.Auto, 280, 10)  
freeform.AddNodes(SegmentType.Curve, EditingType.Auto, 280, 200)  
freeform.AddNodes(SegmentType.Line, EditingType.Auto, 160, 10)  
freeform.ConvertToShape()

Introducing Enhanced Custom Shape Support with Edit Points

Download Now!<%/if%>

Tyler Barlock

Technical Engagement Engineer
comments powered by Disqus