public static PointF XmlElementToPointF(XmlElement Node, string NodeName, string Attribute = "Value") { string[] tRectArr = Helper.GetXmlResValue(Node, NodeName, Attribute).Split(','); if (tRectArr.Length != 2) { throw new Exception("'" + NodeName + "'属性格式不正确: 请确保为'x,y'."); } return(new PointF( Convert.ToSingle(tRectArr[0]), Convert.ToSingle(tRectArr[1]) )); }
public static RectangleF XmlElementToRectangleF(XmlElement Node, string NodeName, string Attribute = "Value") { string[] tRectArr = Helper.GetXmlResValue(Node, NodeName, Attribute).Split(','); if (tRectArr.Length != 4) { throw new Exception("'" + NodeName + "'属性格式不正确: 请确保为'x1,y1,x2,y2'."); } return(new RectangleF( Convert.ToSingle(tRectArr[0]), Convert.ToSingle(tRectArr[1]), Convert.ToSingle(tRectArr[2]) - Convert.ToSingle(tRectArr[0]), Convert.ToSingle(tRectArr[3]) - Convert.ToSingle(tRectArr[1]) )); }
public static Color XmlElementToColor(XmlElement Node, string NodeName, string Attribute = "Value") { string[] tRectArr = Helper.GetXmlResValue(Node, NodeName, Attribute).Split(','); if (tRectArr.Length != 4) { throw new Exception("'" + NodeName + "'属性格式不正确: 请确保为'a,r,g,b'."); } return(Color.FromArgb( Convert.ToInt32(tRectArr[0]), Convert.ToInt32(tRectArr[1]), Convert.ToInt32(tRectArr[2]), Convert.ToInt32(tRectArr[3]) )); }