MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / ConvertFrom

Method ConvertFrom

TexturedFontEditor/Helper.cs:342–365  ·  view source on GitHub ↗
(ITypeDescriptorContext context, CultureInfo culture, object value)

Source from the content-addressed store, hash-verified

340 return ((destinationType == typeof(Color)) || base.CanConvertTo(context, destinationType));
341 }
342 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
343 {
344 if (culture == null)
345 culture = CultureInfo.CurrentCulture;
346
347 if (!(value is string))
348 return base.ConvertFrom(context, culture, value);
349
350 string text = ((string)value).Trim();
351 if (text.Length == 0)
352 return null;
353
354 char ch = culture.TextInfo.ListSeparator[0];
355 string[] textArray = text.Split(new char[] { ch });
356 int[] numArray = new int[textArray.Length];
357 if (numArray.Length != 4)
358 throw new ArgumentException("格式不正确");
359
360 TypeConverter converter = TypeDescriptor.GetConverter(typeof(int));
361 for (int i = 0; i < numArray.Length; i++)
362 numArray[i] = (int)converter.ConvertFromString(context, culture, textArray[i]);
363
364 return Color.FromArgb(numArray[0], numArray[1], numArray[2], numArray[3]);
365 }
366 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
367 {
368 if (culture == null)

Callers 2

ConvertFromMethod · 0.45
ConvertFromMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected