How To Draw Programatically


https://www.nevron.com/Forum/Topic12969.aspx
Print Topic | Close Window

By Ashley Davy - 4 Years Ago
I am trying to draw items programmatically but I am at a loss.  The Geometry.MoveTo method takes Objects as parameter.  All of the examples seem to have relative coordinates.  Can you provide me with a sample on how to draw with geometry?
By Nevron Support - 4 Years Ago

There are two ways in which you can define the path of a geometry:

1. With Plotter Commands                                                              

Plotter commands such as NMoveTo, NLineTo, NArcTo etc.provide the ability define dynamic geometries, that are driven by expressions, because each aspect of a plotter command is controlled by a property to which you can assign an expression. The MoveTo, LineTo etc. commands of NGeometry take object parameters, which can be double values, strings representing formula expressions or expression objects - for example:

geometry.MoveTo(0, "Height / 2");
geometry.LineTo("Width", "Height / 2");

draws a horizontal line in the middle of the shape. The same can be achieved with relative coordinates and values only:

geometry.RelMoveTo(0d, 0.5d)
geometry.RelLineTo(1d, 0.5d)

With DrawBox Commands

DrawBox commands such as NDrawRectangle, NDrawEllipse,NDrawPolygon, NDrawPolyline and NDrawPath provide the ability to draw geometries with many vertices, that stretch to a box inside the shape coordinate system.DrawBox commands are commonly used when you create clip-art shapes.For example:

NDrawRectangle rect = new NDrawRectangle(new NRectangle(0, 0, 1, 1));
geometry.AddRelative(rect);