Attempting to connect a Group with a Shape


Author
Message
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi,

There are 2 problems in your code:

1. You should update the model bounds of the group using its UpdateModelBounds() method when you have finished adding shapes to it.

2. You should add a port to the group before trying to attch a connector to it as by default all shapes and groups not created by a shape factory do not have any ports.

You code should look like this:

// Create the group

NGroup group1 = new NGroup();

m_View.Document.ActiveLayer.AddChild(group1);

group1.Shapes.AddChild(step1);

group1.Shapes.AddChild(step2);

group1.UpdateModelBounds();

 

// Create a "Center" port for the group

group1.CreateShapeElements(ShapeElementsMask.Ports);

NPort port = new NDynamicPort(new NContentAlignment(ContentAlignment.MiddleCenter), DynamicPortGlueMode.GlueToLocation);

port.Name = "Center";

group1.Ports.AddChild(port);

group1.Ports.DefaultInwardPortUniqueId = port.UniqueId;

 

// Connect the "BEGIN" shape and the group

NStep3Connector connector = new NStep3Connector();

m_View.Document.ActiveLayer.AddChild(connector);

connector.FromShape = begin;

connector.ToShape = group1;



Best Regards,
Nevron Support Team


Ramesh Ramaraj
Ramesh Ramaraj
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)
Group: Forum Members
Posts: 2, Visits: 1

In the following example, we are trying to connect the Shape BEGIN with the Group using a connector and it cannot find the PORT for the GROUPS.

And unable to figure out how to draw a border around the Groups.

// create the begin shape

NShape begin = factory.CreateShape((int)FlowChartingShapes.Termination);
begin.Bounds =
new NRectangleF(100, 100, 100, 100);
begin.Text =
"BEGIN";
NDrawingView1.Document.ActiveLayer.AddChild(begin);

// create the step1 shape

NShape step1 = factory.CreateShape((int)FlowChartingShapes.Process);

step1.Bounds = new NRectangleF(100, 400, 100, 100);

step1.Text = "STEP1";

// NDrawingView1.Document.ActiveLayer.AddChild(step1);

 

// create the step2 shape

NShape step2 = factory.CreateShape((int)FlowChartingShapes.Process);

step2.Bounds = new NRectangleF(400, 400, 100, 100);

step2.Text = "STEP2";

//NDrawingView1.Document.ActiveLayer.AddChild(step2);

NGroup group1 = new NGroup();

NDrawingView1.Document.ActiveLayer.AddChild(group1);

group1.Shapes.AddChild(step1);

group1.Shapes.AddChild(step2);

 

NStep3Connector connector = null;

connector = CreateConnector(NDrawingView1.Document, begin, "Center", group1, "Center", ConnectorType.TopToBottom, "") as NStep3Connector;


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search