A path containing several open figures with a closed figure in the middle will not close correctly. It will treat the entire path as a single closed figure. Issue was fixed by updating get accessor in the XGraphicsPath.CurrentPathFigure property.
The code originally read:
Code:
/// <summary>
/// Gets the current path figure.
/// </summary>
private PathFigure CurrentPathFigure
{
get
{
int count = this.pathGeometry.Figures.Count;
if (count == 0)
{
this.pathGeometry.Figures.Add(new PathFigure());
count++;
}
else if (this.startNewFigure && this.pathGeometry.Figures[count - 1].Segments.Count == 0)
{
this.pathGeometry.Figures.Add(new PathFigure());
count++;
}
return this.pathGeometry.Figures[count - 1];
}
}
The apparent logic error is the '==' conditional in the else if statement. With fix, the code reads:
Code:
/// <summary>
/// Gets the current path figure.
/// </summary>
private PathFigure CurrentPathFigure
{
get
{
int count = this.pathGeometry.Figures.Count;
if (count == 0)
{
this.pathGeometry.Figures.Add(new PathFigure());
count++;
}
else if (this.startNewFigure && this.pathGeometry.Figures[count - 1].Segments.Count > 0)
{
this.pathGeometry.Figures.Add(new PathFigure());
count++;
}
return this.pathGeometry.Figures[count - 1];
}
}
With fix, only the closed figure is closed and other figures remain open.