5
5
* Date: 23/09/2008 11:15 AM
6
6
*
7
7
* Change log:
8
+ * v2.9.2
9
+ * 2016-06-02 JPP - Added bounds check to GetNthObject().
8
10
* v2.9
9
11
* 2015-08-02 JPP - Fixed buy with hierarchical checkboxes where setting the checkedness of a deeply
10
12
* nested object would sometimes not correctly calculate the changes in the hierarchy. SF #150.
39
41
* If some children are checked and some are not, the parent is indeterminate.
40
42
* v2.6
41
43
* 2012-10-25 JPP - Circumvent annoying issue in ListView control where changing
42
- * selection would leave artifacts on the control.
44
+ * selection would leave artefacts on the control.
43
45
* 2012-08-10 JPP - Don't trigger selection changed events during expands
44
46
*
45
47
* v2.5.1
@@ -396,7 +398,7 @@ public override IEnumerable ObjectsForClustering {
396
398
397
399
/// <summary>
398
400
/// After expanding a branch, should the TreeListView attempts to show as much of the
399
- /// revealed descendents as possible.
401
+ /// revealed descendants as possible.
400
402
/// </summary>
401
403
[ Category ( "ObjectListView" ) ,
402
404
Description ( "Should the parent of an expand subtree be scrolled to the top revealing the children?" ) ,
@@ -633,9 +635,9 @@ public virtual void Expand(Object model) {
633
635
try {
634
636
int countPerPage = NativeMethods . GetCountPerPage ( this ) ;
635
637
int descedentCount = this . TreeModel . GetVisibleDescendentCount ( model ) ;
636
- // If all of the descendents can be shown in the window, make sure that last one is visible.
637
- // If all the descendents can't fit into the window, move the model to the top of the window
638
- // (which will show as many of the descendents as possible)
638
+ // If all of the descendants can be shown in the window, make sure that last one is visible.
639
+ // If all the descendants can't fit into the window, move the model to the top of the window
640
+ // (which will show as many of the descendants as possible)
639
641
if ( descedentCount < countPerPage ) {
640
642
this . EnsureVisible ( index + descedentCount ) ;
641
643
} else {
@@ -994,7 +996,7 @@ public override OLVListItem MakeListViewItem(int itemIndex) {
994
996
}
995
997
996
998
/// <summary>
997
- /// Reinitialize the Tree structure
999
+ /// Reinitialise the Tree structure
998
1000
/// </summary>
999
1001
protected virtual void RegenerateTree ( ) {
1000
1002
this . TreeModel = this . TreeFactory == null ? new Tree ( this ) : this . TreeFactory ( this ) ;
@@ -1339,7 +1341,7 @@ public virtual int Collapse(Object model) {
1339
1341
int count = br . NumberVisibleDescendents ;
1340
1342
br . Collapse ( ) ;
1341
1343
1342
- // Remove the visible descendents from after the branch itself
1344
+ // Remove the visible descendants from after the branch itself
1343
1345
int index = this . GetObjectIndex ( model ) ;
1344
1346
this . objectList . RemoveRange ( index + 1 , count ) ;
1345
1347
this . RebuildObjectMap ( 0 ) ;
@@ -1408,10 +1410,10 @@ public virtual Branch GetBranch(object model) {
1408
1410
}
1409
1411
1410
1412
/// <summary>
1411
- /// Return the number of visible descendents that are below the given model.
1413
+ /// Return the number of visible descendants that are below the given model.
1412
1414
/// </summary>
1413
1415
/// <param name="model">The model whose descendent count is to be returned</param>
1414
- /// <returns>The number of visible descendents . 0 if the model doesn't exist or is collapsed</returns>
1416
+ /// <returns>The number of visible descendants . 0 if the model doesn't exist or is collapsed</returns>
1415
1417
public virtual int GetVisibleDescendentCount ( object model )
1416
1418
{
1417
1419
Branch br = this . GetBranch ( model ) ;
@@ -1430,7 +1432,7 @@ public virtual int RebuildChildren(Object model) {
1430
1432
1431
1433
int count = br . NumberVisibleDescendents ;
1432
1434
1433
- // Remove the visible descendents from after the branch itself
1435
+ // Remove the visible descendants from after the branch itself
1434
1436
int index = this . GetObjectIndex ( model ) ;
1435
1437
if ( count > 0 )
1436
1438
this . objectList . RemoveRange ( index + 1 , count ) ;
@@ -1489,7 +1491,7 @@ protected virtual void InsertChildren(Branch br, int index) {
1489
1491
br . Expand ( ) ;
1490
1492
br . Sort ( this . GetBranchComparer ( ) ) ;
1491
1493
1492
- // Insert the branch's visible descendents after the branch itself
1494
+ // Insert the branch's visible descendants after the branch itself
1493
1495
this . objectList . InsertRange ( index , br . Flatten ( ) ) ;
1494
1496
this . RebuildObjectMap ( index ) ;
1495
1497
}
@@ -1543,7 +1545,9 @@ internal Branch MakeBranch(Branch parent, object model) {
1543
1545
/// <param name="n"></param>
1544
1546
/// <returns></returns>
1545
1547
public virtual object GetNthObject ( int n ) {
1546
- return this . objectList [ n ] ;
1548
+ if ( n >= 0 && n < this . objectList . Count )
1549
+ return this . objectList [ n ] ;
1550
+ return null ;
1547
1551
}
1548
1552
1549
1553
/// <summary>
@@ -1975,7 +1979,7 @@ public Object Model {
1975
1979
private Object model ;
1976
1980
1977
1981
/// <summary>
1978
- /// Return the number of descendents of this branch that are currently visible
1982
+ /// Return the number of descendants of this branch that are currently visible
1979
1983
/// </summary>
1980
1984
/// <returns></returns>
1981
1985
public virtual int NumberVisibleDescendents {
@@ -2104,7 +2108,7 @@ public virtual void FetchChildren() {
2104
2108
}
2105
2109
2106
2110
/// <summary>
2107
- /// Collapse the visible descendents of this branch into list of model objects
2111
+ /// Collapse the visible descendants of this branch into list of model objects
2108
2112
/// </summary>
2109
2113
/// <returns></returns>
2110
2114
public virtual IList Flatten ( ) {
@@ -2115,7 +2119,7 @@ public virtual IList Flatten() {
2115
2119
}
2116
2120
2117
2121
/// <summary>
2118
- /// Flatten this branch's visible descendents onto the given list.
2122
+ /// Flatten this branch's visible descendants onto the given list.
2119
2123
/// </summary>
2120
2124
/// <param name="flatList"></param>
2121
2125
/// <remarks>The branch itself is <b>not</b> included in the list.</remarks>
@@ -2152,7 +2156,7 @@ public virtual void RefreshChildren() {
2152
2156
}
2153
2157
2154
2158
/// <summary>
2155
- /// Sort the sub-branches and their descendents so they are ordered according
2159
+ /// Sort the sub-branches and their descendants so they are ordered according
2156
2160
/// to the given comparer.
2157
2161
/// </summary>
2158
2162
/// <param name="comparer">The comparer that orders the branches</param>
0 commit comments