|
|
|
@ -5,6 +5,7 @@ using System.Globalization; |
|
|
|
namespace Avalonia.Markup.Xaml.Converters |
|
|
|
{ |
|
|
|
using System.ComponentModel; |
|
|
|
using Avalonia.Utilities; |
|
|
|
|
|
|
|
public class PointsListTypeConverter : TypeConverter |
|
|
|
{ |
|
|
|
@ -15,15 +16,17 @@ namespace Avalonia.Markup.Xaml.Converters |
|
|
|
|
|
|
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) |
|
|
|
{ |
|
|
|
string strValue = (string)value; |
|
|
|
string[] pointStrs = strValue.Split(new[] { ' ', '\t', '\r', '\n', ',' }, StringSplitOptions.RemoveEmptyEntries); |
|
|
|
var result = new List<Point>(pointStrs.Length / 2); |
|
|
|
for (int i = 0; i < pointStrs.Length; i += 2) |
|
|
|
var points = new List<Point>(); |
|
|
|
|
|
|
|
using (var tokenizer = new StringTokenizer((string)value, CultureInfo.InvariantCulture, exceptionMessage: "Invalid PointsList.")) |
|
|
|
{ |
|
|
|
result.Add(Point.Parse($"{pointStrs[i]} {pointStrs[i + 1]}")); |
|
|
|
while (tokenizer.TryReadDouble(out double x)) |
|
|
|
{ |
|
|
|
points.Add(new Point(x, tokenizer.ReadDouble())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
return points; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|