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

OnPaintRow() protected method

Paints the Row at the specified index
protected OnPaintRow ( PaintEventArgs e, int row, Rectangle rowRect ) : void
e PaintEventArgs A PaintEventArgs that contains the event data
row int The index of the Row to be painted
rowRect Rectangle The bounding Rectangle of the Row to be painted
return void
        protected void OnPaintRow(PaintEventArgs e, int row, Rectangle rowRect)
        {
            Rectangle cellRect = new Rectangle(rowRect.X, rowRect.Y, 0, rowRect.Height);

            int colsToIgnore = 0;       // Used to skip cells that are ignored because of a colspan

            var nColumns = this.ColumnModel.Columns.Count;
            var gridLineFlags = new bool[nColumns];

            for (int i = 0; i < nColumns; i++)
            {
                if (!this.ColumnModel.Columns[i].Visible)
                {
                    continue;
                }

                Cell cell = this.TableModel[row, i];
                if (colsToIgnore == 0)
                {
                    cellRect.Width = this.ColumnModel.Columns[i].Width;

                    // Cope with missing cells in a row
                    if (cell == null)
                    {
                        cell = new Cell();
                    }

                    // If this cell spans other columns, then the width (above) needs to take into account
                    // the spanned columns too.
                    if (cell.ColSpan > 1)
                    {
                        for (int span = 1; span < cell.ColSpan; span++)
                        {
                            cellRect.Width += this.ColumnModel.Columns[i + span].Width;
                        }
                    }

                    if (cellRect.IntersectsWith(e.ClipRectangle))
                    {
                        try
                        {
                            this.OnPaintCell(e, row, i, cellRect);
                        }
                        catch (Exception exception)
                        {
                            exception.Data.Add("row", row);
                            exception.Data.Add("column", i);
                            exception.Data.Add("cellRect", cellRect.ToString());
                            throw;
                        }
                    }
                    else if (cellRect.Left > e.ClipRectangle.Right)
                    {
                        break;
                    }

                    // Ignore the cells that this cell span over
                    if (cell.ColSpan > 1)
                    {
                        colsToIgnore = cell.ColSpan - 1;
                    }
                }
                else
                {
                    colsToIgnore--;     // Skip over this cell and count down
                }

                gridLineFlags[i] = colsToIgnore < 1;

                cellRect.X += this.ColumnModel.Columns[i].Width;
            }

            Row r = this.TableModel.Rows[row];
            if (r.InternalGridLineFlags == null)
            {
                r.InternalGridLineFlags = gridLineFlags;
            }
        }
Table