src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/Provider/VirtualTree.cs
/// <summary>
///     Get the absolute index of an item in a TREENODE
/// </summary>
/// <param name="tn">A TREENODE in this tree</param>
/// <param name="index">The relative index of the item within the TREENODE</param>
/// <param name="singleColumnSubItemAdjust">The number of blanks before the item. Undefined if Column > 0.</param>
/// <returns>A valid coordinate, or VirtualTreeCoordinate.Invalid if the item does not currently appear.</returns>
Get the absolute index of an item in a TREENODE
Get the absolute index of an item in a TREENODE
private static VirtualTreeCoordinate FindAbsoluteIndex(TREENODE tn, int index, out int singleColumnSubItemAdjust)
        {
            Debug.Assert(tn != null);
            TREENODE tnTmp;
            var isExpanded = false;
            var column = 0;
            int tnImmedSubItemGain; 
            int tmpSubItemGain;
            singleColumnSubItemAdjust = 0;
            tnImmedSubItemGain = tn.ImmedSubItemGain;
            singleColumnSubItemAdjust = tnImmedSubItemGain;
            var absIndex = tn.Index + index + tnImmedSubItemGain + 1;
            while ((tn != null)
                   && (isExpanded = tn.MultiLine))
            {
                if (tn.Expanded)
                {
                    tnTmp = tn.FirstChild;
                    while ((tnTmp != null)
                           && tnTmp.Index < index)
                    {
                        if (tnTmp.Expanded)
                        {
                            tmpSubItemGain = tnTmp.FullSubItemGain;
                            absIndex += tnTmp.FullCount;
                        }
                        else
                        {
                            tmpSubItemGain = tnTmp.ImmedSubItemGain;
                        }
                        absIndex += tmpSubItemGain;
                        singleColumnSubItemAdjust += tmpSubItemGain;
                        tnTmp = tnTmp.NextSibling;
                    }
                }
                index = tn.Index;
                tnTmp = tn;
                if ((tn = tn.Parent) != null)
                {
                    tnImmedSubItemGain = tn.ImmedSubItemGain;
                    if (tnTmp.SubItemRoot)
                    {
                        column += tn.FirstSubItem.ColumnOfRootNode(tnTmp);
                        absIndex += tn.Index;
                        if (!tnTmp.ComplexSubItem)
                        {
                            ++absIndex;
                        }
                    }
                    else
                    {
                        singleColumnSubItemAdjust += tnImmedSubItemGain;
                        absIndex += tn.Index + tnImmedSubItemGain + 1;
                    }
                }
            }
            return isExpanded ? new VirtualTreeCoordinate(absIndex, column) : VirtualTreeCoordinate.Invalid;
        }
private static VirtualTreeCoordinate FindAbsoluteIndex ( TREENODE tn , int index , out int singleColumnSubItemAdjust ) { Debug . Assert ( tn != null ) ; TREENODE tnTmp ; var isExpanded = false ; var column = 0 ; int tnImmedSubItemGain ; int tmpSubItemGain ; singleColumnSubItemAdjust = 0 ; tnImmedSubItemGain = tn . ImmedSubItemGain ; singleColumnSubItemAdjust = tnImmedSubItemGain ; var absIndex = tn . Index + index + tnImmedSubItemGain + 1 ; while ( ( tn != null ) && ( isExpanded = tn . MultiLine ) ) { if ( tn . Expanded ) { tnTmp = tn . FirstChild ; while ( ( tnTmp != null ) && tnTmp . Index < index ) { if ( tnTmp . Expanded ) { tmpSubItemGain = tnTmp . FullSubItemGain ; absIndex += tnTmp . FullCount ; } else { tmpSubItemGain = tnTmp . ImmedSubItemGain ; } absIndex += tmpSubItemGain ; singleColumnSubItemAdjust += tmpSubItemGain ; tnTmp = tnTmp . NextSibling ; } } index = tn . Index ; tnTmp = tn ; if ( ( tn = tn . Parent ) != null ) { tnImmedSubItemGain = tn . ImmedSubItemGain ; if ( tnTmp . SubItemRoot ) { column += tn . FirstSubItem . ColumnOfRootNode ( tnTmp ) ; absIndex += tn . Index ; if ( ! tnTmp . ComplexSubItem ) { ++ absIndex ; } } else { singleColumnSubItemAdjust += tnImmedSubItemGain ; absIndex += tn . Index + tnImmedSubItemGain + 1 ; } } } return isExpanded ? new VirtualTreeCoordinate ( absIndex , column ) : VirtualTreeCoordinate . Invalid ; }
Get the absolute index of an item in a TREENODE
Get the absolute index of an item in a TREENODE
// ImmedSubItemGain is virtual, limit number of calls //Walk up parent chain to find offset //First, take into account all expanded nodes at this level //which occur before our start position // Track how many columns we need to shift for this column // The final index does not include the new parent's subitem gain, // and there is no automatic plus one like with a normal expanded branch  // Expanded cell
A valid coordinate, or VirtualTreeCoordinate.Invalid if the item does not currently appear.
A valid coordinate or VirtualTreeCoordinate . Invalid if the item does not currently appear .
tn
TREENODE
A TREENODE in this tree
A TREENODE in this tree
index
int
The relative index of the item within the TREENODE
The relative index of the item within the TREENODE
int
out
singleColumnSubItemAdjust
The number of blanks before the item. Undefined if Column > 0.
The number of blanks before the item . Undefined if Column > 0 .