GetXmlResValue() public static method

public static GetXmlResValue ( XmlElement Xml, string TagName, string Attribute = "Value" ) : string
Xml System.Xml.XmlElement
TagName string
Attribute string
return string
Beispiel #1
0
        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])
                       ));
        }
Beispiel #2
0
        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])
                       ));
        }
Beispiel #3
0
        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])
                       ));
        }