public static void addItemToCurItemByString(string xmlStr, XmlItem curItem = null) { if (curItem == null) { curItem = XmlItem.getCurItem(); if (curItem == null) { return; } } XmlDocument newDoc = new XmlDocument(); XmlElement newXe = curItem.m_xe.OwnerDocument.CreateElement("tmp"); if (xmlStr != "") { newXe.InnerXml = xmlStr; if (newXe.FirstChild.NodeType == XmlNodeType.Element) { XmlItem treeChild; if(curItem is Basic) { treeChild = new BoloUI.Basic((XmlElement)newXe.FirstChild, curItem.m_xmlCtrl); } else if(curItem is ResBasic) { SkinDef_T skinDef; if(SkinDef_T.tryGetSkinDef(newXe.FirstChild.Name, out skinDef)) { treeChild = new BoloUI.ResBasic((XmlElement)newXe.FirstChild, curItem.m_xmlCtrl, skinDef); } else { return; } } else { return; } if (treeChild != null) { if (treeChild.m_xe.Name == "event") { curItem.m_xmlCtrl.m_openedFile.m_lstOpt.addOperation(new XmlOperation.HistoryNode( XmlOperation.XmlOptType.NODE_INSERT, treeChild.m_xe, curItem.m_xe, 0)); } else { curItem.m_xmlCtrl.m_openedFile.m_lstOpt.addOperation(new XmlOperation.HistoryNode( XmlOperation.XmlOptType.NODE_INSERT, treeChild.m_xe, curItem.m_xe, curItem.m_xe.ChildNodes.Count)); } } } } }
public void pasteItem() { XmlItem treeChild = null; XmlElement xeCopy; DataNode dataNodeCopy; XmlElement xeClip = null; string clipOutXml = Clipboard.GetText(); XmlDocument tmpDoc = new XmlDocument(); try { tmpDoc.LoadXml(clipOutXml); xeClip = tmpDoc.DocumentElement; } catch { xeClip = null; } if (xeClip != null) { xeCopy = m_xe.OwnerDocument.CreateElement("tmp"); xeCopy.InnerXml = xeClip.OuterXml; xeCopy = (XmlElement)xeCopy.FirstChild; if (DataNodeGroup.tryGetDataNode(m_xe.OwnerDocument.DocumentElement.Name, xeClip.Name, out dataNodeCopy)) { switch (dataNodeCopy.GetType().ToString()) { case "UIEditor.BoloUI.DefConfig.CtrlDef_T": { treeChild = new BoloUI.Basic(xeCopy, m_xmlCtrl); } break; case "UIEditor.BoloUI.DefConfig.SkinDef_T": { treeChild = new BoloUI.ResBasic(xeCopy, m_xmlCtrl, (SkinDef_T)dataNodeCopy); } break; default: { } break; } } if (treeChild != null) { DataNode dataNode; DataNode dataNodeParent; if (DataNodeGroup.tryGetDataNode(m_xe.OwnerDocument.DocumentElement.Name, m_xe.Name, out dataNode) && dataNode != null) { if(dataNode.m_hlstChildNode.Contains(xeCopy.Name)) { m_xmlCtrl.m_openedFile.m_lstOpt.addOperation(new XmlOperation.HistoryNode( XmlOperation.XmlOptType.NODE_INSERT, treeChild.m_xe, m_xe, m_xe.ChildNodes.Count)); } else { if (m_xe.ParentNode != null && DataNodeGroup.tryGetDataNode(m_xe.OwnerDocument.DocumentElement.Name, m_xe.ParentNode.Name, out dataNodeParent)) { if (dataNodeParent.m_hlstChildNode.Contains(xeCopy.Name)) { m_xmlCtrl.m_openedFile.m_lstOpt.addOperation(new XmlOperation.HistoryNode(XmlOperation.XmlOptType.NODE_INSERT, treeChild.m_xe, (XmlElement)m_xe.ParentNode, XmlOperation.HistoryNode.getXeIndex(m_xe) + 1)); } } } } } } }