Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic "Split" an existing arrow into two new a (Read 1990 times)
mattapayne
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 15
Joined: Mar 6th, 2007
"Split" an existing arrow into two new a
Mar 20th, 2007 at 3:59pm
Print Post  
Hi,

More fun with arrows!

Here's the scenario:

I need to allow a user to "split" an arrow - in other words, to select an arrow and cut it in half, effectively creating 2 new arrows joined at the separation point by a new Box.

This is simple in the case of a single segmented arrow, but I'm having trouble in the case of an arrow that has multiple segments where the user has created a shape. In this case I need to split it at the midpoint, but maintain the original shape.

So far I've had awesome help from this forum. I'm hoping that this is a doable scenario.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: "Split" an existing arrow into two n
Reply #1 - Mar 20th, 2007 at 6:21pm
Print Post  
Hi,

You might implement that by saving the control point positions for the original arrow, and assigning them back to the control points of the new arrows, e.g.

Code
Select All
private void splitAt(Arrow arrow, short segment, PointF point)
{
	if (arrow.Style == ArrowStyle.Polyline)
	{
		PointCollection points = arrow.ControlPoints.Clone();
		Box box = fc.CreateBox(point.X - 2, point.Y - 2, 4, 4);
		Arrow newArrow = fc.CreateArrow(box, arrow.Destination);
		arrow.Destination = box;

		arrow.SegmentCount = (short)(segment + 1);
		newArrow.SegmentCount = (short)(arrow.SegmentCount - segment);

		for (int i = 0; i < arrow.ControlPoints.Count - 1; ++i)
			arrow.ControlPoints[i] = points[i];
		arrow.UpdateFromPoints();

		for (int i = segment + 1; i < points.Count; ++i)
			newArrow.ControlPoints[i - segment] = points[i];
		newArrow.UpdateFromPoints();
	}
} 



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: "Split" an existing arrow into two n
Reply #2 - Mar 20th, 2007 at 6:45pm
Print Post  
Yeah, that's kind of what I was going for. I had created two new arrows and removed the old one, but I guess I could always just keep the old one and only create a single new one, then just reassign the control points.

Thanks as always.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: "Split" an existing arrow into two n
Reply #3 - Mar 21st, 2007 at 5:05am
Print Post  
In case anyone needs to get the segment index from the point coordinates - it is returned through an output parameter by one of the GetArrowAt overloaded methods.

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