5 changed files with 49 additions and 4 deletions
@ -0,0 +1,37 @@ |
|||||
|
using OmniXaml.TypeConversion; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Globalization; |
||||
|
|
||||
|
namespace Perspex.Markup.Xaml.Converters |
||||
|
{ |
||||
|
public class PointsListTypeConverter : ITypeConverter |
||||
|
{ |
||||
|
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType) |
||||
|
{ |
||||
|
return sourceType == typeof(string); |
||||
|
} |
||||
|
|
||||
|
public bool CanConvertTo(IXamlTypeConverterContext context, Type destinationType) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
public object ConvertFrom(IXamlTypeConverterContext 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); |
||||
|
foreach (var pointStr in pointStrs) |
||||
|
{ |
||||
|
result.Add(Point.Parse(pointStr, culture)); |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
public object ConvertTo(IXamlTypeConverterContext context, CultureInfo culture, object value, Type destinationType) |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue