Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Reverse A Multisegmented Arrow and Maintain Shape? (Read 1636 times)
mattapayne
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 15
Joined: Mar 6th, 2007
Reverse A Multisegmented Arrow and Maintain Shape?
Mar 10th, 2007 at 4:24pm
Print Post  
Hi,

I need to reverse a multisegmented arrow while maintaining the shape specified by the user.

The code currently does this:

ArrowStyle oStyle = _contextArrow.Style;
_contextArrow.RetainForm = true;
MindFusion.FlowChartX.Node oNode = _contextArrow.Origin;
_contextArrow.Origin = _contextArrow.Destination;
_contextArrow.Destination = oNode;
_contextArrow.Style = oStyle;

The ArrowStyle is PolyLine - if that makes a difference.

While this does reverse the endpoints properly, the additional segments are lost and the arrow reverts back to a straight line.

It seems to me that perhaps I need to get a reference the the arrow's control points and then reassign them after the reversal. Does that make sense or is there a better way?


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Reverse A Multisegmented Arrow and Maintain Sh
Reply #1 - Mar 11th, 2007 at 8:35am
Print Post  
Hi,

You can do that by cloning the arrow control points before changing the Origin and Destination, and restoring them in reversed order after that.

The arrow style changes automatically when the arrow's origin and destination nodes get the same, which happens at one point of the code where the nodes are swapped, so the style must be restored too:

Code
Select All
private void reverseArrow(Arrow arrow)
{
	short segments = arrow.SegmentCount;
	ArrowStyle style = arrow.Style;
	PointCollection points = arrow.ControlPoints.Clone();

	Node node = arrow.Origin;
	arrow.Origin = arrow.Destination;
	arrow.Destination = node;

	arrow.SegmentCount = segments;
	arrow.Style = style;
	for (int i = 0; i < points.Count; ++i)
		arrow.ControlPoints[points.Count - i - 1] = points[i];

	arrow.UpdateFromPoints();
}
 



If your flowcharts will contain tables, you will need to add some code that swaps the related row indices as well.

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


I love YaBB 1G - SP1!

Posts: 15
Joined: Mar 6th, 2007
Re: Reverse A Multisegmented Arrow and Maintain Sh
Reply #2 - Mar 12th, 2007 at 2:05pm
Print Post  
Thanks, Stoyo. Figured it was something like that.

Regards,
Matt
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint