コード例 #1
0
ファイル: GridColumn.cs プロジェクト: huamanhtuyen/VNACCS
        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;
            }
        }
コード例 #2
0
ファイル: GridColumn.cs プロジェクト: huamanhtuyen/VNACCS
        private int GetVirtualColumnWidthEx(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, ColumnAutoSizeMode autoSizeMode, ref int height)
        {
            GridPanel panel = GridPanel;

            int start = panel.FirstOnScreenRowIndex;
            int end = panel.LastOnScreenRowIndex;

            int width = 0;

            for (int i = start; i <= end; i++)
            {
                GridRow row = panel.VirtualRows[i];

                if (ColumnIndex < row.GridPanel.Columns.Count)
                {
                    if (ColumnIndex < row.Cells.Count)
                    {
                        GridCell cell = row.Cells[ColumnIndex];

                        MeasureCell(layoutInfo, stateInfo, autoSizeMode, row, cell);

                        width = Math.Max(width, cell.CellSize.Width);
                        height += cell.Size.Height;
                    }
                    else
                    {
                        width = Math.Max(width, Width);
                    }
                }
            }

            return (width);
        }
コード例 #3
0
ファイル: GridColumn.cs プロジェクト: huamanhtuyen/VNACCS
        private int GetColumnWidthEx(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, ColumnAutoSizeMode autoSizeMode,
            IEnumerable<GridElement> items, int maxHeight, ref int height)
        {
            int width = 0;

            foreach (GridElement item in items)
            {
                GridRow row = item as GridRow;

                if (row != null && row.Visible == true)
                {
                    if (ColumnIndex < row.GridPanel.Columns.Count)
                    {
                        if (ColumnIndex < row.Cells.Count)
                        {
                            GridCell cell = row.Cells[ColumnIndex];

                            if (maxHeight <= 0 || height < maxHeight)
                            {
                                MeasureCell(layoutInfo, stateInfo, autoSizeMode, row, cell);

                                width = Math.Max(width, cell.CellSize.Width);
                                height += cell.Size.Height;
                            }
                            else
                            {
                                cell.NeedsMeasured = true;
                            }
                        }
                        else
                        {
                            width = Math.Max(width, Width);
                        }
                    }

                    if (row.Rows != null && row.Expanded == true)
                    {
                        GridLayoutStateInfo itemStateInfo = new
                            GridLayoutStateInfo(stateInfo.GridPanel, stateInfo.IndentLevel + 1);

                        width = GetColumnWidth(layoutInfo, itemStateInfo,
                            autoSizeMode, row.Rows, width, maxHeight, ref height);
                    }
                }
                else
                {
                    if (item is GridGroup)
                    {
                        int n = GetColumnWidthEx(layoutInfo, stateInfo,
                            autoSizeMode, ((GridGroup) item).Rows, maxHeight, ref height);

                        width = Math.Max(width, n);
                    }
                }
            }

            return (width);
        }
コード例 #4
0
ファイル: GridColumn.cs プロジェクト: huamanhtuyen/VNACCS
        private int GetColumnWidth(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, ColumnAutoSizeMode autoSizeMode,
            IEnumerable<GridElement> items, int width, int maxHeight, ref int height)
        {
            GridPanel panel = GridPanel;

            if (panel != null)
            {
                if (panel.VirtualMode == true)
                {
                    if (panel.VirtualRowCount > 0)
                    {
                        int n = GetVirtualColumnWidthEx(layoutInfo,
                            stateInfo, autoSizeMode, ref height);

                        width = Math.Max(width, n);
                    }
                }
                else
                {
                    int n = GetColumnWidthEx(layoutInfo,
                            stateInfo, autoSizeMode, items, maxHeight, ref height);

                    width = Math.Max(width, n);
                }
            }

            return (width);
        }