SourceGrid.GridVirtual.RangeAtArea C# (CSharp) Method

RangeAtArea() public method

Get the range of cells at the specified dispaly area. This method consider only the visible cells using the current scroll position. Returns a single Range for the specified grid area (scrollable, fixedtop, fixedleft, fixedtopleft). Returns Range.Empty if there isn't a valid range in the specified area.
public RangeAtArea ( CellPositionType areaType ) : Range
areaType CellPositionType
return Range
        public Range RangeAtArea(CellPositionType areaType)
        {
            if (areaType == CellPositionType.FixedTopLeft)
            {
                if (FixedRows > 0 && Rows.Count >= FixedRows &&
                    FixedColumns > 0 && Columns.Count >= FixedColumns)
                    return new Range(0, 0, FixedRows - 1, FixedColumns - 1);
                else
                    return Range.Empty;
            }
            else if (areaType == CellPositionType.FixedLeft)
            {
                int actualFixed = FixedColumns;
                if (actualFixed > Columns.Count)
                    actualFixed = Columns.Count;

                if (actualFixed <= 0)
                    return Range.Empty;

                int? firstRow = Rows.FirstVisibleScrollableRow;
                int? lastRow = Rows.LastVisibleScrollableRow;

                if (firstRow == null || lastRow == null)
                    return Range.Empty;

                return new Range(firstRow.Value, 0, lastRow.Value, actualFixed - 1);
            }
            else if (areaType == CellPositionType.FixedTop)
            {
                int actualFixed = FixedRows;
                if (actualFixed > Rows.Count)
                    actualFixed = Rows.Count;

                if (actualFixed <= 0)
                    return Range.Empty;

                int? firstCol = Columns.FirstVisibleScrollableColumn;
                int? lastCol = Columns.LastVisibleScrollableColumn;

                if (firstCol == null || lastCol == null)
                    return Range.Empty;

                return new Range(0, firstCol.Value, actualFixed - 1, lastCol.Value);
            }
            else if (areaType == CellPositionType.Scrollable)
            {
                int? firstRow = Rows.FirstVisibleScrollableRow;
                int? lastRow = Rows.LastVisibleScrollableRow;

                int? firstCol = Columns.FirstVisibleScrollableColumn;
                int? lastCol = Columns.LastVisibleScrollableColumn;

                if (firstRow == null || firstCol == null ||
                    lastRow == null || lastCol == null)
                    return Range.Empty;

                return new Range(firstRow.Value, firstCol.Value,
                                lastRow.Value, lastCol.Value);
            }
            else
                throw new SourceGridException("Invalid areaType");
        }