Example #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            using (_renderer.LockGraphics(e.Graphics))
            {
                // White Background
                _renderer.SetBrush(Color.White);
                _renderer.SetSolidPen(Color.White);
                _renderer.FillRectangle(e.ClipRectangle);

                // Lag frame calculations
                SetLagFramesArray();

                List <RollColumn> visibleColumns;

                if (HorizontalOrientation)
                {
                    CalculateHorizontalColumnPositions(VisibleColumns.ToList());
                    visibleColumns = VisibleColumns
                                     .Take(_horizontalColumnTops.Count(c => c < e.ClipRectangle.Height))
                                     .ToList();
                }
                else
                {
                    visibleColumns = _columns.VisibleColumns
                                     .Where(c => c.Right > _hBar.Value)
                                     .Where(c => c.Left - _hBar.Value < e.ClipRectangle.Width)
                                     .ToList();
                }

                var firstVisibleRow = Math.Max(FirstVisibleRow, 0);
                var visibleRows     = HorizontalOrientation
                                        ? e.ClipRectangle.Width / CellWidth
                                        : e.ClipRectangle.Height / CellHeight;

                var lastVisibleRow = firstVisibleRow + visibleRows;

                var needsColumnRedraw = HorizontalOrientation || e.ClipRectangle.Y < ColumnHeight;
                if (visibleColumns.Any() && needsColumnRedraw)
                {
                    DrawColumnBg(visibleColumns, e.ClipRectangle);
                    DrawColumnText(visibleColumns);
                }

                // Background
                DrawBg(visibleColumns, e.ClipRectangle, firstVisibleRow, lastVisibleRow);

                // Foreground
                DrawData(visibleColumns, firstVisibleRow, lastVisibleRow);

                DrawColumnDrag(visibleColumns);
                DrawCellDrag(visibleColumns);
            }
        }