示例#1
0
        public GridLayer(RenderElement owner, CellSizeStyle cellSizeStyle, GridTable gridTable)
            : base(owner)
        {
            this.cellSizeStyle = cellSizeStyle;
            this.gridTable     = gridTable;

            gridRows = gridTable.Rows;
            gridCols = gridTable.Columns;
            int columnWidth = owner.Width;

            int nColumns = gridTable.ColumnCount;

            if (nColumns > 0)
            {
                columnWidth      = columnWidth / nColumns;
                uniformCellWidth = columnWidth;
                if (columnWidth < 1)
                {
                    columnWidth = 1;
                }
            }

            //------------------------------------------------------------
            int cx = 0;

            for (int c = 0; c < nColumns; c++)
            {
                GridColumn col = gridCols.GetColumn(c);
                col.Width = columnWidth;
                col.Left  = cx;
                cx       += columnWidth;
            }
            //------------------------------------------------------------
            int nRows = gridTable.RowCount;

            if (nRows > 0)
            {
                int rowHeight = owner.Height / nRows;
                int cy        = 0;
                for (int r = 0; r < nRows; r++)
                {
                    GridRow row = gridRows.GetRow(r);
                    row.Height = rowHeight;
                    row.Top    = cy;
                    cy        += rowHeight;
                }
                uniformCellHeight = rowHeight;
            }
            //------------------------------------------------------------
        }
示例#2
0
        public void UpdateParentLink(GridViewRenderBox gridViewRenderE)
        {
            int rowCount = _gridRows.Count;
            int colCount = _gridCols.Count;

            for (int c = 0; c < colCount; ++c)
            {
                GridColumn col = _gridCols.GetColumn(c);
                for (int r = 0; r < rowCount; ++r)
                {
                    GridCell      gridCell       = col.GetCell(r);
                    RenderElement contentRenderE = col.GetCell(r).ContentElement;

#if DEBUG
                    if (contentRenderE.MyParentLink != null)
                    {
                        throw new NotSupportedException();
                    }
#endif
                    RenderElement.SetParentLink(contentRenderE, gridViewRenderE);
                }
            }
        }
示例#3
0
        public GridLayer(int width, int height, CellSizeStyle cellSizeStyle, GridTable gridTable)
        {
            _cellSizeStyle = cellSizeStyle;
            _gridTable     = gridTable;
            _gridRows      = gridTable.Rows;
            _gridCols      = gridTable.Columns;


            int nColumns = gridTable.ColumnCount;

            if (cellSizeStyle == CellSizeStyle.ColumnAndRow)
            {
                int cx = 0;
                for (int c = 0; c < nColumns; c++)
                {
                    GridColumn col   = _gridCols.GetColumn(c);
                    int        col_w = col.Width;
                    col.Left = cx;
                    cx      += col_w;
                }
                //------------------------------------------------------------
                int nRows = gridTable.RowCount;
                if (nRows > 0)
                {
                    int cy    = 0;
                    int row_h = 1;
                    for (int r = 0; r < nRows; r++)
                    {
                        GridRow row = _gridRows.GetRow(r);
                        row_h      = row.Height;
                        row.Height = row_h;
                        row.Top    = cy;
                        cy        += row_h;
                    }
                    _uniformCellHeight = row_h;
                }
            }
            else
            {
                int columnWidth = width;
                if (nColumns > 0)
                {
                    columnWidth       = columnWidth / nColumns;
                    _uniformCellWidth = columnWidth;
                    if (columnWidth < 1)
                    {
                        columnWidth = 1;
                    }
                }
                //------------------------------------------------------------
                int cx = 0;
                for (int c = 0; c < nColumns; c++)
                {
                    GridColumn col = _gridCols.GetColumn(c);
                    col.Width = columnWidth;
                    col.Left  = cx;
                    cx       += columnWidth;
                }
                //------------------------------------------------------------
                int nRows = gridTable.RowCount;
                if (nRows > 0)
                {
                    int rowHeight = height / nRows;
                    int cy        = 0;
                    for (int r = 0; r < nRows; r++)
                    {
                        GridRow row = _gridRows.GetRow(r);
                        row.Height = rowHeight;
                        row.Top    = cy;
                        cy        += rowHeight;
                    }
                    _uniformCellHeight = rowHeight;
                }
            }


            //------------------------------------------------------------
        }