Exemple #1
0
        /// <summary>
        /// 向XML节点加载对象数据,该函数不会重置所有的数据
        /// </summary>
        /// <param name="myElement">XML节点对象</param>
        /// <returns>加载是否成功</returns>
        public bool FromXMLWithoutClear(System.Xml.XmlElement myElement)
        {
            if (myElement != null)
            {
                // all
                if (myElement.HasAttribute(c_Border_Color))
                {
                    this.BorderColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_Border_Color), DefaultColor);
                }
                if (myElement.HasAttribute(c_Border_Width))
                {
                    this.BorderWidth = StringCommon.ToInt32Value(myElement.GetAttribute(c_Border_Width), DefaultWidth);
                }
                if (myElement.HasAttribute(c_Border_Style))
                {
                    this.BorderStyle = ToBorderStyle(myElement.GetAttribute(c_Border_Style));
                }

                // left
                if (myElement.HasAttribute(c_Border_Left_Color))
                {
                    leftColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_Border_Left_Color), DefaultColor);
                }
                if (myElement.HasAttribute(c_Border_Left_Width))
                {
                    leftWidth = StringCommon.ToInt32Value(myElement.GetAttribute(c_Border_Left_Width), DefaultWidth);
                }
                if (myElement.HasAttribute(c_Border_Left_Style))
                {
                    leftStyle = ToBorderStyle(myElement.GetAttribute(c_Border_Left_Style));
                }

                // top
                if (myElement.HasAttribute(c_Border_Top_Color))
                {
                    topColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_Border_Top_Color), DefaultColor);
                }
                if (myElement.HasAttribute(c_Border_Top_Width))
                {
                    topWidth = StringCommon.ToInt32Value(myElement.GetAttribute(c_Border_Top_Width), DefaultWidth);
                }
                if (myElement.HasAttribute(c_Border_Top_Style))
                {
                    topStyle = ToBorderStyle(myElement.GetAttribute(c_Border_Top_Style));
                }

                // right
                if (myElement.HasAttribute(c_Border_Right_Color))
                {
                    rightColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_Border_Right_Color), DefaultColor);
                }
                if (myElement.HasAttribute(c_Border_Right_Width))
                {
                    rightWidth = StringCommon.ToInt32Value(myElement.GetAttribute(c_Border_Right_Width), DefaultWidth);
                }
                if (myElement.HasAttribute(c_Border_Right_Style))
                {
                    rightStyle = ToBorderStyle(myElement.GetAttribute(c_Border_Right_Style));
                }

                // bottom
                if (myElement.HasAttribute(c_Border_Bottom_Color))
                {
                    bottomColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_Border_Bottom_Color), DefaultColor);
                }
                if (myElement.HasAttribute(c_Border_Bottom_Width))
                {
                    bottomWidth = StringCommon.ToInt32Value(myElement.GetAttribute(c_Border_Bottom_Width), DefaultWidth);
                }
                if (myElement.HasAttribute(c_Border_Bottom_Style))
                {
                    bottomStyle = ToBorderStyle(myElement.GetAttribute(c_Border_Bottom_Style));
                }

                // 背景色
                hasBackGround = myElement.HasAttribute(c_BackGround_Color);
                if (hasBackGround)
                {
                    backColor = StringCommon.ColorFromHtml(myElement.GetAttribute(c_BackGround_Color), DefaultBackColor);
                }
                else
                {
                    backColor = DefaultBackColor;
                }
                return(true);
            }
            return(false);
        }