Nevron Forum

Rectanlge with rounded corners

https://www.nevron.com/Forum/Topic8450.aspx

By David Dieffenthaler 1 - Monday, February 3, 2014

Hello,

I would like what is the recommended method to create rectangle shapes with rounded corners?
Is there a shape for that? Should I create it by associating 1D shapes into a group?

Thanks
David
By Nevron Support - Monday, February 3, 2014

Hi David,

The easiest way to create a rounded rectangle shape is to use the basic shapes factory:

// Create a basic shapes factory

NBasicShapesFactory factory = new NBasicShapesFactory(document);

factory.DefaultSize = new NSizeF(100, 60);

 

// Use the factory to create a rounded rectangle shape

NShape roundedRectangle = factory.CreateShape(BasicShapes.RoundedRectangle);

roundedRectangle.Location = new NPointF(100, 100);

document.ActiveLayer.AddChild(roundedRectangle);

By David Dieffenthaler 1 - Tuesday, February 4, 2014

Thanks for this answer however I still have questions regarding this RoundedRectangle shape:
- How do we adjust the radius of the rounded corners?

There is an example with NSmartShape here : http://helpdotnetvision.nevron.com/Presentation_SmartShapes_Samples_Rounded_Rectangle_Shape.html

Seems like we can adjust lots of parameters that can be adjusted for NSmartShape, but I can't find the way to add it to a document the way I add conventional NShape.

- What are NSmartShape and do you have examples of their use in a document ?

Thanks a lot
David
By Nevron Support - Tuesday, February 4, 2014

Hi, NSmartShapes are shapes that are not related to Nevron Diagram. They are used in Nevron Gauge for some indicators and gauges, so you cannot use them in a Diagram drawing document.

If you want to create a rounded rectangle with differently rounded corners than that of the predefined one, your should create a GraphicsPath that defines your shape geometry, then create an NCustomPath from it and add it to an NCompositeShape. Take a look at the Document Object Model -> Shapes -> Custom Shapes example that comes preinstalled with Nevron Diagram for .NET for a sample implementation.

By David Dieffenthaler 1 - Friday, February 7, 2014

great! thank you I wasn't able to find that shape in the examples