/// <summary> /// /// </summary> /// <param name="newList"></param> /// <param name="curList"></param> private void compareRefreshLists(RenderableObjectList newList, RenderableObjectList curList) { ArrayList addList = new ArrayList(); ArrayList delList = new ArrayList(); foreach (RenderableObject newObject in newList.ChildObjects) { bool foundObject = false; foreach (RenderableObject curObject in curList.ChildObjects) { string xmlSource = curObject.MetaData["XmlSource"] as string; if (xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name) { foundObject = true; updateRenderable(curObject, newObject); break; } } if (!foundObject) { addList.Add(newObject); } } foreach (RenderableObject curObject in curList.ChildObjects) { bool foundObject = false; foreach (RenderableObject newObject in newList.ChildObjects) { string xmlSource = newObject.MetaData["XmlSource"] as string; if (xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name) { foundObject = true; break; } } if (!foundObject) { string src = (string)curObject.MetaData["XmlSource"]; if (src != null || src == m_DataSource) { delList.Add(curObject); } } } foreach (RenderableObject o in addList) { curList.Add(o); } foreach (RenderableObject o in delList) { curList.Remove(o); } }
/// <summary> /// 添加一个子图层到这个图层列表。 /// Add a child object to this layer. /// </summary> public virtual void Add(RenderableObject ro) { lock (this.m_children.SyncRoot) { RenderableObjectList dupList = null; RenderableObject duplicate = null; ro.ParentList = this; foreach (RenderableObject childRo in m_children) { if (childRo is RenderableObjectList && childRo.Name == ro.Name) { dupList = (RenderableObjectList)childRo; break; } else if (childRo.Name == ro.Name) { duplicate = childRo; break; } } if (dupList != null) { RenderableObjectList rol = (RenderableObjectList)ro; foreach (RenderableObject childRo in rol.ChildObjects) { dupList.Add(childRo); } } else { if (duplicate != null) { for (int i = 1; i < 100; i++) {//TODO:ZYM-20130707发现,需要解决工具加载时图层列表中出现多个相同名称的问题 ro.Name = string.Format("{0} [{1}]", duplicate.Name, i); bool found = false; foreach (RenderableObject childRo in m_children) { if (childRo.Name == ro.Name) { found = true; break; } } if (!found) { break; } } } m_children.Add(ro); } SortChildren(); } }