예제 #1
0
        private void LoadTable(XmlNode node, Base parent)
        {
            TableObject table = ComponentsFactory.CreateTableObject(node.Name, parent);

            AddLocalizationItemsAttributes(node);
            LoadComponent(node, table);
            LoadSize(node, table);
            LoadBorder(node, table.Border);
            ApplyStyle(node, table);
            TableInfo tableInfo = new TableInfo();
            XmlNode   rowsNode  = FindChildNoteByName(node, "Rows");

            int columnsCount = 0;

            foreach (XmlNode row in rowsNode.ChildNodes)
            {
                XmlNode cells = FindChildNoteByName(row, "Cells");

                if (columnsCount < cells.ChildNodes.Count)
                {
                    columnsCount = cells.ChildNodes.Count;

                    foreach (XmlNode cell in cells.ChildNodes)
                    {
                        AddLocalizationItemsAttributes(cell);
                        tableInfo.Column.Add(UnitsConverter.SizeFToPixels(GetAttribute(cell, "Weight")));
                    }
                }
            }

            foreach (XmlNode row in rowsNode)
            {
                AddLocalizationItemsAttributes(row);
                tableInfo.Row.Add(UnitsConverter.SizeFToPixels(GetAttribute(row, "Weight")));
            }

            for (int i = 0; i < columnsCount; i++)
            {
                TableColumn column = new TableColumn();
                column.Width = GetRowColumnSize(tableInfo.Column, i, table.Width);
                table.Columns.Add(column);
                column.CreateUniqueName();
            }

            for (int i = 0; i < rowsNode.ChildNodes.Count; i++)
            {
                XmlNode rowNode = rowsNode.ChildNodes[i];

                TableRow row = new TableRow();
                row.Name   = GetAttribute(rowNode, "Name");
                row.Height = GetRowColumnSize(tableInfo.Row, i, table.Height);
                XmlNode cells = FindChildNoteByName(rowNode, "Cells");

                for (int j = 0; j < cells.ChildNodes.Count; j++)
                {
                    XmlNode   cellNode = cells.ChildNodes[j];
                    TableCell cell     = new TableCell();
                    LoadTableCell(cellNode, cell);
                    if (j == cells.ChildNodes.Count - 1 && cells.ChildNodes.Count < columnsCount)
                    {
                        cell.ColSpan = columnsCount - cells.ChildNodes.Count + 1;
                    }
                    row.AddChild(cell);
                }
                table.Rows.Add(row);
            }
        }
        private void LoadTable(string name, Base parent)
        {
            string      description = GetObjectDescription(name);
            TableObject table       = ComponentsFactory.CreateTableObject(name, parent);

            LoadComponent(description, table);
            LoadSize(description, table);
            LoadBorder(description, table.Border);
            table.Style = GetPropertyValue("StyleName", description).Replace("\"", "");
            List <string> rowNames = GetChildNames(DEV_EXPRESS_TABLE_ROW, description);

            TableInfo tableInfo = new TableInfo();

            // Create table columns.
            int columnsCount = 0;

            foreach (string rowName in rowNames)
            {
                string        rowDescription = GetObjectDescription(rowName);
                List <string> cellNames      = GetChildNames(DEV_EXPRESS_TABLE_CELL, rowDescription);

                if (columnsCount < cellNames.Count)
                {
                    columnsCount = cellNames.Count;
                    tableInfo.Column.Clear();
                    foreach (string cellName in cellNames)
                    {
                        tableInfo.Column.Add(GetWeight(cellName));
                    }
                }
            }

            for (int i = 0; i < rowNames.Count; i++)
            {
                tableInfo.Row.Add(GetWeight(rowNames[i]));
            }

            for (int i = 0; i < columnsCount; i++)
            {
                TableColumn column = new TableColumn();

                column.Width = GetRowColumnSize(tableInfo.Column, i, table.Width);
                table.Columns.Add(column);
                column.CreateUniqueName();
            }

            // Create table rows.
            for (int i = 0; i < rowNames.Count; i++)
            {
                TableRow row = new TableRow();
                row.Name = rowNames[i];
                string rowDescription = GetObjectDescription(row.Name);

                row.Height = GetRowColumnSize(tableInfo.Row, i, table.Height);
                List <string> cellNames = GetChildNames(DEV_EXPRESS_TABLE_CELL, rowDescription);

                // Create table cell.
                foreach (string cellName in cellNames)
                {
                    TableCell cell = new TableCell();
                    cell.Name = cellName;
                    LoadTableCell(cellName, cell);
                    row.AddChild(cell);
                }
                table.Rows.Add(row);
            }
        }
예제 #3
0
        private void LoadTable(XmlNode tableNode)
        {
            if (parent is TableCell)
            {
                if (curBand != null)
                {
                    parent = curBand;
                }
                else
                {
                    return;
                }
            }
            component = ComponentsFactory.CreateTableObject(tableNode.Attributes["Name"].Value, parent);
            XmlNodeList nodeList = tableNode.ChildNodes;

            LoadReportItem(nodeList);
            XmlNode tableColumnsNode = null;
            XmlNode headerNode       = null;
            XmlNode detailsNode      = null;
            XmlNode footerNode       = null;

            XmlNode tableRowsNode = null;

            foreach (XmlNode node in nodeList)
            {
                if (node.Name == "TableColumns")
                {
                    tableColumnsNode = node.Clone();
                }
                else if (node.Name == "Header")
                {
                    headerNode = node.Clone();
                }
                else if (node.Name == "Details")
                {
                    detailsNode = node.Clone();
                }
                else if (node.Name == "Footer")
                {
                    footerNode = node.Clone();
                }
                else if (node.Name == "TablixBody")
                {
                    if (node.HasChildNodes)
                    {
                        foreach (XmlNode bodyChild in node.ChildNodes)
                        {
                            if (bodyChild.Name == "TablixColumns")
                            {
                                tableColumnsNode = bodyChild.Clone();
                            }
                            else if (bodyChild.Name == "TablixRows")
                            {
                                tableRowsNode = node.Clone();
                            }
                        }
                    }
                }
            }
            LoadTableColumns(tableColumnsNode);
            LoadHeader(headerNode != null ? headerNode : tableRowsNode);
            LoadDetails(detailsNode);
            LoadFooter(footerNode);
            (component as TableObject).CreateUniqueNames();
        }