XPTable.Models.Table.FindNextVisibleCell C# (CSharp) Method

FindNextVisibleCell() protected method

Returns a CellPos that specifies the next Cell that is visible and enabled from the specified Cell
protected FindNextVisibleCell ( XPTable.Models.CellPos start, bool wrap, bool forward, bool includeStart, bool checkOtherCellsInRow, bool includeDisabledCells ) : XPTable.Models.CellPos
start XPTable.Models.CellPos A CellPos that specifies the Cell to start /// searching from
wrap bool Specifies whether to move to the start of the /// next Row when the end of the current Row is reached
forward bool Specifies whether the search should travel /// in a forward direction (top to bottom, left to right) through the Cells
includeStart bool Indicates whether the specified starting /// Cell is included in the search
checkOtherCellsInRow bool Specifies whether all Cells in /// the Row should be included in the search
includeDisabledCells bool Indicates whether disabled cells should be included in the search.
return XPTable.Models.CellPos
        protected CellPos FindNextVisibleCell(CellPos start, bool wrap, bool forward, bool includeStart, bool checkOtherCellsInRow, bool includeDisabledCells)
        {
            if (this.ColumnCount == 0 || this.RowCount == 0)
            {
                return CellPos.Empty;
            }

            int startRow = start.Row != -1 ? start.Row : 0;
            int startCol = start.Column != -1 ? start.Column : 0;

            bool first = true;

            if (forward)
            {
                for (int i = startRow; i < this.RowCount; i++)
                {
                    int j = (first || !checkOtherCellsInRow ? startCol : 0);

                    for (; j < this.TableModel.Rows[i].Cells.Count; j++)
                    {
                        if (i == startRow && j == startCol)
                        {
                            if (!first)
                            {
                                return CellPos.Empty;
                            }

                            first = false;

                            if (!includeStart)
                            {
                                if (!checkOtherCellsInRow)
                                {
                                    break;
                                }

                                continue;
                            }
                        }

                        if (IsCellVisible(i, j, includeDisabledCells))
                        {
                            return new CellPos(i, j);
                        }

                        if (!checkOtherCellsInRow)
                        {
                            continue;
                        }
                    }

                    if (wrap)
                    {
                        if (i + 1 == this.TableModel.Rows.Count)
                        {
                            i = -1;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                for (int i = startRow; i >= 0; i--)
                {
                    int j = (first || !checkOtherCellsInRow ? startCol : this.TableModel.Rows[i].Cells.Count);

                    for (; j >= 0; j--)
                    {
                        if (i == startRow && j == startCol)
                        {
                            if (!first)
                            {
                                return CellPos.Empty;
                            }

                            first = false;

                            if (!includeStart)
                            {
                                if (!checkOtherCellsInRow)
                                {
                                    break;
                                }

                                continue;
                            }
                        }

                        if (IsCellVisible(i, j, includeDisabledCells))
                        {
                            return new CellPos(i, j);
                        }

                        if (!checkOtherCellsInRow)
                        {
                            continue;
                        }
                    }

                    if (wrap)
                    {
                        if (i - 1 == -1)
                        {
                            i = this.TableModel.Rows.Count;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return CellPos.Empty;
        }
Table