blob: 9b949988451ae3bc8b20dcfa121213f6557d7cec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
using System;
using System.Globalization;
namespace Xamarin.Forms
{
public class PointTypeConverter : TypeConverter
{
public override object ConvertFromInvariantString(string value)
{
if (value != null)
{
double x, y;
string[] xy = value.Split(',');
if (xy.Length == 2 && double.TryParse(xy[0], NumberStyles.Number, CultureInfo.InvariantCulture, out x) && double.TryParse(xy[1], NumberStyles.Number, CultureInfo.InvariantCulture, out y))
return new Point(x, y);
}
throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(Point)));
}
}
}
|