/// <summary> /// 多页夹控件的模板 /// </summary> /// <param name="tabControl">多页夹控件</param> /// <param name="node">节点</param> public static void TabControlTemplate(FCTabControl tabControl, UIXmlEx xml, XmlNode node) { XmlDocument xmlDoc = node.OwnerDocument; tabControl.Size = new FCSize(200, 200); FCTabPage tabPage = new FCTabPage(); tabControl.addControl(tabPage); tabPage.Name = CreateControlName(tabPage, xml); tabPage.Text = tabPage.Name; XmlNode tabPageNode = xmlDoc.CreateNode(XmlNodeType.Element, "div", ""); node.AppendChild(tabPageNode); XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("name"); xmlAtr1.Value = tabPage.Name; tabPageNode.Attributes.Append(xmlAtr1); XmlAttribute xmlAtr2 = xmlDoc.CreateAttribute("text"); xmlAtr2.Value = tabPage.Name; tabPageNode.Attributes.Append(xmlAtr2); XmlAttribute xmlAtr3 = xmlDoc.CreateAttribute("type"); xmlAtr3.Value = "tabpage"; tabPageNode.Attributes.Append(xmlAtr3); xml.m_controls.Add(tabPage); xml.Nodes[tabPage] = tabPageNode; tabControl.update(); }
/// <summary> /// 删除类 /// </summary> public void deleteClass() { List <FCGridRow> selectedRows = m_tvCollection.SelectedRows; int selectedRowsSize = selectedRows.Count; if (selectedRowsSize > 0) { if (m_collectionName == "TabPages") { FCTabControl tabControl = m_target as FCTabControl; FCTabPage tabPage = selectedRows[0].Tag as FCTabPage; m_xml.removeControl(tabPage); m_tvCollection.removeRow(selectedRows[0]); m_tvCollection.update(); tabControl.update(); } else if (m_collectionName == "Columns") { FCGrid grid = m_target as FCGrid; FCGridColumn column = selectedRows[0].Tag as FCGridColumn; grid.removeColumn(column); m_xml.m_controls.Remove(column); m_xml.Nodes[column].ParentNode.RemoveChild(m_xml.Nodes[column]); m_xml.Nodes.Remove(column); m_tvCollection.removeRow(selectedRows[0]); m_tvCollection.update(); grid.update(); } Native.invalidate(); m_designerDiv.saveUndo(); } }
/// <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(); }