public static Color ToColor(PropertyDictionary dictionary) { if (!dictionary.HasIntegerFor("red", "green", "blue")) { throw new PropertyListException("A color property dictionary is missing one or " + "both of the required fields (red, green or blue)."); } return Color.FromArgb( (byte)dictionary.IntegerFor("alpha", 255), (byte)dictionary.IntegerFor("red").Value, (byte)dictionary.IntegerFor("green").Value, (byte)dictionary.IntegerFor("blue").Value ); }
public static Rectangle ToRectangle(PropertyDictionary dictionary) { if (!dictionary.HasIntegerFor("x", "y", "width", "height")) { throw new PropertyListException("A rectangle property dictionary is missing some or " + "all of the required fields (x, y, width or height)."); } return new Rectangle( dictionary.IntegerFor("x").Value, dictionary.IntegerFor("y").Value, dictionary.IntegerFor("width").Value, dictionary.IntegerFor("height").Value ); }
public static Size ToSize(PropertyDictionary dictionary) { if (!dictionary.HasIntegerFor("width", "height")) { throw new PropertyListException("A size property dictionary is missing one or " + "both of the required fields (width or height)."); } return new Size( dictionary.IntegerFor("width").Value, dictionary.IntegerFor("height").Value ); }
public static Point ToPoint(PropertyDictionary dictionary) { if (!dictionary.HasIntegerFor("x", "y")) { throw new PropertyListException("A point property dictionary is missing one or " + "both of the required fields (x or y)."); } return new Point( dictionary.IntegerFor("x").Value, dictionary.IntegerFor("y").Value ); }