/// <summary> /// 创建控件 /// </summary> /// <param name="node">节点</param> /// <param name="control">控件</param> protected virtual void createTableLayoutSubProperty(XmlNode node, FCTableLayoutDiv tableLayoutDiv) { setAttributesBefore(node, tableLayoutDiv); foreach (XmlNode node2 in node.ChildNodes) { String nodeName2 = node2.Name.ToLower(); if (nodeName2 == "columnstyles") { foreach (XmlNode node3 in node2.ChildNodes) { String nodeName3 = node3.Name.ToLower(); if (nodeName3 == "columnstyle") { FCColumnStyle column = new FCColumnStyle(FCSizeType.PercentSize, 0.0f); tableLayoutDiv.ColumnStyles.add(column); HashMap <String, String> dic = getAttributes(node3); foreach (String str in dic.Keys) { column.setProperty(str, dic.get(str)); } } } } else if (nodeName2 == "rowstyles") { foreach (XmlNode node3 in node2.ChildNodes) { String nodeName3 = node3.Name.ToLower(); if (nodeName3 == "rowstyle") { FCRowStyle row = new FCRowStyle(FCSizeType.PercentSize, 0.0f); tableLayoutDiv.RowStyles.add(row); HashMap <String, String> dic = getAttributes(node3); foreach (String str in dic.Keys) { row.setProperty(str, dic.get(str)); } } } } else if (nodeName2 == "childs") { //读取子节点 readChildNodes(node2, tableLayoutDiv); } } setAttributesAfter(node, tableLayoutDiv); tableLayoutDiv.update(); onAddControl(tableLayoutDiv, node); }
/// <summary> /// 表格布局控件的模板 /// </summary> /// <param name="tableLayoutDiv">表格布局控件</param> /// <param name="xml">XML</param> /// <param name="node">节点</param> public static void TableLayoutDivTemplate(FCTableLayoutDiv tableLayoutDiv, UIXmlEx xml, XmlNode node) { XmlDocument xmlDoc = node.OwnerDocument; tableLayoutDiv.Size = new FCSize(200, 200); tableLayoutDiv.ColumnsCount = 2; tableLayoutDiv.RowsCount = 2; tableLayoutDiv.ColumnStyles.Add(new FCColumnStyle(FCSizeType.PercentSize, 0.5f)); tableLayoutDiv.ColumnStyles.Add(new FCColumnStyle(FCSizeType.PercentSize, 0.5f)); tableLayoutDiv.RowStyles.Add(new FCRowStyle(FCSizeType.PercentSize, 0.5f)); tableLayoutDiv.RowStyles.Add(new FCRowStyle(FCSizeType.PercentSize, 0.5f)); XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("columnscount"); xmlAtr1.Value = "2"; node.Attributes.Append(xmlAtr1); XmlAttribute xmlAtr2 = xmlDoc.CreateAttribute("rowscount"); xmlAtr2.Value = "2"; node.Attributes.Append(xmlAtr2); XmlNode columnsStylesNode = xmlDoc.CreateNode(XmlNodeType.Element, "columnstyles", ""); node.AppendChild(columnsStylesNode); XmlNode columnStyleNode1 = xmlDoc.CreateNode(XmlNodeType.Element, "columnstyle", ""); columnsStylesNode.AppendChild(columnStyleNode1); XmlAttribute columnStyleNodeAtr1 = xmlDoc.CreateAttribute("sizetype"); columnStyleNodeAtr1.Value = "percentsize"; columnStyleNode1.Attributes.Append(columnStyleNodeAtr1); XmlAttribute columnStyleNodeAtr2 = xmlDoc.CreateAttribute("width"); columnStyleNodeAtr2.Value = "0.5"; columnStyleNode1.Attributes.Append(columnStyleNodeAtr2); XmlNode columnStyleNode2 = xmlDoc.CreateNode(XmlNodeType.Element, "columnstyle", ""); columnsStylesNode.AppendChild(columnStyleNode2); XmlAttribute columnStyleNodeAtr3 = xmlDoc.CreateAttribute("sizetype"); columnStyleNodeAtr3.Value = "percentsize"; columnStyleNode2.Attributes.Append(columnStyleNodeAtr3); XmlAttribute columnStyleNodeAtr4 = xmlDoc.CreateAttribute("width"); columnStyleNodeAtr4.Value = "0.5"; columnStyleNode2.Attributes.Append(columnStyleNodeAtr4); XmlNode rowsStylesNode = xmlDoc.CreateNode(XmlNodeType.Element, "rowstyles", ""); node.AppendChild(rowsStylesNode); XmlNode rowStyleNode1 = xmlDoc.CreateNode(XmlNodeType.Element, "rowstyle", ""); rowsStylesNode.AppendChild(rowStyleNode1); XmlAttribute rowStyleNodeAtr1 = xmlDoc.CreateAttribute("sizetype"); rowStyleNodeAtr1.Value = "percentsize"; rowStyleNode1.Attributes.Append(rowStyleNodeAtr1); XmlAttribute rowStyleNodeAtr2 = xmlDoc.CreateAttribute("height"); rowStyleNodeAtr2.Value = "0.5"; rowStyleNode1.Attributes.Append(rowStyleNodeAtr2); XmlNode rowStyleNode2 = xmlDoc.CreateNode(XmlNodeType.Element, "rowstyle", ""); rowsStylesNode.AppendChild(rowStyleNode2); XmlAttribute rowStyleNodeAtr3 = xmlDoc.CreateAttribute("sizetype"); rowStyleNodeAtr3.Value = "percentsize"; rowStyleNode2.Attributes.Append(rowStyleNodeAtr3); XmlAttribute rowStyleNodeAtr4 = xmlDoc.CreateAttribute("height"); rowStyleNodeAtr4.Value = "0.5"; rowStyleNode2.Attributes.Append(rowStyleNodeAtr4); XmlNode childsNodes = xmlDoc.CreateNode(XmlNodeType.Element, "childs", ""); node.AppendChild(childsNodes); FCDiv div1 = new FCDiv(); div1.Name = CreateControlName(div1, xml); div1.Size = new FCSize(50, 50); tableLayoutDiv.addControl(div1); XmlNode div1Node = xmlDoc.CreateNode(XmlNodeType.Element, "div", ""); childsNodes.AppendChild(div1Node); XmlAttribute divAtr1 = xmlDoc.CreateAttribute("name"); divAtr1.Value = div1.Name; div1Node.Attributes.Append(divAtr1); xml.m_controls.Add(div1); xml.Nodes[div1] = div1Node; FCDiv div2 = new FCDiv(); div2.Name = CreateControlName(div2, xml); div2.Size = new FCSize(50, 50); tableLayoutDiv.addControl(div2); XmlNode div2Node = xmlDoc.CreateNode(XmlNodeType.Element, "div", ""); childsNodes.AppendChild(div2Node); XmlAttribute divAtr2 = xmlDoc.CreateAttribute("name"); divAtr2.Value = div2.Name; div2Node.Attributes.Append(divAtr2); xml.m_controls.Add(div2); xml.Nodes[div2] = div2Node; FCDiv div3 = new FCDiv(); div3.Name = CreateControlName(div3, xml); div3.Size = new FCSize(50, 50); tableLayoutDiv.addControl(div3); XmlNode div3Node = xmlDoc.CreateNode(XmlNodeType.Element, "div", ""); childsNodes.AppendChild(div3Node); XmlAttribute divAtr3 = xmlDoc.CreateAttribute("name"); divAtr3.Value = div3.Name; div3Node.Attributes.Append(divAtr3); xml.m_controls.Add(div3); xml.Nodes[div3] = div2Node; FCDiv div4 = new FCDiv(); div4.Name = CreateControlName(div4, xml); div4.Size = new FCSize(50, 59); tableLayoutDiv.addControl(div4); XmlNode div4Node = xmlDoc.CreateNode(XmlNodeType.Element, "div", ""); childsNodes.AppendChild(div4Node); XmlAttribute divAtr4 = xmlDoc.CreateAttribute("name"); divAtr4.Value = div4.Name; div4Node.Attributes.Append(divAtr4); xml.m_controls.Add(div4); xml.Nodes[div4] = div4Node; tableLayoutDiv.update(); }