@@ -25,13 +25,13 @@ protected override void OnPaint(PaintEventArgs e)
2525 if ( HorizontalOrientation )
2626 {
2727 visibleColumns = VisibleColumns
28- . Where ( c => c . Right > _vBar . Value && c . Left - _vBar . Value < e . ClipRectangle . Height )
28+ . Where ( c => c . Right - _vBar . Value > e . ClipRectangle . Top && c . Left - _vBar . Value < e . ClipRectangle . Bottom )
2929 . ToList ( ) ;
3030 }
3131 else
3232 {
3333 visibleColumns = _columns . VisibleColumns
34- . Where ( c => c . Right > _hBar . Value && c . Left - _hBar . Value < e . ClipRectangle . Width )
34+ . Where ( c => c . Right - _hBar . Value > e . ClipRectangle . Left && c . Left - _hBar . Value < e . ClipRectangle . Right )
3535 . ToList ( ) ;
3636 }
3737
@@ -297,7 +297,8 @@ private void DrawColumnBg(List<RollColumn> visibleColumns, Rectangle rect)
297297
298298 if ( HorizontalOrientation )
299299 {
300- _renderer . FillRectangle ( new Rectangle ( 0 , 0 , MaxColumnWidth + 1 , rect . Height ) ) ;
300+ int rightEdge = MaxColumnWidth ;
301+ _renderer . FillRectangle ( new Rectangle ( 0 , 0 , rightEdge + 1 , rect . Bottom ) ) ;
301302
302303 for ( int j = 0 ; j < visibleColumns . Count ; j ++ )
303304 {
@@ -307,20 +308,20 @@ private void DrawColumnBg(List<RollColumn> visibleColumns, Rectangle rect)
307308
308309 if ( visibleColumns . Count is not 0 )
309310 {
310- _renderer . Line ( 1 , TotalColWidth , MaxColumnWidth , TotalColWidth ) ;
311+ _renderer . Line ( 1 , TotalColWidth , rightEdge , TotalColWidth ) ;
311312 }
312313
313- _renderer . Line ( 0 , 0 , 0 , rect . Height ) ;
314- _renderer . Line ( MaxColumnWidth , 0 , MaxColumnWidth , rect . Height ) ;
314+ if ( rect . Left <= 0 ) _renderer . Line ( 0 , 0 , 0 , rect . Bottom ) ;
315+ _renderer . Line ( rightEdge , 0 , rightEdge , rect . Bottom ) ;
315316 }
316317 else
317318 {
318319 int bottomEdge = RowsToPixels ( 0 ) ;
319320
320321 // Gray column box and black line underneath
321- _renderer . FillRectangle ( new Rectangle ( 0 , 0 , rect . Width , bottomEdge + 1 ) ) ;
322- _renderer . Line ( 0 , 0 , rect . Width , 0 ) ;
323- _renderer . Line ( 0 , bottomEdge , rect . Width , bottomEdge ) ;
322+ _renderer . FillRectangle ( new Rectangle ( 0 , 0 , rect . Right , bottomEdge + 1 ) ) ;
323+ if ( rect . Top <= 0 ) _renderer . Line ( 0 , 0 , rect . Right , 0 ) ;
324+ _renderer . Line ( 0 , bottomEdge , rect . Right , bottomEdge ) ;
324325
325326 // Vertical black separators
326327 foreach ( var column in visibleColumns )
@@ -421,18 +422,18 @@ private void DrawBg(List<RollColumn> visibleColumns, Rectangle rect, int firstVi
421422 for ( int i = 1 ; i < lastVisibleRow - firstVisibleRow + 1 ; i ++ )
422423 {
423424 int x = RowsToPixels ( i ) ;
424- _renderer . Line ( x , 1 , x , rect . Height ) ;
425+ _renderer . Line ( x , 1 , x , rect . Bottom ) ;
425426 }
426427
427428 // Rows
428- _renderer . Line ( RowsToPixels ( 0 ) + 1 , 0 , rect . Width + MaxColumnWidth , 0 ) ;
429+ int startX = RowsToPixels ( 0 ) + 1 ;
430+ _renderer . Line ( startX , 0 , rect . Right , 0 ) ;
429431 for ( int i = 0 ; i < visibleColumns . Count ; i ++ )
430432 {
431433 // TODO: MaxColumnWidth shouldn't be necessary
432434 // This also makes too many assumptions, the parameters need to drive what is being drawn
433435 int y = visibleColumns [ i ] . Right - _vBar . Value ;
434- int x = RowsToPixels ( 0 ) + 1 ;
435- _renderer . Line ( x , y , rect . Width + MaxColumnWidth , y ) ;
436+ _renderer . Line ( startX , y , rect . Right , y ) ;
436437 }
437438 }
438439 else
@@ -442,19 +443,19 @@ private void DrawBg(List<RollColumn> visibleColumns, Rectangle rect, int firstVi
442443 foreach ( var column in visibleColumns )
443444 {
444445 int x = column . Left - _hBar . Value ;
445- _renderer . Line ( x , y , x , rect . Height - 1 ) ;
446+ _renderer . Line ( x , y , x , rect . Bottom - 1 ) ;
446447 }
447448
448449 if ( visibleColumns . Count is not 0 )
449450 {
450451 int x = TotalColWidth - _hBar . Value ;
451- _renderer . Line ( x , y , x , rect . Height - 1 ) ;
452+ _renderer . Line ( x , y , x , rect . Bottom - 1 ) ;
452453 }
453454
454455 // Rows
455456 for ( int i = 1 ; i < VisibleRows + 1 ; i ++ )
456457 {
457- _renderer . Line ( 0 , RowsToPixels ( i ) , rect . Width + 1 , RowsToPixels ( i ) ) ;
458+ _renderer . Line ( 0 , RowsToPixels ( i ) , rect . Right + 1 , RowsToPixels ( i ) ) ;
458459 }
459460 }
460461 }
0 commit comments