Method to draw an open or closed polyline
A closed polyline is really a polygon. For clarity, why not just call it a polygon?  There is no point in trying to do too much in the same function. Not only would the calling code be clearer, the implementations would be simpler too, without the special cases.

void Polyline(IList&lt;Point&gt; points)
{
    var n = points.Count - 1;
    for (int i = 0; i &lt; n; i++)
    {
        AddLineSegment(points[i], points[i + 1]);
    }
}

void Polygon(IList&lt;Point&gt; points)
{
    Polyline(points);
    if (points.Count &gt;= 3)
    {
        AddLineSegment(points[points.Count - 1], points[0]);
    }
}