summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/PointTypeConverter.cs
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-03-22 13:02:25 -0700
committerJason Smith <jason.smith@xamarin.com>2016-03-22 16:13:41 -0700
commit17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch)
treeb5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Core/PointTypeConverter.cs
downloadxamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip
Initial import
Diffstat (limited to 'Xamarin.Forms.Core/PointTypeConverter.cs')
-rw-r--r--Xamarin.Forms.Core/PointTypeConverter.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/PointTypeConverter.cs b/Xamarin.Forms.Core/PointTypeConverter.cs
new file mode 100644
index 00000000..9b949988
--- /dev/null
+++ b/Xamarin.Forms.Core/PointTypeConverter.cs
@@ -0,0 +1,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)));
+ }
+ }
+} \ No newline at end of file