You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
808 B
C#
28 lines
808 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace OptionStudy.Next
|
|
{
|
|
public class PointTypeConverter: TypeConverter
|
|
{
|
|
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
|
{
|
|
return sourceType == typeof(string);
|
|
}
|
|
|
|
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
|
|
{
|
|
var split = (value.ToString()??"0.0,0.0").Split(',');
|
|
double x = double.Parse(split[0].Trim().TrimStart('('));
|
|
double y = double.Parse(split[1].Trim().TrimEnd(')'));
|
|
|
|
return new Point(x, y);
|
|
}
|
|
}
|
|
}
|