public static List <Base> ToPathList(this string pathDataText) { pathDataText = pathDataText.Trim(); var strings = new List <string>(); int start = 0; for (int i = 1; i <= pathDataText.Length; i++) { if (i == pathDataText.Length || (char.ToLower(pathDataText[i]) != 'e' && char.IsLetter(pathDataText[i]))) { strings.Add(pathDataText.Substring(start, i - start)); start = i; } } var result = new List <PathElement.Base>(); foreach (var str in strings) { if (string.IsNullOrWhiteSpace(str)) { continue; } var cmd = char.ToUpper(str[0]); switch (cmd) { case Arc.Symbol: if (Arc.FromString(str) is List <Arc> arcList) { result.AddRange(arcList); } break; case BezierCurve.Symbol: if (BezierCurve.FromString(str) is List <BezierCurve> bezierCurveList) { result.AddRange(bezierCurveList); } break; case ClosePath.Symbol: result.Add(new ClosePath()); break; case HorzLineTo.Symbol: if (HorzLineTo.FromString(str) is HorzLineTo horzLineTo) { result.Add(horzLineTo); } break; case LineTo.Symbol: if (LineTo.FromString(str) is List <LineTo> lineList) { result.AddRange(lineList); } break; case MoveTo.Symbol: if (MoveTo.FromString(str) is List <Base> moveAndLineList) { result.AddRange(moveAndLineList); } break; case QuadraticCurve.Symbol: if (QuadraticCurve.FromString(str) is List <QuadraticCurve> quadraticCurveList) { result.AddRange(quadraticCurveList); } break; case ShortcutBezierCurve.Symbol: if (ShortcutBezierCurve.FromString(str) is List <ShortcutBezierCurve> shortcutBezierCurveList) { result.AddRange(shortcutBezierCurveList); } break; case ShortcutQuadraticCurve.Symbol: if (ShortcutQuadraticCurve.FromString(str) is List <ShortcutQuadraticCurve> shortcutQuadraticCurveList) { result.AddRange(shortcutQuadraticCurveList); } break; case VertLineTo.Symbol: if (VertLineTo.FromString(str) is VertLineTo vertLineTo) { result.Add(vertLineTo); } break; default: throw new Exception("Unrecognized Path Command : " + str); } } return(result); }