Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic SegmentCount not always updated (Read 1889 times)
Todd
YaBB Newbies
*
Offline



Posts: 9
Joined: Apr 15th, 2008
SegmentCount not always updated
Apr 17th, 2008 at 4:48pm
Print Post  
When writing some custom code to insert new ControlPoints to a DiagramLink via a context menu I found that SegmentCount was not being updated appropriately.

The code I was executing looked like so:
link.ControlPoints.Insert(nNewPointIndex, ptNew);
link.UpdateFromPoints();

What was interesting to me is that future calls like the following were returning the correct nSegment to me.

DiagramLink link = diagram.GetLinkAt(ptLocation, fDistance, bExcludeLocked, ref nSegment);

However, if on the very next line I checked link.SegmentCount it was always 1;
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SegmentCount not always updated
Reply #1 - Apr 18th, 2008 at 5:47am
Print Post  
Inserting new points directly into ControlPoints isn't supported officially, since there might be more complex dependencies between the points when using cascading or bezier links, and adding a point at a random position might break them. Anyway the following should work for polyline links:

- create a clone of the ControlPoints collection
- insert the new point into the cloned collection
- increment SegmentCount
- assign the cloned points back to ControlPoints

For Bezier links, you must add three points for each new segment. For cascading links, you must align the points adjacent to the newly added one, so that the segments keep their horizontal and vertical orientations.

You might check how the AllowSplitLinks property works - it will let you insert new segments by clicking and dragging at any point of the link.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint