Custom link style

I have the following code, to add some arrow heads to my links
if (myArrowPosition == ArrowPositionEnum.Multiple )
{
int num = this.PointsCount;
if (num < 2) return;
for (int i = 0; i < num-1; i++)
{
PointF a2, m2;
CalculateArrowPoints(GetPoint(i), GetPoint(i+1), out a2, out m2);
CalculateArrowhead(a2, m2, true, myPoly);
DrawArrowhead(g, view, new Pen(System.Drawing.Color.Red), new SolidBrush(System.Drawing.Color.Red), true, 0, 0, myPoly);
}

}
The problem is that my customer wants some gap/space after each arrow, so that the link will look more like multiple arrows, more than just a single link with multiple arrowheads .
what we have now : ----->------>
what we need : -----> ------>

It might be easiest to draw over a little bit of the stroke with a Pen that is the same color as the background, just before you call DrawArrowhead.

that’s exactly what I am trying right now, but i have a problem: I do not know which direction the link goes, so I don’t know where exactly to draw

Well, the link has to go from GetPoint(i+1) to GetPoint(i+2), assuming that segment exists (i.e. i+2 < num).

it seemed to work fine, but then I saw the app crasses. After searching this forum a little I found :

walter
Admin Group



Joined: 19 May 2003
Posts: 2402
Posted: 01 September 2005 at 8:14pm | IP Logged

Implementations of the GoObject.Paint method must NOT modify any objects, neither in the document nor in the view.

Is your code above part of an override of GoObject.Paint?
Do you modify any GoObjects in that method? I would think not, in which case there is some other failure. Please see what is causing the exception. What is the exception, anyway?

forget about it. found the problem.
it is not because I’m using the paint method, it is because I called
DrawArrowhead method after
ToArrowStyle = GoStrokeArrowheadStyle.Circle.
seems like the last param of DrawArrowhead isnt’t ok. will fix this.

It is in the paint method of a link object