Example #1
0
        /// <summary>
        /// Performs the layout of the item
        /// and sets the Size property to size that item will take.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="constraintSize"></param>
        protected override void MeasureOverride(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            Size sizeNeeded = Size.Empty;

            if (stateInfo.GridPanel.ShowRowHeaders == true)
                sizeNeeded = MeasureRowHeader(stateInfo.GridPanel);

            Size size = Size.Empty;

            if (stateInfo.GridPanel.VirtualMode == true)
            {
                size.Width = GetColumnsWidth(stateInfo);
                size.Height = stateInfo.GridPanel.VirtualRowHeight;
            }
            else
            {
                int rowHeight = GetRowHeight();

                if (rowHeight == 0)
                {
                    size = MeasureCells(layoutInfo, stateInfo);
                }
                else
                {
                    size.Width = GetColumnsWidth(stateInfo);
                    size.Height = rowHeight;
                }
            }

            sizeNeeded.Width += size.Width;
            sizeNeeded.Height = Math.Max(size.Height, sizeNeeded.Height);
            sizeNeeded.Height = Math.Max(sizeNeeded.Height, stateInfo.GridPanel.MinRowHeight);
            sizeNeeded.Height = Math.Min(sizeNeeded.Height, stateInfo.GridPanel.MaxRowHeight);

            _EffectivePreDetailRowHeight = GetRowPreDetailHeight();
            _EffectivePostDetailRowHeight = GetRowPostDetailHeight();

            SuperGrid.DoRowGetDetailHeightEvent(this, layoutInfo,
                sizeNeeded, ref _EffectivePreDetailRowHeight, ref _EffectivePostDetailRowHeight);

            sizeNeeded.Height += (_EffectivePreDetailRowHeight + _EffectivePostDetailRowHeight);

            FixedRowHeight = sizeNeeded.Height;

            HasVisibleItems = false;

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

                    size = MeasureSubItems(layoutInfo, itemStateInfo, constraintSize);

                    sizeNeeded.Width = Math.Max(size.Width, sizeNeeded.Width);
                    sizeNeeded.Height += size.Height;
                }
                else
                {
                    HasVisibleItems = AnyVisibleItems();
                }
            }

            Size = sizeNeeded;
        }
Example #2
0
        /// <summary>
        /// Performs the layout of the item and sets the Size property to size that item will take.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="constraintSize"></param>
        protected override void MeasureOverride(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            Size sizeNeeded = MeasureRow(layoutInfo, stateInfo, constraintSize);

            if (constraintSize.Width > 0)
                sizeNeeded.Width = constraintSize.Width;

            Size = sizeNeeded;
        }
Example #3
0
 /// <summary>
 /// Performs the arrange pass layout of the item
 /// when final position and size of the item has been set
 /// </summary>
 /// <param name="layoutInfo">Layout information.</param>
 /// <param name="stateInfo"></param>
 /// <param name="layoutBounds">Layout bounds</param>
 protected override void ArrangeOverride(GridLayoutInfo layoutInfo,
     GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
 {
     Size = ArrangeRow(layoutInfo, stateInfo, layoutBounds);
 }
Example #4
0
        /// <summary>
        /// Performs the arrange pass layout of the item when final position and size of the item has been set.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="layoutBounds">Layout bounds</param>
        protected override void ArrangeOverride(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
        {
            GridPanel panel = stateInfo.GridPanel;

            if (panel.ColumnHeader.Visible == true)
                panel.ColumnHeader.UpdateImageBounds(panel, this);

            if (NeedsFilterScan == true || panel.NeedsFilterScan == true)
            {
                NeedsFilterScan = false;

                if (FilterAutoScan == true)
                    FilterScan.BeginScan();
            }
        }
Example #5
0
        private Size GetMaximumCellSize(GridItemsCollection rows,
            int firstRow, int lastRow, GridLayoutInfo layoutInfo, GridLayoutStateInfo layoutState)
        {
            Size size = Size.Empty;

            for (int i = firstRow; i < lastRow; i++)
            {
                if (i >= rows.Count)
                    break;

                GridContainer item = rows[i] as GridContainer;

                if (item != null)
                {
                    Size cellSize = Size.Empty;

                    if (item is GridRow)
                    {
                        cellSize = GetMaxRowCellSize(
                            (GridRow) item, layoutInfo, layoutState);
                    }
                    else if (item is GridGroup)
                    {
                        cellSize = GetMaximumCellSize(
                            item.Rows, 0, lastRow - i, layoutInfo, layoutState);
                    }

                    size.Width = Math.Max(size.Width, cellSize.Width);
                    size.Height = Math.Max(size.Height, cellSize.Height);
                }
            }

            return (size);
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        protected override void MeasureOverride(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            Size sizeNeeded = Size.Empty;
            GridPanel panel = stateInfo.GridPanel;
            Graphics g = layoutInfo.Graphics;

            if (CanShowRowHeader(panel) == true)
                sizeNeeded.Width += panel.RowHeaderWidth;

            GroupHeaderVisualStyle style = GetSizingStyle(panel);

            Size size = MeasureGroupText(g, style, constraintSize);

            if (size.Height > 0)
            {
                size.Height += 8;

                size.Width += style.Padding.Horizontal;
                size.Height += style.Padding.Vertical;
            }

            size.Height = Math.Max(size.Height, panel.GroupHeaderHeight);

            sizeNeeded.Width += size.Width;
            sizeNeeded.Height = Math.Max(size.Height, sizeNeeded.Height);

            if (panel.ShowGroupUnderline == true && size.Height > 0)
                sizeNeeded.Height += 4;

            FixedRowHeight = sizeNeeded.Height;

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

                    size = MeasureSubItems(layoutInfo, itemStateInfo, constraintSize);
                }
                else
                {
                    size = MeasureSubItems(layoutInfo, stateInfo, constraintSize);
                }

                sizeNeeded.Width = Math.Max(size.Width, sizeNeeded.Width);
                sizeNeeded.Height += size.Height;
            }

            Size = sizeNeeded;
        }
Example #9
0
        protected override void ArrangeOverride(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
        {
            Rectangle bounds = layoutBounds;
            bounds.Height = FixedRowHeight;

            GridPanel panel = stateInfo.GridPanel;
            IndentLevel = stateInfo.IndentLevel;

            if (panel.ShowGroupExpand == true)
            {
                GroupHeaderVisualStyle style = GetSizingStyle(panel);

                Rectangle r = bounds;
                r.Width = panel.LevelIndentSize.Width;
                r.Height -= style.Padding.Vertical;

                if (r.Height < panel.GroupHeaderHeight)
                    r.Height = panel.GroupHeaderHeight;

                if (CanShowRowHeader(panel) == true)
                    r.X += panel.RowHeaderWidth;

                int n = panel.TreeButtonIndent +
                    (panel.LevelIndentSize.Width * IndentLevel) - panel.LevelIndentSize.Width;

                r.X += n;

                if (r.Right > BoundsRelative.Right)
                    r.Width -= r.Right - BoundsRelative.Right;

                r.X += style.Padding.Left;
                r.Y += style.Padding.Top;

                Size size = panel.GetTreeButtonSize();

                r.X += (r.Width - size.Width) / 2;
                r.Y += (r.Height - size.Height) / 2 - 1;

                r.Size = size;

                _ExpandButtonBounds = r;
            }
            else
            {
                _ExpandButtonBounds = Rectangle.Empty;
            }

            if (Rows != null && Expanded == true)
            {
                bounds = layoutBounds;

                bounds.Y += FixedRowHeight;
                bounds.Height -= FixedRowHeight;

                if (panel.IndentGroups == true)
                {
                    GridLayoutStateInfo itemStateInfo =
                        new GridLayoutStateInfo(panel, stateInfo.IndentLevel + 1);

                    ArrangeSubItems(layoutInfo, itemStateInfo, bounds);
                }
                else
                {
                    ArrangeSubItems(layoutInfo, stateInfo, bounds);
                }
            }
        }
Example #10
0
        private void ArrangeCells(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, Rectangle bounds)
        {
            GridPanel panel = stateInfo.GridPanel;

            if (panel.Columns.Count > 0)
            {
                int indentLevel = stateInfo.IndentLevel;

                GridCellCollection cells = _Cells;
                GridColumnCollection columns = panel.Columns;

                int j = 0;

                int[] map = columns.DisplayIndexMap;
                for (int i = 0; i < map.Length; i++)
                {
                    int index = map[i];

                    GridColumn column = columns[index];

                    if (column.Visible == true)
                    {
                        if (index < cells.Count)
                        {
                            GridCell cell = cells[index];

                            if (panel.GroupColumns.Count > 0)
                            {
                                cell.IndentLevel = (j == 0 ? indentLevel : 0);
                            }
                            else
                            {
                                cell.IndentLevel =
                                    (panel.PrimaryColumnIndex == index) ? indentLevel : 0;
                            }

                            bounds.Width = column.Size.Width;

                            cell.Arrange(layoutInfo, stateInfo, bounds);
                        }

                        j++;

                        bounds.X += column.Size.Width;
                    }
                }
            }
        }
Example #11
0
        ///<summary>
        /// This routine calculates and returns the maximum
        /// row height based upon the individual measured heights
        /// of each cell in the row, based upon the given array of
        /// columns to included in the calculation process.
        ///</summary>
        ///<returns></returns>
        public int GetMaximumRowHeight(GridColumn[] columns)
        {
            GridPanel panel = GridPanel;

            if (panel != null)
            {
                int maxHeight = 0;

                using (Graphics g = SuperGrid.CreateGraphics())
                {
                    GridLayoutInfo layoutInfo = new GridLayoutInfo(g, panel.BoundsRelative);
                    GridLayoutStateInfo layoutState = new GridLayoutStateInfo(panel, 0);

                    foreach (GridColumn column in columns)
                    {
                        if (column != null &&
                            column.ColumnIndex < Cells.Count)
                        {
                            GridCell cell = Cells[column.ColumnIndex];

                            if (cell != null)
                            {
                                Size oldSize = cell.Size;

                                cell.Measure(layoutInfo, layoutState, new Size(column.Width, 0));

                                if (cell.Size.Height > maxHeight)
                                    maxHeight = cell.Size.Height;

                                cell.Size = oldSize;
                            }
                        }
                    }
                }

                if (maxHeight > 0)
                    return (maxHeight);
            }

            return (GetRowHeight());
        }
Example #12
0
        /// <summary>
        /// Performs the arrange pass layout of the
        /// item when final position and size of the item has been set.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="layoutBounds">Layout bounds</param>
        protected override void ArrangeOverride(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
        {
            ContainerBounds = layoutBounds;

            Rectangle bounds = layoutBounds;
            bounds.Height = FixedRowHeight;

            GridPanel panel = stateInfo.GridPanel;
            IndentLevel = stateInfo.IndentLevel;

            if (panel.ShowRowHeaders == true)
                bounds.X += panel.RowHeaderWidth;

            ArrangeCells(layoutInfo, stateInfo, bounds);

            if (Rows != null && Expanded == true)
            {
                bounds = layoutBounds;

                bounds.Y += FixedRowHeight;
                bounds.Height -= FixedRowHeight;

                GridLayoutStateInfo itemStateInfo =
                    new GridLayoutStateInfo(panel, IndentLevel + 1);

                ArrangeSubItems(layoutInfo, itemStateInfo, bounds);
            }

            ArrangeLayoutCount = SuperGrid.ArrangeLayoutCount;
        }
Example #13
0
        private Size MeasureCells(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo)
        {
            GridPanel panel = stateInfo.GridPanel;
            Size sizeNeeded = Size.Empty;

            int rowHeight = GetRowHeight();

            GridCellCollection cells = _Cells;
            foreach (GridCell cell in cells)
            {
                if (cell.ColumnIndex < panel.Columns.Count)
                {
                    GridColumn column = panel.Columns[cell.ColumnIndex];

                    if (column.Visible == true)
                    {
                        ColumnAutoSizeMode mode = column.GetAutoSizeMode();
                        Size size = column.BoundsRelative.Size;

                        if ((rowHeight == 0 && mode == ColumnAutoSizeMode.Fill) ||
                            cell.NeedsMeasured == true || column.NeedsMeasured == true ||
                            NeedsMeasured == true || panel.NeedsMeasured == true)
                        {
                            cell.Measure(layoutInfo, stateInfo, size);
                        }

                        size.Height = cell.MeasuredSize.Height;

                        if (mode != ColumnAutoSizeMode.Fill)
                            size.Width = cell.MeasuredSize.Width;

                        if (rowHeight != 0)
                            size.Height = rowHeight;

                        cell.Size = size;

                        sizeNeeded.Width += cell.Size.Width;
                        sizeNeeded.Height = Math.Max(cell.Size.Height, sizeNeeded.Height);
                    }
                }
            }

            if (sizeNeeded.IsEmpty == true)
                sizeNeeded = new Size(100, rowHeight);

            return (sizeNeeded);
        }
Example #14
0
        private int GetColumnsWidth(GridLayoutStateInfo stateInfo)
        {
            int width = 0;

            GridColumnCollection columns = stateInfo.GridPanel.Columns;
            foreach (GridColumn column in columns)
            {
                if (column.Visible == true)
                    width += column.Size.Width;
            }

            return (width);
        }
Example #15
0
        private void ArrangeGrid(Graphics g)
        {
            ArrangeLayoutCount++;

            GridLayoutInfo layoutInfo = GetGridLayoutInfo(g);
            GridLayoutStateInfo stateInfo = new GridLayoutStateInfo(_PrimaryGrid, 0);

            Size constraintSize = Size.Empty;

            _PrimaryGrid.Measure(layoutInfo, stateInfo, constraintSize);

            stateInfo.PassCount++;

            NeedToUpdateIndicees = false;

            if (HorizontalIsOver(layoutInfo) == true && _HScrollBarVisible)
            {
                if(_HScrollBarVisible)
                    layoutInfo.ClientBounds.Height -= HScrollBarHeight;

                if (VerticalIsOver(layoutInfo) == true && _VScrollBarVisible)
                    layoutInfo.ClientBounds.Width -= VScrollBarWidth;

                _PrimaryGrid.Measure(layoutInfo, stateInfo, constraintSize);
            }
            else
            {
                if (VerticalIsOver(layoutInfo) == true && _VScrollBarVisible)
                {
                    layoutInfo.ClientBounds.Width -= VScrollBarWidth;

                    _PrimaryGrid.Measure(layoutInfo, stateInfo, constraintSize);

                    if (HorizontalIsOver(layoutInfo) == true && _HScrollBarVisible)
                        layoutInfo.ClientBounds.Height -= HScrollBarHeight;
                }
            }

            layoutInfo.ClientBounds.Width = Math.Max(0, layoutInfo.ClientBounds.Width);
            layoutInfo.ClientBounds.Height = Math.Max(0, layoutInfo.ClientBounds.Height);

            EnableVScrollBar(layoutInfo);
            EnableHScrollBar(layoutInfo);

            ViewRect = Rectangle.Empty;
            _PrimaryGrid.Arrange(layoutInfo, stateInfo, layoutInfo.ClientBounds);
            ViewRect = Rectangle.Empty;

            UpdateScrollBars(layoutInfo);

            if (_ActiveEditor != null)
                EditorCell.PositionEditPanel(_ActiveEditor);

            if (NonModalEditorCell != null)
                NonModalEditorCell.PositionEditPanel(_ActiveNonModalEditor);

            if (ActiveFilterPanel != null)
                _ActiveFilterPanel.PositionEditPanel();
        }
Example #16
0
        /// <summary>
        /// Performs the layout of the item and sets
        /// the Size property to size that item will take.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="constraintSize"></param>
        protected override void MeasureOverride(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            Size sizeNeeded = Size.Empty;

            GridPanel panel = stateInfo.GridPanel;

            sizeNeeded.Width = panel.ColumnHeader.Size.Width;

            sizeNeeded.Height = (_RowHeight > 0)
                ? _RowHeight : MeasureHeaderHeight(panel);

            Size = sizeNeeded;
        }
Example #17
0
        /// <summary>
        /// Performs the layout of the item and sets the Size property to size that item will take.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="constraintSize"></param>
        protected override void MeasureOverride(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            if (NeedsResized == true || NeedsMeasured == true || stateInfo.GridPanel.NeedsMeasured == true)
            {
                Size sizeNeeded = Size.Empty;

                ColumnAutoSizeMode autoSizeMode = GetAutoSizeMode();

                int baseWidth = MinimumWidth;

                switch (autoSizeMode)
                {
                    case ColumnAutoSizeMode.AllCells:
                    case ColumnAutoSizeMode.DisplayedCells:
                    case ColumnAutoSizeMode.ColumnHeader:
                        baseWidth = Math.Max(baseWidth, _HeaderSize.Width);
                        break;
                }

                int height = 0;

                switch (autoSizeMode)
                {
                    case ColumnAutoSizeMode.None:
                        sizeNeeded.Width = Math.Max(baseWidth, Width);
                        break;

                    case ColumnAutoSizeMode.AllCells:
                    case ColumnAutoSizeMode.AllCellsExceptHeader:
                        sizeNeeded.Width = GetColumnWidth(layoutInfo, stateInfo,
                            autoSizeMode, stateInfo.GridPanel.Rows, baseWidth, 0, ref height);
                        break;

                    case ColumnAutoSizeMode.ColumnHeader:
                        sizeNeeded = new Size(baseWidth, 0);
                        MarkRowsToMeasure(stateInfo.GridPanel.Rows);
                        break;

                    default:
                        sizeNeeded.Width = GetColumnWidth(layoutInfo, stateInfo, autoSizeMode,
                            stateInfo.GridPanel.Rows, baseWidth, layoutInfo.ClientBounds.Height, ref height);
                        break;
                }

                Size = sizeNeeded;

                NeedsResized = false;
            }
        }
Example #18
0
        /// <summary>
        /// This method is used by the items internally to invoke the measure pass to
        /// get item size. Override MeasureOverride method to perform actual measuring.
        /// </summary>
        /// <param name="layoutInfo">Holds contextual layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="constraintSize"></param>
        internal void Measure(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            MeasureOverride(layoutInfo, stateInfo, constraintSize);

            NeedsMeasured = false;
        }
Example #19
0
        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);
        }
Example #20
0
 /// <summary>
 /// Performs the arrange pass layout of the item when
 /// the final position and size of the item has been set.
 /// </summary>
 /// <param name="layoutInfo">Layout information.</param>
 /// <param name="stateInfo"></param>
 /// <param name="layoutBounds"></param>
 protected abstract void ArrangeOverride(
     GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Rectangle layoutBounds);
Example #21
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;
            }
        }
Example #22
0
        /// <summary>
        /// This method is used by the items internally to invoke the arrange pass after
        /// location and size of the item has been set. Override ArrangeOverride method
        /// to perform internal arranging.
        /// </summary>
        /// <param name="layoutInfo"></param>
        /// <param name="stateInfo"></param>
        /// <param name="layoutBounds"></param>
        internal void Arrange(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
        {
            IsLayoutValid = true;

            _BoundsRelative = layoutBounds;

            ArrangeOverride(layoutInfo, stateInfo, layoutBounds);
        }
Example #23
0
        ///<summary>
        /// This routine calculates and returns the maximum cell
        /// size from each cell in the column, as limited by the
        /// given row scope ('AllRows' or 'OnScreenRows').
        /// If 'includeHeader' is true, then the width of the header
        /// is included in the max calculation.
        ///</summary>
        ///<returns>Maximum cell size.</returns>
        public Size GetMaximumCellSize(RowScope scope, bool includeHeader)
        {
            Size size = Size.Empty;
            GridPanel panel = GridPanel;

            if (panel != null)
            {
                using (Graphics g = SuperGrid.CreateGraphics())
                {
                    GridLayoutInfo layoutInfo = new GridLayoutInfo(g, panel.BoundsRelative);
                    GridLayoutStateInfo layoutState = new GridLayoutStateInfo(panel, 0);

                    if (includeHeader == true)
                    {
                        Size oldSize = panel.ColumnHeader.Size;

                        panel.ColumnHeader.MeasureHeader(layoutInfo, Size.Empty, panel, this);

                        size.Width = _HeaderSize.Width;

                        panel.ColumnHeader.Size = oldSize;
                    }

                    if (panel.VirtualMode == true)
                    {
                        int firstRow = 0;
                        int lastRow = panel.VirtualRowCountEx;

                        if (scope == RowScope.OnScreenRows)
                        {
                            firstRow = panel.FirstOnScreenRowIndex;
                            lastRow = panel.LastOnScreenRowIndex + 1;
                        }

                        for (int i = firstRow; i < lastRow; i++)
                        {
                            GridRow row = panel.VirtualRows[i];
                            GridCell cell = row.Cells[ColumnIndex];

                            Size oldSize = cell.Size;

                            cell.Measure(layoutInfo, layoutState, Size.Empty);

                            int n = GetColumnIndent(layoutState.IndentLevel);

                            size.Width = Math.Max(size.Width, cell.Size.Width + n);
                            size.Height = Math.Max(size.Height, cell.Size.Height);

                            cell.Size = oldSize;
                        }
                    }
                    else
                    {
                        if (panel.Rows.Count > 0)
                        {
                            int firstRow = 0;
                            int lastRow = panel.Rows.Count;

                            if (scope == RowScope.OnScreenRows)
                            {
                                firstRow = panel.FirstOnScreenRowIndex;
                                lastRow = firstRow + 100;
                            }

                            Size cellSize = GetMaximumCellSize(
                                panel.Rows, firstRow, lastRow, layoutInfo, layoutState);

                            size.Width = Math.Max(size.Width, cellSize.Width);
                            size.Height = Math.Max(size.Height, cellSize.Height);
                        }
                    }
                }
            }

            return (size);
        }
Example #24
0
 /// <summary>
 /// Performs the layout of the item
 /// and sets the Size property to size that item will take.
 /// </summary>
 /// <param name="layoutInfo">Layout information.</param>
 /// <param name="stateInfo"></param>
 /// <param name="constraintSize"></param>
 protected abstract void MeasureOverride(
     GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize);
Example #25
0
        private Size GetMaxRowCellSize(GridRow row,
            GridLayoutInfo layoutInfo, GridLayoutStateInfo layoutState)
        {
            if (row.Cells.Count <= ColumnIndex)
                return (Size.Empty);

            GridCell cell = row.Cells[ColumnIndex];

            Size oldSize = cell.Size;

            cell.Measure(layoutInfo, layoutState, Size.Empty);

            Size size = cell.Size;
            size.Width += GetColumnIndent(layoutState.IndentLevel);

            cell.Size = oldSize;

            if (row.Rows.Count > 0 && row.Expanded == true)
            {
                layoutState.IndentLevel++;

                foreach (GridContainer item in row.Rows)
                {
                    if (item is GridRow)
                    {
                        Size cellSize =
                            GetMaxRowCellSize((GridRow)item, layoutInfo, layoutState);

                        size.Width = Math.Max(size.Width, cellSize.Width);
                        size.Height = Math.Max(size.Height, cellSize.Height);
                    }
                }

                layoutState.IndentLevel--;
            }

            return (size);
        }
Example #26
0
 /// <summary>
 /// Performs the arrange pass layout of the item
 /// when final position and size of the item has been set.
 /// </summary>
 /// <param name="layoutInfo">Layout information.</param>
 /// <param name="stateInfo"></param>
 /// <param name="layoutBounds">Layout bounds</param>
 protected override void ArrangeOverride(GridLayoutInfo layoutInfo,
     GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
 {
 }
Example #27
0
        protected virtual Size MeasureRow(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            Size sizeNeeded = Size.Empty;

            if (IsEmpty == false)
            {
                GridPanel panel = stateInfo.GridPanel;
                TextRowVisualStyle style = GetSizingStyle(stateInfo.GridPanel);

                Alignment imageAlignment = style.ImageAlignment;
                Size imageSize = style.GetImageSize(style.Image);

                if (style.IsOverlayImage == true)
                    imageAlignment = Alignment.MiddleCenter;

                int width = constraintSize.Width;

                if (width > 0)
                {
                    if (panel.IsSubPanel == false)
                        width = ViewRect.Width;

                    if (CanShowRowHeader(panel) == true)
                        width -= panel.RowHeaderWidth;

                    switch (imageAlignment)
                    {
                        case Alignment.TopCenter:
                        case Alignment.MiddleCenter:
                        case Alignment.BottomCenter:
                            break;

                        default:
                            width -= imageSize.Width;
                            break;
                    }
                }

                Size borderSize = style.GetBorderSize(true);

                if (constraintSize.Width > 0)
                    width -= borderSize.Width;

                Size size = GetTextSize(layoutInfo, style, width);

                switch (imageAlignment)
                {
                    case Alignment.MiddleCenter:
                        sizeNeeded.Height = Math.Max(imageSize.Height, size.Height) + borderSize.Height;
                        sizeNeeded.Width = Math.Max(size.Width, imageSize.Width) + borderSize.Width;
                        break;

                    case Alignment.TopCenter:
                    case Alignment.BottomCenter:
                        sizeNeeded.Width = Math.Max(size.Width, imageSize.Width) + borderSize.Width;
                        sizeNeeded.Height = size.Height + imageSize.Height + borderSize.Height;
                        break;

                    default:
                        sizeNeeded.Width = size.Width + imageSize.Width + borderSize.Width;
                        sizeNeeded.Height = Math.Max(imageSize.Height, size.Height) + borderSize.Height;
                        break;
                }

                if (RowHeight > 0)
                    sizeNeeded.Height = RowHeight;

                sizeNeeded.Height += 1;
            }

            return (sizeNeeded);
        }
Example #28
0
        /// <summary>
        /// Performs the layout of the item and sets
        /// the Size property to size that item will take.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="constraintSize"></param>
        protected override void MeasureOverride(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            Size sizeNeeded = Size.Empty;

            GridPanel panel = stateInfo.GridPanel;

            if (panel.ShowRowHeaders == true)
                sizeNeeded.Width += panel.RowHeaderWidth;

            GridColumnCollection columns = _Columns;
            foreach (GridColumn column in columns)
            {
                Size size = MeasureHeader(layoutInfo, constraintSize, panel, column);

                if (column.Visible == true)
                {
                    sizeNeeded.Width += size.Width;
                    sizeNeeded.Height = Math.Max(size.Height, sizeNeeded.Height);
                }
            }

            if (_RowHeight > 0)
                sizeNeeded.Height = _RowHeight;

            Size = sizeNeeded;
        }
Example #29
0
        protected virtual Size ArrangeRow(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
        {
            Size size = Size;

            size.Width = stateInfo.GridPanel.ColumnHeader.BoundsRelative.Width;

            return (size);
        }
Example #30
0
        protected override Size ArrangeRow(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
        {
            UpdateGroupBoxes(stateInfo.GridPanel, layoutBounds);

            return (base.ArrangeRow(layoutInfo, stateInfo, layoutBounds));
        }