Profile Picture

Connector shapes factory

Posted By Marius Bucur 14 Years Ago
Author
Message
Marius Bucur
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 12, Visits: 1
I've seen in the Diagram Designer application a Connector Shapes group in Library Browser but i cant find a Connector Factory. How did you added those connectors to library browser?

Ivo Milanov
Posted 14 Years Ago
View Quick Profile
Forum Member

Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)

Group: Forum Members
Last Active: 2 Months Ago
Posts: 35, Visits: 15
Hi Marius,

The connectors library group is generated for a library document on which the InitWithConnectors method has been called. The connectors are not available by a factory on purpose - all other factories are generally creating 2D shapes, which makes it possible to assign a default size to the shapes. Connectors are different - driven only by their end points. There is nothing special about the InitWithConnectors method - following is its current code:

public virtual void InitWithConnectors(NMeasurementUnit measurementUnit, NSizeF connectorSize)
{
if (connectorSize.Width == 0 || connectorSize.Height == 0)
throw new ArgumentException("##Connectors size width and height must not be 0", "connectors");

BeginInit();
RemoveAllChildren();

NRectangleF bounds = new NRectangleF(0, 0, connectorSize.Width, connectorSize.Height);
NPointF[] corners = bounds.Vertices;

// add line connector
NLineShape lineConnector = new NLineShape(corners[0], corners[2]);
lineConnector.StyleSheetName = NDR.NameConnectorsStyleSheet;
AddChild(new NMaster(lineConnector, measurementUnit, "Line Connector", ""));

// add bezier connector
NBezierCurveShape bezierConnector = new NBezierCurveShape(corners[0], corners[1], corners[3], corners[2]);
bezierConnector.StyleSheetName = NDR.NameConnectorsStyleSheet;
AddChild(new NMaster(bezierConnector, measurementUnit, "Bezier Connector", ""));

// add HV first horizontal
NStep2Connector step2Connector = new NStep2Connector(corners[0], corners[2], false);
step2Connector.StyleSheetName = NDR.NameConnectorsStyleSheet;
AddChild(new NMaster(step2Connector, measurementUnit, "Side to top/bottom", ""));

// add HV first vertical
step2Connector = new NStep2Connector(corners[0], corners[2], true);
step2Connector.StyleSheetName = NDR.NameConnectorsStyleSheet;
AddChild(new NMaster(step2Connector, measurementUnit, "Top/bottom to side", ""));

// add Side to Side connector
NStep3Connector step3Connector = new NStep3Connector(corners[0], corners[2], false, 50, 0, true);
step3Connector.StyleSheetName = NDR.NameConnectorsStyleSheet;
AddChild(new NMaster(step3Connector, measurementUnit, "Side to side", ""));

// add Top to Bottom connector
step3Connector = new NStep3Connector(corners[0], corners[2], true, 50, 0, true);
step3Connector.StyleSheetName = NDR.NameConnectorsStyleSheet;
AddChild(new NMaster(step3Connector, measurementUnit, "Top to bottom", ""));

// add arrow connectors
foreach (ArrowType arrowType in Enum.GetValues(typeof(ArrowType)))
{
NArrowShape arrowShape = new NArrowShape();
arrowShape.StyleSheetName = NDR.NameConnectorsStyleSheet;

(arrowShape.Primitive as NArrowPath).DefineModel(arrowType, corners[0], corners[2]);

string name = NSystem.InsertSpacesBeforeUppers(arrowType.ToString());
AddChild(new NMaster(arrowShape, measurementUnit, name, ""));
}

// add routable connectors
foreach (RoutableConnectorType routableConnectorType in Enum.GetValues(typeof(RoutableConnectorType)))
{
NRoutableConnector routableConnector = null;
switch (routableConnectorType)
{
case RoutableConnectorType.DynamicHV:
routableConnector = new NRoutableConnector(new NPointF[3] { corners[0], corners[3], corners[2] });
break;
case RoutableConnectorType.DynamicPolyline:
routableConnector = new NRoutableConnector(RoutableConnectorType.DynamicPolyline, new NPointF[2] { corners[0], corners[2] });
break;
case RoutableConnectorType.DynamicCurve:
routableConnector = new NRoutableConnector(RoutableConnectorType.DynamicCurve, new NPointF[2] { corners[0], corners[2] });
break;
}

routableConnector.StyleSheetName = NDR.NameConnectorsStyleSheet;

string name = NSystem.InsertSpacesBeforeUppers(routableConnectorType.ToString());
AddChild(new NMaster(routableConnector, measurementUnit, name, ""));
}

// init document info
Info.Author = "Nevron";
Info.Category = "Connectors";
Info.Company = "Nevron";
Info.Title = "Connector shapes";

EndInit();
IsModified = false;
}

Best regards,
Ivo

Marius Bucur
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 12, Visits: 1
Ty, i will look on it monday



Similar Topics


Reading This Topic