src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/UI/ColumnHeader.cs
/// <summary>
///     Change the visible order to match the new order.
/// </summary>
/// <param name="oldOrder">The old order. Acts as a base order to determine new order</param>
/// <param name="newOrder">The new order. Compare columns to old order to deduce current display order.</param>
/// <param name="updateHeaderControl">Set to true if the headers should be updated during this function</param>
/// <returns>true to allow the change, false to block it</returns>
Change the visible order to match the new order.
Change the visible order to match the new order .
public bool ChangeColumnOrder(int[] oldOrder, int[] newOrder, bool updateHeaderControl)
        {
            if (!AllowColumnOrderChange(oldOrder, newOrder))
            {
                return false;
            }
            try
            {
                SetStateFlag(VTCStateFlags.UpdateHeaderControl, updateHeaderControl);
                SetStateFlag(VTCStateFlags.ChangingColumnOrder, true);
                var needOldPermutation = GetStyleFlag(VTCStyleFlags.MultiSelect);
                if (!needOldPermutation
                    && GetStateFlag(VTCStateFlags.FullColumnHeadersDirty))
                {
                    myHeaderBounds.ReverseIntegratePermutedSettings(
                        myColumnPermutation, GetStateFlag(VTCStateFlags.FixedColumnAutoFilled), myFullHeaders);
                    SetStateFlag(VTCStateFlags.FullColumnHeadersDirty, false);
                }
                var oldSelectionColumn = -1;
                ColumnPermutation oldPermutation = null;
                if (myColumnPermutation == null)
                {
                    myColumnPermutation = new ColumnPermutation(newOrder.Length, newOrder, RightToLeft == RightToLeft.Yes);
                }
                else
                {
                    if (needOldPermutation)
                    {
                        oldPermutation = myColumnPermutation.Clone();
                    }
                    else
                    {
                        oldSelectionColumn = myColumnPermutation.GetNativeColumn(mySelectionColumn);
                    }
                    myColumnPermutation.ChangeVisibleColumnOrder(oldOrder, newOrder);
                }
                PermuteHeaders(oldPermutation, myColumnPermutation, false, oldSelectionColumn);
                Refresh();
            }
            finally
            {
                SetStateFlag(VTCStateFlags.ChangingColumnOrder, false);
            }
            return true;
        }
public bool ChangeColumnOrder ( int [ ] oldOrder , int [ ] newOrder , bool updateHeaderControl ) { if ( ! AllowColumnOrderChange ( oldOrder , newOrder ) ) { return false ; } try { SetStateFlag ( VTCStateFlags . UpdateHeaderControl , updateHeaderControl ) ; SetStateFlag ( VTCStateFlags . ChangingColumnOrder , true ) ; var needOldPermutation = GetStyleFlag ( VTCStyleFlags . MultiSelect ) ; if ( ! needOldPermutation && GetStateFlag ( VTCStateFlags . FullColumnHeadersDirty ) ) { myHeaderBounds . ReverseIntegratePermutedSettings ( myColumnPermutation , GetStateFlag ( VTCStateFlags . FixedColumnAutoFilled ) , myFullHeaders ) ; SetStateFlag ( VTCStateFlags . FullColumnHeadersDirty , false ) ; } var oldSelectionColumn = - 1 ; ColumnPermutation oldPermutation = null ; if ( myColumnPermutation == null ) { myColumnPermutation = new ColumnPermutation ( newOrder . Length , newOrder , RightToLeft == RightToLeft . Yes ) ; } else { if ( needOldPermutation ) { oldPermutation = myColumnPermutation . Clone ( ) ; } else { oldSelectionColumn = myColumnPermutation . GetNativeColumn ( mySelectionColumn ) ; } myColumnPermutation . ChangeVisibleColumnOrder ( oldOrder , newOrder ) ; } PermuteHeaders ( oldPermutation , myColumnPermutation , false , oldSelectionColumn ) ; Refresh ( ) ; } finally { SetStateFlag ( VTCStateFlags . ChangingColumnOrder , false ) ; } return true ; }
Change the visible order to match the new order.
Change the visible order to match the new order .
// Integrate before doing the new permutation so that we can apply // the change inline in the current permutation // Unfortunately, the oldPermutation is required here to enable cleanly changing selecting // the columns in multiselect mode. I'd prefer not to make the copy, but multiselect selection // state is very hard to propagate without a copy of the old permutation to accurately filter // the selected indices // For the single select case, just pass in the oldSelectionColumn
true to allow the change, false to block it
true to allow the change false to block it
oldOrder
int[]
The old order. Acts as a base order to determine new order
The old order . Acts as a base order to determine new order
newOrder
int[]
The new order. Compare columns to old order to deduce current display order.
The new order . Compare columns to old order to deduce current display order .
updateHeaderControl
bool
Set to true if the headers should be updated during this function
Set to true if the headers should be updated during this function