Hi Sandor,
The following is a simple implementation of a shape factory:
public class MyEdgeShapeFactory : NShapesFactory
{
public MyEdgeShapeFactory()
: base("MyEdgeShapeFactory")
{
}
public override int ShapesCount
{
get
{
return Enum.GetValues(GetEnumType()).Length;
}
}
public override NShape CreateShape(int index)
{
switch ((MyEdgeShapes)index)
{
case MyEdgeShapes.ArrowShape:
NArrowShape arrowShape = new NArrowShape(new NPointF(0, 0), new NPointF(DefaultSize.Width, DefaultSize.Height));
return arrowShape;
default:
throw new Exception("New shape type ?");
}
}
protected override NShapeInfo CreateShapeInfo(int index)
{
MyEdgeShapes edgeShape = (MyEdgeShapes)index;
NShapeInfo info = new NShapeInfo(NSystem.InsertSpacesBeforeUppers(edgeShape.ToString()));
return info;
}
protected override Type GetEnumType()
{
return typeof(MyEdgeShapes);
}
}
public enum MyEdgeShapes
{
ArrowShape
}
To make the graph data importer use this shape factory to create edges, use the following piece of code:
MyEdgeShapeFactory edgesFactory = new MyEdgeShapeFactory();
edgesFactory.DefaultSize = new NSizeF(60, 30);
graphImporter.EdgeShapesFactory = edgesFactory;
graphImporter.EdgeShapesName = MyEdgeShapes.ArrowShape.ToString();
Best Regards,
Nevron Support Team