/// <summary> /// 加载树的模板 /// </summary> /// <param name="tree">树</param> /// <param name="node">节点</param> public static void TreeTemplate(FCTree tree, UIXmlEx xml, XmlNode node) { XmlDocument xmlDoc = node.OwnerDocument; tree.Size = new FCSize(200, 200); FCGridColumn column = new FCGridColumn("Column1"); column.AllowSort = false; tree.addColumn(column); FCGridColumn column2 = new FCGridColumn("Column2"); column2.AllowSort = false; tree.addColumn(column2); tree.update(); FCTreeNode treeNode = new FCTreeNode(); treeNode.Text = "Node1"; tree.appendNode(treeNode); FCTreeNode subTreeNode = new FCTreeNode(); subTreeNode.Text = "Node2"; treeNode.appendNode(subTreeNode); tree.update(); XmlNode columnsNode = xmlDoc.CreateNode(XmlNodeType.Element, "tr", ""); node.AppendChild(columnsNode); XmlNode column1Node = xmlDoc.CreateNode(XmlNodeType.Element, "th", ""); columnsNode.AppendChild(column1Node); XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("text"); xmlAtr1.Value = "Column1"; column1Node.Attributes.Append(xmlAtr1); XmlNode column2Node = xmlDoc.CreateNode(XmlNodeType.Element, "th", ""); columnsNode.AppendChild(column2Node); XmlAttribute xmlAtr2 = xmlDoc.CreateAttribute("text"); xmlAtr2.Value = "Column2"; column2Node.Attributes.Append(xmlAtr2); XmlNode nodesNode = xmlDoc.CreateNode(XmlNodeType.Element, "nodes", ""); node.AppendChild(nodesNode); XmlNode nodeNode = xmlDoc.CreateNode(XmlNodeType.Element, "node", ""); nodesNode.AppendChild(nodeNode); XmlAttribute xmlAtr3 = xmlDoc.CreateAttribute("text"); xmlAtr3.Value = "Node1"; nodeNode.Attributes.Append(xmlAtr3); XmlNode subNodeNode = xmlDoc.CreateNode(XmlNodeType.Element, "node", ""); nodeNode.AppendChild(subNodeNode); XmlAttribute xmlAtr4 = xmlDoc.CreateAttribute("text"); xmlAtr4.Value = "Node2"; subNodeNode.Attributes.Append(xmlAtr4); }
/// <summary> /// 添加类 /// </summary> public void addClass() { XmlDocument xmlDoc = m_xml.XmlDoc; if (m_collectionName == "TabPages") { FCTabControl tabControl = m_target as FCTabControl; FCTabPage tabPage = new FCTabPage(); tabControl.addControl(tabPage); String newControlName = UITemplate.CreateControlName(tabPage, m_xml); tabPage.Name = newControlName; tabPage.Text = newControlName; XmlNode tabControlNode = m_xml.Nodes[tabControl]; XmlNode tabpageNode = m_xml.XmlDoc.CreateNode(XmlNodeType.Element, "div", ""); tabControlNode.AppendChild(tabpageNode); XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("name"); xmlAtr1.Value = tabPage.Text; tabpageNode.Attributes.Append(xmlAtr1); XmlAttribute xmlAtr2 = xmlDoc.CreateAttribute("text"); xmlAtr2.Value = tabPage.Text; tabpageNode.Attributes.Append(xmlAtr2); XmlAttribute xmlAtr3 = xmlDoc.CreateAttribute("type"); xmlAtr3.Value = "tabpage"; tabpageNode.Attributes.Append(xmlAtr3); m_xml.m_controls.Add(tabPage); m_xml.Nodes[tabPage] = tabpageNode; FCTreeNode node = new FCTreeNode(); node.setString(tabPage.Name); m_tvCollection.appendNode(node); node.Row.Tag = tabPage; m_tvCollection.update(); m_tvCollection.selectNextRow(); tabControl.update(); } else if (m_collectionName == "Columns") { FCGrid grid = m_target as FCGrid; FCGridColumn column = new FCGridColumn(); grid.addColumn(column); String newControlName = UITemplate.CreateControlName(column, m_xml); column.Name = newControlName; column.Text = newControlName; XmlNode gridNode = m_xml.Nodes[grid]; XmlNode columnsNode = null; foreach (XmlNode subNode in gridNode.ChildNodes) { if (subNode.Name.ToLower() == "columns" || subNode.Name.ToLower() == "tr") { columnsNode = subNode; break; } } if (columnsNode == null) { columnsNode = xmlDoc.CreateNode(XmlNodeType.Element, "tr", ""); gridNode.AppendChild(columnsNode); } XmlNode columnNode = m_xml.XmlDoc.CreateNode(XmlNodeType.Element, "th", ""); columnNode.InnerText = column.Text; columnsNode.AppendChild(columnNode); XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("name"); xmlAtr1.Value = column.Text; columnNode.Attributes.Append(xmlAtr1); m_xml.m_controls.Add(column); m_xml.Nodes[column] = columnNode; FCTreeNode node = new FCTreeNode(); node.setString(column.Name); m_tvCollection.appendNode(node); node.Row.Tag = column; grid.update(); } m_tvCollection.update(); m_tvCollection.selectNextRow(); Native.invalidate(); m_designerDiv.saveUndo(); }