/// <summary> /// 它返回具有给定XML ID的svgelement。 /// </summary> public SVGUnit GetSvgElement(string sId) { SVGUnit eleToReturn = null; IDictionaryEnumerator e = m_elements.GetEnumerator(); bool bLoop = e.MoveNext(); while (bLoop) { string sValue = ""; SVGUnit ele = (SVGUnit)e.Value; sValue = ele.GetAttributeStringValue(SVGAttribute._SvgAttribute.attrCore_Id); if (sValue == sId) { eleToReturn = ele; bLoop = false; } bLoop = e.MoveNext(); } return(eleToReturn); }
/// <summary> /// 它创建了一个新的元素,从eletoclone复制所有属性;新的 /// 元素插入到提供的父元素下。 /// </summary> public SVGUnit CloneElement(SVGUnit parent, SVGUnit eleToClone, SVGUnit last) { string sOldId = eleToClone.GetAttributeStringValue(SVGAttribute._SvgAttribute.attrCore_Id); string sNewId = sOldId; if (sOldId != "") { int i = 1; while (GetSvgElement(sNewId) != null) { sNewId = sOldId + "_" + i.ToString(); i++; } } SVGUnit eleNew = AddElement(parent, eleToClone.getElementName(), ref last); eleNew.CloneAttributeList(eleToClone); if (sNewId != "") { eleNew.SetAttributeValue(SVGAttribute._SvgAttribute.attrCore_Id, sNewId); } if (eleToClone.getChild() != null) { eleNew.setChild(CloneElement(eleNew, eleToClone.getChild(), last)); if (eleToClone.getChild().getNext() != null) { eleNew.getChild().setNext(CloneElement(eleNew, eleToClone.getChild().getNext(), last)); } } return(eleNew); }