src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/Provider/ColumnPermutation.cs
/// <summary>
///     Get the blank expansion column information for the given permuted column.
/// </summary>
/// <param name="permutedColumn">The permuted column</param>
/// <param name="lastNativeNonBlankColumn">The last column in the native data structure that contains data</param>
/// <returns>
///     Expansion data with the column fields set. The returned data will always register as Invalid
///     because the rows are not set, but the columns are guaranteed to be value.
/// </returns>
Get the blank expansion column information for the given permuted column.
Get the blank expansion column information for the given permuted column .
public BlankExpansionData GetColumnExpansion(int permutedColumn, int lastNativeNonBlankColumn)
        {
            int firstPermutedColumn;
            int lastPermutedColumn;
            int anchorColumn;
            var nativeColumn = myVisibleColumns[permutedColumn];
            Debug.Assert(permutedColumn != -1);
            firstPermutedColumn = lastPermutedColumn = anchorColumn = permutedColumn;
            var haveAnchor = nativeColumn <= lastNativeNonBlankColumn;
            var searchLeft = !myPreferLeftBlanks;
            int i;
            for (var pass = 0; pass < 2; ++pass)
            {
                if (searchLeft)
                {
                    searchLeft = false;
                    if (permutedColumn > 0)
                    {
                        for (i = permutedColumn - 1; i >= 0; --i)
                        {
                            if (myVisibleColumns[i] <= lastNativeNonBlankColumn)
                            {
                                if (haveAnchor)
                                {
                                    if (myPreferLeftBlanks)
                                    {
                                        firstPermutedColumn = i + 1;
                                    }
                                    break;
                                }
                                else
                                {
                                    haveAnchor = true;
                                    firstPermutedColumn = anchorColumn = i;
                                    if (i == 0)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        if (i == -1)
                        {
                            firstPermutedColumn = 0;
                        }
                    }
                }
                else 
                {
                    searchLeft = true;
                    var visibleColumnCount = myVisibleColumns.Length;
                    var lastVisibleColumn = visibleColumnCount - 1;
                    if (permutedColumn < lastVisibleColumn)
                    {
                        for (i = permutedColumn + 1; i < visibleColumnCount; ++i)
                        {
                            if (myVisibleColumns[i] <= lastNativeNonBlankColumn)
                            {
                                if (haveAnchor)
                                {
                                    if (!myPreferLeftBlanks)
                                    {
                                        lastPermutedColumn = i - 1;
                                    }
                                    break;
                                }
                                else
                                {
                                    haveAnchor = true;
                                    lastPermutedColumn = anchorColumn = i;
                                    if (i == lastVisibleColumn)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        if (i == visibleColumnCount)
                        {
                            lastPermutedColumn = lastVisibleColumn;
                        }
                    }
                }
            }
            if (!haveAnchor)
            {
                anchorColumn = VirtualTreeConstant.NullIndex;
            }
            return new BlankExpansionData(
                VirtualTreeConstant.NullIndex, firstPermutedColumn, VirtualTreeConstant.NullIndex, lastPermutedColumn, anchorColumn);
        }
public BlankExpansionData GetColumnExpansion ( int permutedColumn , int lastNativeNonBlankColumn ) { int firstPermutedColumn ; int lastPermutedColumn ; int anchorColumn ; var nativeColumn = myVisibleColumns [ permutedColumn ] ; Debug . Assert ( permutedColumn != - 1 ) ; firstPermutedColumn = lastPermutedColumn = anchorColumn = permutedColumn ; var haveAnchor = nativeColumn <= lastNativeNonBlankColumn ; var searchLeft = ! myPreferLeftBlanks ; int i ; for ( var pass = 0 ; pass < 2 ; ++ pass ) { if ( searchLeft ) { searchLeft = false ; if ( permutedColumn > 0 ) { for ( i = permutedColumn - 1 ; i >= 0 ; -- i ) { if ( myVisibleColumns [ i ] <= lastNativeNonBlankColumn ) { if ( haveAnchor ) { if ( myPreferLeftBlanks ) { firstPermutedColumn = i + 1 ; } break ; } else { haveAnchor = true ; firstPermutedColumn = anchorColumn = i ; if ( i == 0 ) { break ; } } } } if ( i == - 1 ) { firstPermutedColumn = 0 ; } } } else { searchLeft = true ; var visibleColumnCount = myVisibleColumns . Length ; var lastVisibleColumn = visibleColumnCount - 1 ; if ( permutedColumn < lastVisibleColumn ) { for ( i = permutedColumn + 1 ; i < visibleColumnCount ; ++ i ) { if ( myVisibleColumns [ i ] <= lastNativeNonBlankColumn ) { if ( haveAnchor ) { if ( ! myPreferLeftBlanks ) { lastPermutedColumn = i - 1 ; } break ; } else { haveAnchor = true ; lastPermutedColumn = anchorColumn = i ; if ( i == lastVisibleColumn ) { break ; } } } } if ( i == visibleColumnCount ) { lastPermutedColumn = lastVisibleColumn ; } } } } if ( ! haveAnchor ) { anchorColumn = VirtualTreeConstant . NullIndex ; } return new BlankExpansionData ( VirtualTreeConstant . NullIndex , firstPermutedColumn , VirtualTreeConstant . NullIndex , lastPermutedColumn , anchorColumn ) ; }
Get the blank expansion column information for the given permuted column.
Get the blank expansion column information for the given permuted column .
// Lots of bad things can happen with column permutations and blank expansions. We // can end up with blanks to the left and the right of the anchor column, as well // as an entire row of blanks. We also need to consider whether the user prefers blanks // to the right (a standard tree), or the left (a reverse drawn or right-to-left tree). // If we're sitting on a blank cell, then this preference influences whether we // should look left first or right first for an anchor cell. // Go right on the next pass // Pick up blank columns to the left // We're looking left to pick up blanks only, not to find an anchor. // If we find another non-blank column to the left, then any blanks // between it and our pivot column belong to this node if we prefer // right blanks. Otherwise, attach them to the current pivot. In any // case, we do not need to look further. // If we did not have an anchor before, then // we need to handle the case of a central anchor // node, which can have blanks both to the left // and to the right, so we can't break here unless // there is nothing more to the left. // We fell off the end, so there must be blank columns // all the way to the left of the anchor // !searchLeft // Go left on the next pass // Pick up blank columns to the right // We're looking right to pick up blanks only, not to find an anchor. // If we find another non-blank column to the right, then any blanks // between it and our pivot column belong to this node if we prefer // left blanks. Otherwise, attach them to the current pivot. In any // case, we do not need to look further. // If we did not have an anchor before, then // we need to handle the case of a central anchor // node, which can have blanks both to the left // and to the right, so we can't break here unless // there is nothing more to the left. // We fell off the end, so there must be blank columns // all the way to the right of the anchor // This implies a totally blank row, which means that the UI code // allowed a root column with jagged child branches or complex column // to be hidden. Getting this situation to not have blank cells // implies pushing column visibility information down into the core // TREENODE structures in the core provider engine, which is a huge // huge amount of work. There are no plans to do this given the minimal // benefit to the end user. The best we'll do is to recognize the situation // and not crash at the control level.
Expansion data with the column fields set. The returned data will always register as Invalid
because the rows are not set, but the columns are guaranteed to be value.
Expansion data with the column fields set . The returned data will always register as Invalid because the rows are not set but the columns are guaranteed to be value .
permutedColumn
int
The permuted column
The permuted column
lastNativeNonBlankColumn
int
The last column in the native data structure that contains data
The last column in the native data structure that contains data