/// <summary> /// 比较对象数据是否一致 /// </summary> /// <param name="b">另一个ZYTextBorder 对象</param> /// <returns>两者设置是否一样</returns> public bool EqualBorder(ZYTextBorder b) { //ZYTextBorder b = obj as ZYTextBorder ; if (this == b) { return(true); } if (b != null) { return( // width leftWidth == b.leftWidth && topWidth == b.topWidth && rightWidth == b.rightWidth && bottomWidth == b.bottomWidth // style && leftStyle.Equals(b.leftStyle) && topStyle.Equals(b.topStyle) && rightStyle.Equals(b.rightStyle) && bottomStyle.Equals(b.bottomStyle) // color && leftColor.Equals(b.leftColor) && topColor.Equals(b.topColor) && rightColor.Equals(b.rightColor) && bottomColor.Equals(b.bottomColor) && hasBackGround == b.hasBackGround && backColor == b.backColor ); } else { return(false); } }
/// <summary> /// 复制对象 /// </summary> /// <returns>复制品</returns> public ZYTextBorder Clone() { ZYTextBorder b = new ZYTextBorder(); b.CopyFrom(this); return(b); }
/// <summary> /// 从其他的边框样式对象拷贝数据 /// </summary> /// <param name="b">数据来源的边框样式对象</param> public void CopyFrom(ZYTextBorder b) { if (b != null) { leftColor = b.leftColor; leftStyle = b.leftStyle; leftWidth = b.leftWidth; topColor = b.topColor; topStyle = b.topStyle; topWidth = b.topWidth; rightColor = b.rightColor; rightStyle = b.rightStyle; rightWidth = b.rightWidth; bottomColor = b.bottomColor; bottomStyle = b.bottomStyle; bottomWidth = b.bottomWidth; } }
/// <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); }