Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Save and recreate arrow points (Read 1539 times)
Johan
Guest


Save and recreate arrow points
Jan 25th, 2006 at 11:39am
Print Post  
Hello! Thanks for a really nice product.

Now for the question, I have a flowchart with a number of connected tables. I want to control the route of the arrows (allow the user to control how they are routed).

How do I get the points where the arrow route turns and save them and then how do I create the arrows back in the same way

Thanks!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Save and recreate arrow points
Reply #1 - Jan 25th, 2006 at 2:01pm
Print Post  
Hi,

We are glad to know that you like Flowchart.NET!

You could use the following methods to save and restore the path of arrows:

Code
Select All
class ArrowPath
{
  public Node origin;
  public Node dest;
  public int orgRow;
  public int destRow;
  public ArrowStyle style;
  public short segmentCount;
  public PointCollection points;
}

ArrowPath saveArrowPath(Arrow a)
{
  ArrowPath ap = new ArrowPath();
  ap.origin = a.Origin;
  ap.dest = a.Destination;
  ap.orgRow = a.OrgnIndex;
  ap.destRow = a.DestIndex;
  ap.style = a.Style;
  ap.segmentCount = a.SegmentCount;
  ap.points = a.ControlPoints.Clone();
  return ap;
}

void restoreArrowPath(ArrowPath ap, Arrow a)
{
  a.Origin = ap.origin;
  a.Destination = ap.dest;
  a.OrgnIndex = ap.orgRow;
  a.DestIndex = ap.destRow;
  a.Style = ap.style;
  a.SegmentCount = ap.segmentCount;
  for (int i = 0; i < a.ControlPoints.Count; ++i)
    a.ControlPoints[i] = ap.points[i];
}
 



The number of control points depends both on the arrow Style and SegmentCount, so you must set these properties before assigning the points values. E.g. a Bezier arrow with 2 segments has 7 control points, while a Polyline with 2 segments has 3 control points. If there are less points in the collection than indicated in arrows Style and SegmentCount, there will be an "index out of range: exception thrown at some point.

If you use anchor points, you might also save and restore the OrgnAcnhor and DestAnchor properties.

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