public virtual void CreateFromTemplate(XElement node, Hashtable boundFields) { XAttribute styleAttr = node.Attribute("style"); if (styleAttr != null) { style.LoadFromString(styleAttr.Value); } }
public override void CreateFromTemplate(XElement node, Hashtable boundFields) { XAttribute tempAttr = node.Attribute("style"); if (tempAttr != null) { style.LoadFromString(tempAttr.Value); itemStyle.LoadFromString(tempAttr.Value); } tempAttr = node.Attribute("font"); if (tempAttr != null) { itemFont.LoadFromString(tempAttr.Value); } TextBox tb; tempAttr = node.Attribute("text"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.Text = tempAttr.Value; tb.Style = (ObjectStyle)itemStyle.Clone(); tb.Font = (ObjectFont)itemFont.Clone(); itemTemplate.Clear(); itemTemplate.Add(tb); } tempAttr = node.Attribute("sourceField"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.SourceField = tempAttr.Value; if (boundFields [tempAttr.Value] != null) { tb.Text = boundFields [tempAttr.Value].ToString(); } tb.Style = (ObjectStyle)itemStyle.Clone(); tb.Font = (ObjectFont)itemFont.Clone(); itemTemplate.Clear(); itemTemplate.Add(tb); } foreach (XElement child in node.Elements()) { XAttribute styleAttr; switch (child.Name.LocalName.ToLowerInvariant()) { case "template": styleAttr = child.Attribute("style"); if (styleAttr != null) { itemStyle.LoadFromString(styleAttr.Value); } if (child.HasElements) { CreateChildrenFromTemplate(child, boundFields, ref itemTemplate); } break; case "header": styleAttr = child.Attribute("style"); if (styleAttr != null) { headerStyle.LoadFromString(styleAttr.Value); } tempAttr = node.Attribute("font"); if (tempAttr != null) { headerFont.LoadFromString(tempAttr.Value); } tempAttr = child.Attribute("text"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.Text = tempAttr.Value; tb.Style = (ObjectStyle)headerStyle.Clone(); tb.Font = (ObjectFont)headerFont.Clone(); headerTemplate.Clear(); headerTemplate.Add(tb); } tempAttr = child.Attribute("sourceField"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.SourceField = tempAttr.Value; tb.Text = boundFields [tempAttr.Value].ToString(); tb.Style = (ObjectStyle)headerStyle.Clone(); tb.Font = (ObjectFont)headerFont.Clone(); headerTemplate.Clear(); headerTemplate.Add(tb); } if (child.HasElements) { CreateChildrenFromTemplate(child, boundFields, ref headerTemplate); } break; case "footer": styleAttr = child.Attribute("style"); if (styleAttr != null) { footerStyle.LoadFromString(styleAttr.Value); } tempAttr = node.Attribute("font"); if (tempAttr != null) { footerFont.LoadFromString(tempAttr.Value); } tempAttr = child.Attribute("text"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.Text = tempAttr.Value; tb.Style = (ObjectStyle)footerStyle.Clone(); tb.Font = (ObjectFont)footerFont.Clone(); footerTemplate.Clear(); footerTemplate.Add(tb); } tempAttr = child.Attribute("sourceField"); if (tempAttr != null) { tb = DocumentHelper.FormObjectCreator.CreateTextBox(); tb.SourceField = tempAttr.Value; tb.Text = boundFields [tempAttr.Value].ToString(); tb.Style = (ObjectStyle)footerStyle.Clone(); tb.Font = (ObjectFont)footerFont.Clone(); footerTemplate.Clear(); footerTemplate.Add(tb); } if (child.HasElements) { CreateChildrenFromTemplate(child, boundFields, ref footerTemplate); } break; } } }
public override void CreateFromTemplate(XElement node, Hashtable boundFields) { XAttribute tempAttr = node.Attribute("sourceTable"); if (tempAttr != null) { sourceTable = tempAttr.Value; } base.CreateFromTemplate(node, boundFields); tempAttr = node.Attribute("headerStyle"); if (tempAttr != null) { headerStyle.LoadFromString(tempAttr.Value); } tempAttr = node.Attribute("itemStyle"); if (tempAttr != null) { ItemStyle.LoadFromString(tempAttr.Value); } tempAttr = node.Attribute("hasHeader"); if (tempAttr != null) { bool.TryParse(tempAttr.Value, out hasHeader); } tempAttr = node.Attribute("footerStyle"); if (tempAttr != null) { footerStyle.LoadFromString(tempAttr.Value); } tempAttr = node.Attribute("sourceTableHasFooter"); if (tempAttr != null) { bool.TryParse(tempAttr.Value, out sourceTableHasFooter); } tempAttr = node.Attribute("sourceTableHasFooterSource"); if (tempAttr != null) { sourceTableHasFooterSource = tempAttr.Value; if (boundFields.ContainsKey(sourceTableHasFooterSource)) { bool.TryParse(boundFields [sourceTableHasFooterSource].ToString(), out sourceTableHasFooter); } } foreach (XElement child in node.Elements()) { switch (child.Name.LocalName.ToLowerInvariant()) { case "columns": foreach (XElement column in child.Elements()) { TableColumn tableColumn; switch (column.Name.LocalName.ToLowerInvariant()) { case "column": tableColumn = new TableColumn(column, boundFields); break; default: continue; } columns.Add(tableColumn); } CreateHeader(boundFields); CreateFooter(boundFields); break; case "rows": if (sourceTable.Length == 0) { foreach (XElement row in child.Elements()) { TableRow tableRow; switch (row.Name.LocalName.ToLowerInvariant()) { case "row": tableRow = DocumentHelper.FormObjectCreator.CreateRow(row, boundFields); break; default: continue; } if (tableRow.Style.ToString(tableRow.DefaultStyle) == tableRow.DefaultStyle.ToString(tableRow.DefaultStyle)) { tableRow.Style = (ObjectStyle)itemStyle.Clone(); } rows.Add(tableRow); if (style.InnerVerticalBorder.HasValue) { tableRow.Style.InnerVerticalBorder = style.InnerVerticalBorder; } if (style.InnerHSpacing.HasValue) { tableRow.Style.InnerHSpacing = style.InnerHSpacing; } } } break; } } RefreshStructure(boundFields); }