forked from skeiya/ProjectsTM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRowColRange.cs
51 lines (43 loc) · 1.4 KB
/
RowColRange.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections.Generic;
namespace FreeGridControl
{
public class RowColRange
{
private readonly ColIndex _leftCol;
private readonly RowIndex _topRow;
private readonly int _colCount;
private readonly int _rowCount;
public RowColRange(ColIndex visibleNormalLeftCol, RowIndex visibleNormalTopRow, int visibleNormalColCount, int visibleNormalRowCount)
{
this._leftCol = visibleNormalLeftCol;
this._topRow = visibleNormalTopRow;
this._colCount = visibleNormalColCount;
this._rowCount = visibleNormalRowCount;
}
public IEnumerable<ColIndex> Cols
{
get
{
return _leftCol.Range(_colCount);
}
}
public bool Contains(RowIndex r, ColIndex c)
{
if (c.Value < _leftCol.Value) return false;
if (_leftCol.Value + _colCount < c.Value) return false;
if (r.Value < _topRow.Value) return false;
if (_topRow.Value + _rowCount < r.Value) return false;
return true;
}
public IEnumerable<RowIndex> Rows
{
get
{
return _topRow.Range(_rowCount);
}
}
public int RowCount => _rowCount;
public RowIndex TopRow => _topRow;
public ColIndex LeftCol => _leftCol;
}
}