Esempio n. 1
0
        /// <summary>
        /// Measures the current row when drawn with the specified cells.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="useColumnWidth">True to fix the column width when calculating the required height of the row.</param>
        /// <param name="StartCol">Start column to measure</param>
        /// <param name="EndCol">End column to measure</param>
        /// <returns>Returns the required height</returns>
        public int MeasureRowHeight(int row, bool useColumnWidth, int StartCol, int EndCol)
        {
            int min = Grid.MinimumHeight;

            if ((GetAutoSizeMode(row) & AutoSizeMode.MinimumSize) == AutoSizeMode.MinimumSize)
            {
                return(min);
            }

            for (int c = StartCol; c <= EndCol; c++)
            {
                Cells.ICellVirtual cell = Grid.GetCell(row, c);
                if (cell != null)
                {
                    Position cellPosition = new Position(row, c);

                    Size maxLayout = Size.Empty;
                    //Use the width of the actual cell (considering spanned cells)
                    if (useColumnWidth)
                    {
                        maxLayout.Width = Grid.RangeToSize(Grid.PositionToCellRange(cellPosition)).Width;
                    }

                    CellContext cellContext = new CellContext(Grid, cellPosition, cell);
                    Size        cellSize    = cellContext.Measure(maxLayout);
                    if (cellSize.Height > min)
                    {
                        min = cellSize.Height;
                    }
                }
            }
            return(min);
        }
Esempio n. 2
0
        /// <summary>
        /// Measures the current column when drawn with the specified cells.
        /// </summary>
        /// <param name="column"></param>
        /// <param name="useRowHeight">True to fix the row height when measure the column width.</param>
        /// <param name="StartRow">Start row to measure</param>
        /// <param name="EndRow">End row to measure</param>
        /// <returns>Returns the required width</returns>
        public int MeasureColumnWidth(int column, bool useRowHeight, int StartRow, int EndRow)
        {
            int min = Grid.MinimumWidth;

            if ((GetAutoSizeMode(column) & AutoSizeMode.MinimumSize) == AutoSizeMode.MinimumSize)
            {
                return(min);
            }

            for (int r = StartRow; r <= EndRow; r++)
            {
                Cells.ICellVirtual cell = Grid.GetCell(r, column);
                if (cell != null)
                {
                    Position cellPosition = new Position(r, column);

                    Size maxLayout = Size.Empty;
                    //Use the width of the actual cell (considering spanned cells)
                    if (useRowHeight)
                    {
                        maxLayout.Height = Grid.RangeToSize(Grid.PositionToCellRange(cellPosition)).Height;
                    }

                    CellContext cellContext = new CellContext(Grid, cellPosition, cell);
                    Size        cellSize    = cellContext.Measure(maxLayout);
                    if (cellSize.Width > min)
                    {
                        min = cellSize.Width;
                    }
                }
            }
            return(min);
        }