Hi there,
I try to create a custom shape with geometry path. It’s like a rectangle with round corners. Unfortunately I cannot use the built in shape for that since I want to customize each corner individually. So I created a custom shape for that with the following GeometryPath:
var childShape = shapes.AddAutoShape(
ShapeType.Custom, convertedX, convertedY,
convertedWidth, convertedHeight);
var geometryPath = new GeometryPath();
var point1 = new PointF(settings.TopLeftCornerRadiusF, 0);
var point2 = new PointF(convertedWidth - settings.TopRightCornerRadiusF, point1.Y);
var point3 = new PointF(point2.X, point2.Y + settings.TopRightCornerRadiusF);
var point4 = new PointF(point3.X + settings.TopRightCornerRadiusF, point3.Y);
var point5 = new PointF(point4.X, convertedHeight - settings.BottomRightCornerRadiusF);
var point6 = new PointF(point5.X - settings.BottomRightCornerRadiusF, point5.Y);
var point7 = new PointF(point6.X, point6.Y + settings.BottomRightCornerRadiusF);
var point8 = new PointF(settings.BottomLeftCornerRadiusF, point7.Y);
var point9 = new PointF(point8.X, point8.Y - settings.BottomLeftCornerRadiusF);
var point10 = new PointF(point9.X - settings.BottomLeftCornerRadiusF, point9.Y);
var point11 = new PointF(point10.X, settings.TopLeftCornerRadiusF);
var point12 = new PointF(point11.X + settings.TopLeftCornerRadiusF, point11.Y);
geometryPath.MoveTo(point1);
geometryPath.LineTo(point2);
geometryPath.LineTo(point3);
geometryPath.LineTo(point4);
geometryPath.LineTo(point5);
geometryPath.LineTo(point6);
geometryPath.LineTo(point7);
geometryPath.LineTo(point8);
geometryPath.LineTo(point9);
geometryPath.LineTo(point10);
geometryPath.LineTo(point11);
geometryPath.LineTo(point12);
geometryPath.CloseFigure();
childShape.SetGeometryPath(geometryPath);
The resulting shape looks like this (Green Shape):
Capture.JPG (15.9 KB)
The GeometryPath class provides an ArcTo(width, height, startAngle, sweepAngle) which is probably the proper method to accomplish this. But I don’t know where to insert the calls to this method to create my round corners.