/// <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> /// <param name="node">节点</param> /// <param name="control">控件</param> protected virtual void createTabPage(XmlNode node, FCView control) { FCTabControl tabControl = control as FCTabControl; if (tabControl != null) { FCTabPage tabPage = new FCTabPage(); tabPage.Native = m_native; tabControl.addControl(tabPage); setAttributesBefore(node, tabPage); readChildNodes(node, tabPage); setAttributesAfter(node, tabPage); onAddControl(tabPage, node); } }
/// <summary> /// 添加控件方法 /// </summary> public override void onLoad() { base.onLoad(); if (m_tabControl != null) { if (m_headerButton == null) { FCHost host = Native.Host; m_headerButton = host.createInternalControl(this, "headerbutton") as FCButton; m_headerButton.addEvent(m_dragHeaderBeginEvent, FCEventID.DRAGBEGIN); m_headerButton.addEvent(m_dragHeaderEndEvent, FCEventID.DRAGEND); m_headerButton.addEvent(m_draggingHeaderEvent, FCEventID.DRAGGING); m_headerButton.addEvent(m_headerTouchDownEvent, FCEventID.TOUCHDOWN); } if (!m_tabControl.containsControl(m_headerButton)) { m_tabControl.addControl(m_headerButton); } } }
/// <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(); }