Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Remove control points from an arrow (Read 3856 times)
CharlesG
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Feb 21st, 2006
Remove control points from an arrow
Feb 21st, 2006 at 1:54pm
Print Post  
Hi,

The flowchart I have is using Polyline arrows, SegmentCount is 1, SnapToAnchor property is set to saOnCreateOrModify.

I allow the user to add multiple controls points to the arrows between boxes by dragging them, however, I also want to provide the functionality where they can just remove all the control points (apart from 2 needed for a 1 segment arrow) by selecting an arrow and choosing a menu option.

Here is the code I have been trying to do this with:

foreach (Arrow arr in this.FlowChartMap.Selection.Arrows)
{
arr.SegmentCount = 1;

int NoOfControlPoints = arr.ControlPoints.Count;

for (int i = 1; i < (NoOfControlPoints - 1); i++)
{
arr.ControlPoints.RemoveAt(i);
}

arr.UpdateFromPoints();

}

However, the flowchart appears as a huge X when I run this code. How should I be removing the control points?

Thanks,
Charles
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Remove control points from an arrow
Reply #1 - Feb 21st, 2006 at 3:11pm
Print Post  
Hi,

After you set

arr.SegmentCount = 1;

the ControlPoints collection will contain just two points, you should not remove any points from it. You could just restore the end points positions, e.g.

srcPt = arr.ControlPoints[0];
dstPt = arr.ControlPoints[arr.ControlPoints - 1];
arr.SegmentCount = 1; // that resets the points
arr.ControlPoints[0] = srcPt;
arr.ControlPoints[1] = dstPt;
arr.UpdateFromPoints();

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
CharlesG
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Feb 21st, 2006
Re: Remove control points from an arrow
Reply #2 - Feb 22nd, 2006 at 9:16am
Print Post  
Hi,

That code works when the arrow has 3 control points. However it doesn't work when the arrow has more than 3 control points, the arrow appears to be disjointed/split after running the code.
Also, setting to SegmentCount = 1 does not change the no. of the control points, the number of these always stays the same.

Any ideas?
Charles.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Remove control points from an arrow
Reply #3 - Feb 22nd, 2006 at 9:37am
Print Post  
Hi

Are you sure the arrow is a Polyline one ? If the arrow Style is cascading, the control won't let you set less than 2 segments.

Stoyan
  
Back to top
 
IP Logged
 
CharlesG
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Feb 21st, 2006
Re: Remove control points from an arrow
Reply #4 - Feb 22nd, 2006 at 2:00pm
Print Post  
Yes it is polyline.
It has originally only one segment and the user can then drag it around to add more.

Charles.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Remove control points from an arrow
Reply #5 - Feb 22nd, 2006 at 2:58pm
Print Post  
Is by any chance arrow.AutoRoute enabled ? If it's enabled, the control won't let you change the number of segments at all. You might have to set AutoRoute = false temporarily.

Stoyan
  
Back to top
 
IP Logged
 
CharlesG
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Feb 21st, 2006
Re: Remove control points from an arrow
Reply #6 - Feb 22nd, 2006 at 3:03pm
Print Post  
Yes that's it !
I set AutoRoute to false and that resolves it.

Thanks a lot,
Charles.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint