(ITypeDescriptorContext context, CultureInfo culture, object value)
| 182 | return ((destinationType == typeof(PointF)) || base.CanConvertTo(context, destinationType)); |
| 183 | } |
| 184 | public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) |
| 185 | { |
| 186 | if (culture == null) |
| 187 | culture = CultureInfo.CurrentCulture; |
| 188 | |
| 189 | if (!(value is string)) |
| 190 | return base.ConvertFrom(context, culture, value); |
| 191 | |
| 192 | string text = ((string)value).Trim(); |
| 193 | if (text.Length == 0) |
| 194 | return null; |
| 195 | |
| 196 | char ch = culture.TextInfo.ListSeparator[0]; |
| 197 | string[] textArray = text.Split(new char[] { ch }); |
| 198 | float[] numArray = new float[textArray.Length]; |
| 199 | if (numArray.Length != 2) |
| 200 | throw new ArgumentException("格式不正确"); |
| 201 | |
| 202 | TypeConverter converter = TypeDescriptor.GetConverter(typeof(float)); |
| 203 | for (int i = 0; i < numArray.Length; i++) |
| 204 | numArray[i] = (float)converter.ConvertFromString(context, culture, textArray[i]); |
| 205 | |
| 206 | return new PointF(numArray[0], numArray[1]); |
| 207 | } |
| 208 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) |
| 209 | { |
| 210 | if (culture == null) |
nothing calls this directly
no test coverage detected