79 using System.ComponentModel;
80 using System.Globalization;
82 namespace SiliconStudio.
Paradox.Assets.SpriteFont.Compiler
86 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
88 return sourceType == typeof(
string);
92 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture,
object value)
95 string source = value as string;
97 if (
string.IsNullOrEmpty(source))
99 throw new ArgumentException();
108 var splitStr = source.Split(
'-');
109 var split =
new char[splitStr.Length];
110 for (
int i = 0; i < splitStr.Length; i++)
112 split[i] = ConvertCharacter(splitStr[i]);
115 switch (split.Length)
119 return new CharacterRegion(split[0], split[0]);
123 return new CharacterRegion(split[0], split[1]);
126 throw new ArgumentException();
131 static char ConvertCharacter(
string value)
133 if (value.Length == 1)
141 return (
char)(int)intConverter.ConvertFromInvariantString(value);
146 static TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(
int));