We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Drawing OrthogonalConnector programmatically

Hi,
I am using Syncfusion Essential Studio 7.4 and am trying to create an OrthogonalConnetor link between two ports wherein the points on the connector should be custom defined.
Previously, I was using the TryConnect() method which connects two points with the route of the link assigned automatically.
but I wish to assign the points on the link programmatically for which I tried using SetPoints() method which is not working.
Hoping for a quick response as this is an urgent requirement.
The code snippet I am using is as follows:


OrthogonalConnector connectionLine = new OrthogonalConnector(pointFromPortPoint, pointToPortPoint);// .PinPoint, polygon.PinPoint);
connectionLine.LineBridgingEnabled = true;
connectionLine.BridgeStyle = BridgeStyle.Arc;
connectionLine.LineRoutingEnabled = true;
connectionLine.LineHitTestPadding = 10;
connectionLine.EnableCentralPort = false;
funcBlockFrom.Ports[intFromNodePortNo].TryConnect(connectionLine.TailEndPoint);
funcBlockTo.Ports[intToNodePortNo].TryConnect(connectionLine.HeadEndPoint);
//PointF[] arr = connectionLine.GetPoints();

String[] asConnPoints = strConnectorPoints.Split(';');
PointF[] arrConnPoints = new PointF[(asConnPoints.Count() - 1) / 2];
for (int i = 0, j = 0; i < (asConnPoints.Count() - 1); j++)
{
float x = (float)Convert.ToDouble(asConnPoints.ElementAt(i));
float y = (float)Convert.ToDouble(asConnPoints.ElementAt(i+1));
PointF point = new PointF(x, y);
arrConnPoints.SetValue(point, j);
i += 2;
}
connectionLine.SetPoints(arrConnPoints);
PointF[] a = connectionLine.GetPoints();
FlexControlBAL.sequencerUserControlProductType1.diagramSequencerUserControl.Model.AppendChild(connectionLine);
foreach (Node node in FlexControlBAL.sequencerUserControlProductType1.diagramSequencerUserControl.Model.Nodes)
{
if (node is OrthogonalConnector)
{
//PointF[] b = ((OrthogonalConnector)node).GetPoints();
int ss = ((OrthogonalConnector)node).MaxPoints;
((OrthogonalConnector)node).MaxPoints = arrConnPoints.Count();
for (int i = 0; i < arrConnPoints.Count(); i++)
{
PointF ssss = (PointF)arrConnPoints.GetValue(i);
((OrthogonalConnector)node).SetPoint(i, ssss);
}
//PointF[] c = ((OrthogonalConnector)node).GetPoints();
}
}

4 Replies

DM Dinesh M Syncfusion Team January 21, 2010 06:31 PM UTC

Hi Santanu,

Though the SetPoints method is public, it doesn't allow the users to set path points using it. I will check this issue and update you with further details in one business day.

Regards,
Dinesh


SS Santanu Sarma February 3, 2010 05:30 AM UTC

Hi Dinesh,
the SetPoint() method allows connector points to be custom set only when called without the line conneting two ports. But the moment TryConnect() method is called, the line seems to be automatically rerouted and SetPoints() method doesn't seem to work.

Looking for a quick response.

Regards,
Santanu.


SS Santanu Sarma February 8, 2010 07:59 AM UTC

Hi Dinesh,
I am yet to receive a response regarding the issue mentioned above. Hope to get a response soon.

Regards,
Santanu Sarma.


DM Dinesh M Syncfusion Team February 9, 2010 12:04 PM UTC

Hi Santanu,

Sorry for the inadvertent delay in response. Whenever you set points of the orthogonal connector we need to ensure that the consecutive/adjacent points provided are in line(horizontal or vertical) with each other. To be more precise the points should meet the following criteria.

Geometry.CheckPointOnLine(pts[i], pts[i + 1], 0)

The following set of points will work even for connected OrthogonalConnectors.

OrthogonalConnector con = diagram1.Controller.SelectionList[0] as OrthogonalConnector;
if (con != null)
{
con.SetPoints(new PointF[5] {new PointF(0,0), new PointF(100, 0), new PointF(100, 100), new PointF(100,200), new PointF(200,200) }, true);
}

Let me know if you shall need any further clarifications in this regard.

Regards,
Dinesh

Loader.
Live Chat Icon For mobile
Up arrow icon