Profile Picture

Connectors are missing but Text of the connectors are appearing on the Diagram

Posted By kanakaraju tadimati 13 Years Ago

Connectors are missing but Text of the connectors are appearing on the...

Author
Message
kanakaraju tadimati
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 4, Visits: 1
I am building a tree dynamically. Am creating and positioning the shapes 1st and then am trying to connect them.
Shapes are appearing in the expected positions, but connectors are nor appearing.
Interesting part is, Text provided to the connectors are appearing.
Please find the code below that I have used.

private void FormTree(List QuestionList)
{
String ContainerStyle = String.Empty;
Queue QuestionQueue = new Queue();
List ChildQuestions = new List();
Dictionary QuestionBoundsShape = new Dictionary();
QuestionBounds QuestionInst;

while (QuestionQueue.Count != 0)
{
QuestionInst = QuestionQueue.Dequeue();

switch (QuestionInst.Question.ContainerShapeCode)
{
case 18:
ContainerStyle = "STARTEND";
break;
case 0:
ContainerStyle = "ACTION";
break;
case 1:
ContainerStyle = "QUESTION";
break;
default:
break;
}
//Creating Shape
NShape start = CreateFlowChartingShape(QuestionInst.Question.ContainerShapeCode, QuestionInst.Bounds, QuestionInst.Question.Question, ContainerStyle);

var ParentShapeA = from n in QuestionBoundsShape
where n.Key.Case_Questions_ID == QuestionInst.Question.ParentQuestion
select n.Value;

NShape[] ParentShape = ParentShapeA.ToArray();
QuestionBoundsShape.Add(QuestionInst.Question, start);

ChildQuestions = GetChildren(QuestionList, QuestionInst.Question.Case_Questions_ID);
foreach (var Question in ChildQuestions)
{
QuestionQueue.Enqueue(Question);
}
}

//Code to create connectors

foreach (var Question in QuestionBoundsShape)
{
var ParentShapeA = from n in QuestionBoundsShape
where n.Key.Case_Questions_ID == Question.Key.ParentQuestion
select n.Value;

NShape[] ParentShape = ParentShapeA.ToArray();

if (ParentShape.Length > 0)
{
CreateConnector(ParentShape[0], "Bottom", Question.Value, "Top", ConnectorType.TopToBottom, Question.Key.YesorNo);
}

}

}

//Method to create connectors
protected NShape CreateConnector(NShape fromShape, string fromPortName, NShape toShape, string toPortName, ConnectorType connectorType, string text)
{
// check arguments
if (fromShape == null)
throw new ArgumentNullException("fromShape");

if (toShape == null)
throw new ArgumentNullException("toShape");

NPort fromPort = (fromShape.Ports.GetChildByName(fromPortName, 0) as NPort);
if (fromPort == null)
throw new ArgumentException("Was not able to find fromPortName in the ports collection of the fromShape", "fromPortName");

NPort toPort = (toShape.Ports.GetChildByName(toPortName, 0) as NPort);
if (toPort == null)
throw new ArgumentException("Was not able to find toPortName in the ports collection of the toShape", "toPortName");

// create the connector
NShape connector = null;
switch (connectorType)
{
case ConnectorType.Line:
connector = new NLineShape();
break;

case ConnectorType.Bezier:
connector = new NBezierCurveShape();
break;

case ConnectorType.SingleArrow:
connector = new NArrowShape(ArrowType.SingleArrow);
break;

case ConnectorType.DoubleArrow:
connector = new NArrowShape(ArrowType.DoubleArrow);
break;

case ConnectorType.SideToTopBottom:
connector = new NStep2Connector(false);
break;

case ConnectorType.TopBottomToSide:
connector = new NStep2Connector(true);
break;

case ConnectorType.SideToSide:
connector = new NStep3Connector(false, 50, 0, true);
break;

case ConnectorType.TopToBottom:
connector = new NStep3Connector(true, 50, 0, true);
break;

case ConnectorType.DynamicHV:
connector = new NRoutableConnector(RoutableConnectorType.DynamicHV);
break;

case ConnectorType.DynamicPolyline:
connector = new NRoutableConnector(RoutableConnectorType.DynamicPolyline);
break;

case ConnectorType.DynamicCurve:
connector = new NRoutableConnector(RoutableConnectorType.DynamicCurve);
break;

default:
Debug.Assert(false, "New graph connector type?");
break;
}

// the connector must be added to the document prior to connecting it
DrawingView.Document.ActiveLayer.AddChild(connector);

// change the default label text
connector.Text = text;

// connectors by default inherit styles from the connectors stylesheet
connector.StyleSheetName = NDR.NameConnectorsStyleSheet;

// connect the connector to the specified ports
connector.StartPlug.Connect(fromPort);
connector.EndPlug.Connect(toPort);

// modify the connector text style
connector.Style.TextStyle = (connector.ComposeTextStyle().Clone() as NTextStyle);
connector.Style.TextStyle.Offset = new NPointL(0, -7);

return connector;
}

#endregion
}

Am I missing some thing. Please help me out.



Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi,

Please, send your whole sample project to our support e-mail: support@nevron.com and we will tell you what is wrong with it and how to correct it.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic