src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/Provider/VirtualTree.cs
/// <summary>
///     Determine how far a given index is from its parent node. Due to expansions
///     and subitems, this value can be much greater than the index in the branch itself.
/// </summary>
/// <param name="parentRow">The row of the parent object</param>
/// <param name="column">The column coordinate</param>
/// <param name="relativeIndex">The index in the child list to get the offset for</param>
/// <param name="complexColumnRoot">The row and column are the first node of a complex subitem column. Return the offset from this node to other items in the root branch.</param>
/// <returns>The offset from the parent to the given index in an expanded child list</returns>
Determine how far a given index is from its parent node. Due to expansions
and subitems, this value can be much greater than the index in the branch itself.
Determine how far a given index is from its parent node . Due to expansions and subitems this value can be much greater than the index in the branch itself .
protected int GetOffsetFromParent(int parentRow, int column, int relativeIndex, bool complexColumnRoot)
        {
            TREENODE tn = null;
            if (parentRow == VirtualTreeConstant.NullIndex)
            {
                if (column > 0)
                {
                    throw new ArgumentOutOfRangeException(
                        "column", VirtualTreeStrings.GetString(VirtualTreeStrings.ColumnOutOfRangeException));
                }
                tn = myRootNode;
            }
            else if (complexColumnRoot)
            {
                if (relativeIndex == 0)
                {
                    return 1;
                }
                var pos = TrackCell(parentRow, ref column);
                tn = pos.ParentNode;
                if (!tn.ComplexSubItem)
                {
                    throw new ArgumentException(VirtualTreeStrings.GetString(VirtualTreeStrings.ComplexColumnRootException));
                }
                Debug.Assert(column == 0); 
            }
            else
            {
                var pos = TrackCell(parentRow, ref column);
                tn = pos.ParentNode.GetChildNode(pos.Index);
                if (column > 0
                    && tn != null)
                {
                    var sn = tn.SubItemAtColumn(column);
                    tn = (sn != null) ? sn.RootNode : null;
                }
            }
            if ((tn != null)
                && tn.Expanded)
            {
                return tn.GetChildOffset(relativeIndex);
            }
            else
            {
                throw new ArgumentException(VirtualTreeStrings.GetString(VirtualTreeStrings.ParentRowException));
            }
        }
protected int GetOffsetFromParent ( int parentRow , int column , int relativeIndex , bool complexColumnRoot ) { TREENODE tn = null ; if ( parentRow == VirtualTreeConstant . NullIndex ) { if ( column > 0 ) { throw new ArgumentOutOfRangeException ( " " , VirtualTreeStrings . GetString ( VirtualTreeStrings . ColumnOutOfRangeException ) ) ; } tn = myRootNode ; } else if ( complexColumnRoot ) { if ( relativeIndex == 0 ) { return 1 ; } var pos = TrackCell ( parentRow , ref column ) ; tn = pos . ParentNode ; if ( ! tn . ComplexSubItem ) { throw new ArgumentException ( VirtualTreeStrings . GetString ( VirtualTreeStrings . ComplexColumnRootException ) ) ; } Debug . Assert ( column == 0 ) ; } else { var pos = TrackCell ( parentRow , ref column ) ; tn = pos . ParentNode . GetChildNode ( pos . Index ) ; if ( column > 0 && tn != null ) { var sn = tn . SubItemAtColumn ( column ) ; tn = ( sn != null ) ? sn . RootNode : null ; } } if ( ( tn != null ) && tn . Expanded ) { return tn . GetChildOffset ( relativeIndex ) ; } else { throw new ArgumentException ( VirtualTreeStrings . GetString ( VirtualTreeStrings . ParentRowException ) ) ; } }
Determine how far a given index is from its parent node.
Determine how far a given index is from its parent node .
// column resolved by TrackCell for a complex item
The offset from the parent to the given index in an expanded child list
The offset from the parent to the given index in an expanded child list
parentRow
int
The row of the parent object
The row of the parent object
column
int
The column coordinate
The column coordinate
relativeIndex
int
The index in the child list to get the offset for
The index in the child list to get the offset for
complexColumnRoot
bool
The row and column are the first node of a complex subitem column. Return the offset from this node to other items in the root branch.
The row and column are the first node of a complex subitem column . Return the offset from this node to other items in the root branch .