Esempio n. 1
0
        private void MeasureCell(GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo,
            ColumnAutoSizeMode autoSizeMode, GridRow row, GridCell cell)
        {
            if (cell.NeedsMeasured || NeedsMeasured || row.NeedsMeasured)
            {
                int rowHeight = row.GetRowHeight();

                if (rowHeight > 0)
                {
                    Size size = new Size(Width, rowHeight);

                    if (autoSizeMode != ColumnAutoSizeMode.None)
                    {
                        cell.Measure(layoutInfo, stateInfo, Size.Empty);

                        size.Width = cell.Size.Width;
                        size.Width += GetColumnIndent(stateInfo.IndentLevel);
                    }
                    else
                    {
                        cell.Measure(layoutInfo, stateInfo, size);
                    }

                    cell.Size = size;
                }
                else
                {
                    Size size = Size.Empty;

                    if (autoSizeMode == ColumnAutoSizeMode.None)
                    {
                        size.Width = Width;
                        size.Width -= GetColumnIndent(stateInfo.IndentLevel);
                        size.Width = Math.Max(1, size.Width);
                    }

                    cell.Measure(layoutInfo, stateInfo, new Size(size.Width, 0));

                    if (autoSizeMode != ColumnAutoSizeMode.None)
                    {
                        size = cell.Size;
                        size.Width += GetColumnIndent(stateInfo.IndentLevel);
                        cell.Size = size;
                    }
                    else
                    {
                        size = cell.Size;
                        size.Width = Width;
                        cell.Size = size;
                    }
                }

                cell.CellSize = cell.Size;
            }
        }