private void generateAdditionDataString(List <PathPart> motionPath) { double wholeDistance = 0.0; PathPoint lastPoint = null; foreach (PathPart part in motionPath) { wholeDistance += part.Distance(lastPoint); lastPoint = part.LastPoint(); } PathPart previousPart = null; String result = ""; foreach (PathPart part in motionPath) { result += "|" + part.typeCharacter + " "; bool needsComma = false; if (previousPart != null && previousPart.LastPoint() != null) { needsComma = true; result += previousPart.LastPoint().X.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")) + "," + previousPart.LastPoint().Y.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")); } foreach (PathPoint point in part.points) { result += (needsComma ? "," : "") + point.X.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")) + "," + point.Y.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")); needsComma = true; } if (previousPart != null) //First part doesn't have timing { double timing = (part.Distance(previousPart.LastPoint()) / wholeDistance) * ((double)Length / (double)1000); result += "," + timing.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")); } previousPart = part; } result += "|E " + previousPart.LastPoint().X.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")) + "," + previousPart.LastPoint().Y.ToString("0.##########", CultureInfo.CreateSpecificCulture("en-GB")); AdditionalData = "'" + result + "'"; }