Ejemplo n.º 1
0
        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);
        }