Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Change AnchorPattern and redraw (Read 1709 times)
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Change AnchorPattern and redraw
Mar 28th, 2007 at 5:47am
Print Post  
Hello,

i got the following problem:

I draw a Box and want to change the AnchorPattern according to the number of arrows this Box is attached to.

I tried the following:

Code
Select All
private void flowChart_ArrowCreated(object sender, ArrowEventArgs args)
{
            //get count of Arrows
            int incArrows = args.Arrow.Destination.IncomingArrows.Count;
            int outArrows = args.Arrow.Destination.OutgoingArrows.Count;
            // build new anchor points
            AnchorPointCollection ap = new AnchorPointCollection();
            int incomPat = 100 / (incArrows + 1);
            int outgoPat = 100 / (outArrows + 1);

            // distribute the anchors on the Box
            for (int i = 0; i < incArrows+1; i++)



{
                ap.Add(new AnchorPoint((short)((i+1)*incomPat), 25, true, false, MarkStyle.Circle, Color.Blue));
}
            for (int i = 0; i < outArrows+1; i++)
{
    ap.Add(new AnchorPoint((short)((i+1)*outgoPat), 75, false, true, MarkStyle.Circle, Color.Blue));
}

ap.Add(new AnchorPoint(100,50,true,true, MarkStyle.Cross, Color.Red));

            AnchorPattern pat = new AnchorPattern(ap);
            //assign the new anchor pattern to the Box
            args.Arrow.Destination.AnchorPattern = pat;

            //register all arrows to the new pattern!
            ArrowCollection arCol = args.Arrow.Destination.IncomingArrows;
            int counter = 0;
            foreach (Arrow arrow in arCol)
            {
                arrow.DestAnchor = counter;
                ++counter;
            }
} 



Problem is, that the arrow aligns to the right place when created, but the already connected arrows do not realign.

Any ideas? I currently find no solution...

Thank you again!

Alex

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Change AnchorPattern and redraw
Reply #1 - Mar 28th, 2007 at 6:03am
Print Post  
Hello,

You might set the OrgnAnchor and DestAnchor properties of the already connected arrows in order to realign them. Or call the Arrow.ReassignAnchorPoints() method and handle the ValidateAnchorPoint event.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: Change AnchorPattern and redraw
Reply #2 - Mar 28th, 2007 at 6:39am
Print Post  
This is what I've tried to do (see above), but it doesn't work.

Same problem with the ReassignAnchorPoints(). If I call this function, all Arrows are connected to the first anchor (which is at least at the right position).

I think I'm missing something ... can you help?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Change AnchorPattern and redraw
Reply #3 - Mar 28th, 2007 at 7:42am
Print Post  
Maybe the arrows compare their old DestAnchor value with the new one, and if it's the same the property setter just returns. Try setting the property value to 0, and then immediately to the intended point index.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint