public static Rectangle GetRectangle(String name)
{
name = name.Trim().ToUpper(System.Globalization.CultureInfo.InvariantCulture);
int pos = name.IndexOf(' ');
if (pos == -1) {
try {
return (Rectangle)typeof(PageSize).GetField(name).GetValue(null);
} catch (Exception) {
throw new ArgumentException(MessageLocalization.GetComposedMessage("can.t.find.page.size.1", name));
}
}
else {
try {
String width = name.Substring(0, pos);
String height = name.Substring(pos + 1);
return new Rectangle(float.Parse(width, System.Globalization.NumberFormatInfo.InvariantInfo), float.Parse(height, System.Globalization.NumberFormatInfo.InvariantInfo));
} catch(Exception e) {
throw new ArgumentException(MessageLocalization.GetComposedMessage("1.is.not.a.valid.page.size.format.2", name, e.Message));
}
}
}