Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic AutoRoute (Read 2160 times)
alesdario
Junior Member
**
Offline



Posts: 71
Joined: Mar 7th, 2007
AutoRoute
Mar 13th, 2007 at 8:16am
Print Post  
Hi stoyo.

I link a Box to a Bezier Arrow. But the first time arrow is drawed, she reroute herself cause the box is positioned in arrow' middle point. ( i calculate this with your formula ).
I don't want that arrow reroute when a box is linked to.
This is the code. Can you check if there are some error?

Code
Select All
private void flow_ArrowCreated(object sender, ArrowEventArgs e)
{
Box bImm;

PointF center;

bImm = this.flow.CreateBox((r.Approssima(e.Arrow).X-19),(r.Approssima(e.Arrow).Y-24),38,48);

bImm.Style = BoxStyle.Shape;
bImm.Shape = myshape;
bImm.Image = Image.FromFile(@"D:/Prototipi/Designer/test2/Association/MyBox/MyBox/home.ico");
bImm.ImageAlign = ImageAlign.Fit;
bImm.Text  ="transazione";
bImm.Locked = false;
bImm.Font = new Font("Arial",10,System.Drawing.GraphicsUnit.World);
bImm.AttachTo(e.Arrow,AttachToArrow.LongestHSegment,1);
bImm.Transparent = true;

}


public void insertBezierSegment(Arrow arrow, int segment,int index)
{
DialogResult mess = new DialogResult();

int pos = index;

if (arrow.Style != ArrowStyle.Bezier)
mess = MessageBox.Show("Non hai disegnato una curva di bezier!","Errore");

if (segment > arrow.SegmentCount)
mess = MessageBox.Show("Invalid segment args","Errore");

PointCollection savedPoints = arrow.ControlPoints.Clone();

arrow.SegmentCount++;

//Approssima is a method who calculate Bezier Arrow' Middle point
PointF f = this.Approssima(arrow);

// restore the points of the old segments
for (int i = 0; i < segment * 4; ++i)
arrow.ControlPoints[i] = savedPoints[i];
for (int i = (segment + 1) * 4; i < arrow.ControlPoints.Count; ++i)
arrow.ControlPoints[i] = savedPoints[i - 3];

arrow.ControlPoints[pos] = f;
}

 


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: AutoRoute
Reply #1 - Mar 13th, 2007 at 8:48am
Print Post  
Hi Alesdario,

Try creating the image box by calling the Box constructor, setting the Obstacle property to false, and calling FlowChart.Add().

As I think about this some more, it seems it will be better to set Arrow.CustomDraw = Additional, then handle the DrawArrow event and draw the image from there. That will ensure that the image is always drawn at the correct point. Otherwise attaching to arrow's segment or control point for one shape of the Bezier arrow might still displace the image box when you drag control points around.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: AutoRoute
Reply #2 - Mar 13th, 2007 at 8:51am
Print Post  
I mean you can call the e.Graphics.DrawImage method to draw the image at the middle point for the arrow, instead of creating an attached box.

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