Exemple #1
0
 /// <summary>
 /// 增量方式向XML节点,本函数只是向XML节点保存和另一个边框对象的不相同的参数设置
 /// 以减少保存的数据量
 /// </summary>
 /// <param name="myElement">XML节点</param>
 /// <param name="b">作为参照物的边框对象</param>
 /// <returns>保存是否成功</returns>
 public bool ToXMLEx(System.Xml.XmlElement myElement, ZYTextBorder b)
 {
     if (myElement != null && b != null && b != this)
     {
         // color
         if (leftColor.Equals(topColor) && topColor.Equals(rightColor) && rightColor.Equals(bottomColor))
         {
             if (leftColor.Equals(DefaultColor) == false && leftColor.Equals(b.leftColor) == false)
             {
                 myElement.SetAttribute(c_Border_Color, StringCommon.ColorToHtml(leftColor));
             }
         }
         else
         {
             if (!(leftColor.Equals(DefaultColor) || leftColor.Equals(b.leftColor)))
             {
                 myElement.SetAttribute(c_Border_Left_Color, StringCommon.ColorToHtml(leftColor));
             }
             if (!(topColor.Equals(DefaultColor) || topColor.Equals(b.topColor)))
             {
                 myElement.SetAttribute(c_Border_Top_Color, StringCommon.ColorToHtml(topColor));
             }
             if (!(rightColor.Equals(DefaultColor) || rightColor.Equals(b.rightColor)))
             {
                 myElement.SetAttribute(c_Border_Right_Color, StringCommon.ColorToHtml(rightColor));
             }
             if (!(bottomColor.Equals(DefaultColor) || bottomColor.Equals(b.bottomColor)))
             {
                 myElement.SetAttribute(c_Border_Bottom_Color, StringCommon.ColorToHtml(bottomColor));
             }
         }
         // width
         if (leftWidth == topWidth && topWidth == rightWidth && rightWidth == bottomWidth)
         {
             if (leftWidth != DefaultWidth && leftWidth != b.leftWidth)
             {
                 myElement.SetAttribute(c_Border_Width, leftWidth.ToString());
             }
         }
         else
         {
             if (leftWidth != DefaultWidth && leftWidth != b.leftWidth)
             {
                 myElement.SetAttribute(c_Border_Left_Width, leftWidth.ToString());
             }
             if (topWidth != DefaultWidth && topWidth != b.topWidth)
             {
                 myElement.SetAttribute(c_Border_Top_Width, topWidth.ToString());
             }
             if (rightWidth != DefaultWidth && rightWidth != b.rightWidth)
             {
                 myElement.SetAttribute(c_Border_Right_Width, rightWidth.ToString());
             }
             if (bottomWidth != DefaultWidth && bottomWidth != b.bottomWidth)
             {
                 myElement.SetAttribute(c_Border_Bottom_Width, bottomWidth.ToString());
             }
         }
         // style
         if (leftStyle == topStyle && topStyle == rightStyle && rightStyle == bottomStyle)
         {
             if (!leftStyle.Equals(DefaultStyle) && !leftStyle.Equals(b.leftStyle))
             {
                 myElement.SetAttribute(c_Border_Style, leftStyle.ToString().ToLower());
             }
         }
         else
         {
             if (leftStyle != DefaultStyle && leftStyle != b.leftStyle)
             {
                 myElement.SetAttribute(c_Border_Left_Style, leftStyle.ToString().ToLower());
             }
             if (topStyle != DefaultStyle && topStyle != b.topStyle)
             {
                 myElement.SetAttribute(c_Border_Top_Style, topStyle.ToString().ToLower());
             }
             if (rightStyle != DefaultStyle && rightStyle != b.rightStyle)
             {
                 myElement.SetAttribute(c_Border_Right_Style, rightStyle.ToString().ToLower());
             }
             if (bottomStyle != DefaultStyle && bottomStyle != b.bottomStyle)
             {
                 myElement.SetAttribute(c_Border_Bottom_Style, bottomStyle.ToString().ToLower());
             }
         }
         if (hasBackGround == true && hasBackGround != b.hasBackGround && backColor != b.backColor)
         {
             myElement.SetAttribute(c_BackGround_Color, StringCommon.ColorToHtml(backColor));
         }
         return(true);
     }
     return(false);
 }
Exemple #2
0
        /// <summary>
        /// 向XML节点保存对象数据
        /// </summary>
        /// <param name="myElement">XML节点对象</param>
        /// <returns>保存是否成功</returns>
        public bool ToXML(System.Xml.XmlElement myElement)
        {
            if (myElement != null)
            {
                // color
                if (leftColor.Equals(topColor) && topColor.Equals(rightColor) && rightColor.Equals(bottomColor))
                {
                    if (leftColor.Equals(DefaultColor) == false)
                    {
                        myElement.SetAttribute(c_Border_Color, StringCommon.ColorToHtml(leftColor));
                    }
                }
                else
                {
                    if (!leftColor.Equals(DefaultColor))
                    {
                        myElement.SetAttribute(c_Border_Left_Color, StringCommon.ColorToHtml(leftColor));
                    }
                    if (!topColor.Equals(DefaultColor))
                    {
                        myElement.SetAttribute(c_Border_Top_Color, StringCommon.ColorToHtml(topColor));
                    }
                    if (!rightColor.Equals(DefaultColor))
                    {
                        myElement.SetAttribute(c_Border_Right_Color, StringCommon.ColorToHtml(rightColor));
                    }
                    if (!bottomColor.Equals(DefaultColor))
                    {
                        myElement.SetAttribute(c_Border_Bottom_Color, StringCommon.ColorToHtml(bottomColor));
                    }
                }
                // width
                if (leftWidth == topWidth && topWidth == rightWidth && rightWidth == bottomWidth)
                {
                    if (leftWidth != DefaultWidth)
                    {
                        myElement.SetAttribute(c_Border_Width, leftWidth.ToString());
                    }
                }
                else
                {
                    if (leftWidth != DefaultWidth)
                    {
                        myElement.SetAttribute(c_Border_Left_Width, leftWidth.ToString());
                    }
                    if (topWidth != DefaultWidth)
                    {
                        myElement.SetAttribute(c_Border_Top_Width, topWidth.ToString());
                    }
                    if (rightWidth != DefaultWidth)
                    {
                        myElement.SetAttribute(c_Border_Right_Width, rightWidth.ToString());
                    }
                    if (bottomWidth != DefaultWidth)
                    {
                        myElement.SetAttribute(c_Border_Bottom_Width, bottomWidth.ToString());
                    }
                }
                // style
                if (leftStyle == topStyle && topStyle == rightStyle && rightStyle == bottomStyle)
                {
                    if (!leftStyle.Equals(DefaultStyle))
                    {
                        myElement.SetAttribute(c_Border_Style, leftStyle.ToString().ToLower());
                    }
                }
                else
                {
                    if (leftStyle != DefaultStyle)
                    {
                        myElement.SetAttribute(c_Border_Left_Style, leftStyle.ToString().ToLower());
                    }
                    if (topStyle != DefaultStyle)
                    {
                        myElement.SetAttribute(c_Border_Top_Style, topStyle.ToString().ToLower());
                    }
                    if (rightStyle != DefaultStyle)
                    {
                        myElement.SetAttribute(c_Border_Right_Style, rightStyle.ToString().ToLower());
                    }
                    if (bottomStyle != DefaultStyle)
                    {
                        myElement.SetAttribute(c_Border_Bottom_Style, bottomStyle.ToString().ToLower());
                    }
                }
                if (hasBackGround)
                {
                    myElement.SetAttribute(c_BackGround_Color, StringCommon.ColorToHtml(backColor));
                }

                return(true);
            }
            return(false);
        }