This project has moved and is read-only. For the latest updates, please go here.

Best way to get Line with ONE arrow

Oct 8, 2012 at 10:02 AM


What is the best way to implement a Line shape having "arrow" only at its end point ?

Thank you.

Oct 9, 2012 at 8:26 AM

Derive your line from PolyLineBase and set the (protected) property "EndCapStyleInternal" to the desired cap style in the InitializeToDefault method:
        protected internal override void InitializeToDefault(IStyleSet styleSet) {
            EndCapStyleInternal = styleSet.CapStyles.ClosedArrow;

Oct 9, 2012 at 9:08 AM

Thank you very much, that's exactly what I need.

One question more: I need this line to be a bit thicker than by default. To achieve this I'm using the following code:

public override void DrawOutline(Graphics graphics, Pen pen)
    pen.Width = 2;
    base.DrawOutline(graphics, pen);

But this makes the end cap look very ugly :(( is there any way to fix it?

Oct 9, 2012 at 9:57 AM

All styling has to be done in the design. If you want a thicker line, create a thicker line style for it:

project.Design.LineStyles["Thick"].LineWidth = 2;

line.LineStyle = project.Design.LineStyles.Thick;

Never change the properties of pens, brushes, etc (beside transformation) because they are all reused instead of being created each time. Moreover, many GDI+ resources are interdependent (Pen and CustomLineCap for example).

Oct 9, 2012 at 10:09 AM

Thank you!