src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/UI/ColumnHeader.cs
/// <summary>
///     Finish a column adjustment begun with EndColumnAdjustment
/// </summary>
/// <param name="controlWidth">The adjusted control width (FullPercentageHeaderWidth on the control)</param>
/// <param name="dropPosition">The drop position, preadjusted for scroll position and leftscrollbar, and limited with LimitColumnAdjustment</param>
/// <returns>True if the headers changed.</returns>
Finish a column adjustment begun with EndColumnAdjustment
Finish a column adjustment begun with EndColumnAdjustment
public bool EndColumnAdjustment(int controlWidth, int dropPosition)
            {
                if (myHeaders[myAdjustingColumn].Percentage == 0f)
                {
                    int itemLeft;
                    int itemWidth;
                    GetColumnBounds(controlWidth, myAdjustingColumn, myAdjustingColumn, out itemLeft, out itemWidth);
                    var widthDelta = dropPosition - (itemLeft + itemWidth);
                    if (widthDelta == 0)
                    {
                        return false;
                    }
                    myTotalFixedWidth += widthDelta;
                    myHeaders[myAdjustingColumn].SetWidth(itemWidth + widthDelta);
                }
                else
                {
                    float itemLeft;
                    float itemRight;
                    GetVariableColumnBounds(controlWidth, myAdjustingColumn, myAdjustingColumn, out itemLeft, out itemRight);
                    if (dropPosition == (int)(itemRight + .5f))
                    {
                        return false;
                    }
                    var adjustingColumn = myAdjustingColumn;
                    var prevVariableColumn = adjustingColumn;
                    var prevPercent = myHeaders[adjustingColumn].Percentage;
                    var adjustColumnPercentChange = (dropPosition - itemRight)
                                                    / (CalculateNonFixedControlWidth(controlWidth) - myTotalFixedWidth);
                    var newPrevPercent = prevPercent + adjustColumnPercentChange;
                    myHeaders[adjustingColumn].SetPercentage(newPrevPercent);
                    var basePercentage = (1f - prevPercent) / (1f - newPrevPercent);
                    var columns = myHeaders.Length;
                    float percent;
                    for (var i = adjustingColumn + 1; i < columns; ++i)
                    {
                        percent = myHeaders[i].Percentage;
                        if (percent != 0f)
                        {
                            newPrevPercent += ((percent - prevPercent) / basePercentage);
                            myHeaders[i].SetPercentage(newPrevPercent);
                            prevPercent = percent;
                            prevVariableColumn = i;
                        }
                    }
                    if (prevVariableColumn == adjustingColumn)
                    {
                        return false;
                    }
                    myHeaders[prevVariableColumn].SetPercentage(1f);
                }
                Recalculate();
                return true;
            }
public bool EndColumnAdjustment ( int controlWidth , int dropPosition ) { if ( myHeaders [ myAdjustingColumn ] . Percentage == 0f ) { int itemLeft ; int itemWidth ; GetColumnBounds ( controlWidth , myAdjustingColumn , myAdjustingColumn , out itemLeft , out itemWidth ) ; var widthDelta = dropPosition - ( itemLeft + itemWidth ) ; if ( widthDelta == 0 ) { return false ; } myTotalFixedWidth += widthDelta ; myHeaders [ myAdjustingColumn ] . SetWidth ( itemWidth + widthDelta ) ; } else { float itemLeft ; float itemRight ; GetVariableColumnBounds ( controlWidth , myAdjustingColumn , myAdjustingColumn , out itemLeft , out itemRight ) ; if ( dropPosition == ( int ) ( itemRight + .5f ) ) { return false ; } var adjustingColumn = myAdjustingColumn ; var prevVariableColumn = adjustingColumn ; var prevPercent = myHeaders [ adjustingColumn ] . Percentage ; var adjustColumnPercentChange = ( dropPosition - itemRight ) / ( CalculateNonFixedControlWidth ( controlWidth ) - myTotalFixedWidth ) ; var newPrevPercent = prevPercent + adjustColumnPercentChange ; myHeaders [ adjustingColumn ] . SetPercentage ( newPrevPercent ) ; var basePercentage = ( 1f - prevPercent ) / ( 1f - newPrevPercent ) ; var columns = myHeaders . Length ; float percent ; for ( var i = adjustingColumn + 1 ; i < columns ; ++ i ) { percent = myHeaders [ i ] . Percentage ; if ( percent != 0f ) { newPrevPercent += ( ( percent - prevPercent ) / basePercentage ) ; myHeaders [ i ] . SetPercentage ( newPrevPercent ) ; prevPercent = percent ; prevVariableColumn = i ; } } if ( prevVariableColumn == adjustingColumn ) { return false ; } myHeaders [ prevVariableColumn ] . SetPercentage ( 1f ) ; } Recalculate ( ) ; return true ; }
Finish a column adjustment begun with EndColumnAdjustment
Finish a column adjustment begun with EndColumnAdjustment
// The dropPosition will already have been adjusted with LimitColumnAdjustment, // so we don't touch adjustMouseX here. // Find the new width for the item. This is easy for fixed-size columns, but involves // stealing equitable amounts from all trailing variable-width columns for non-fixed size // First get the percentage change of the column that is // being adjusted then share that percentage change with all // of the trailing variable columns. Share regardless of whether // they are at a minimum size or not. // Don't do anything. This used to be asserted, but it // is hard to stop the header control from trying this. // Make sure the last one didn't go too far
True if the headers changed.
True if the headers changed .
controlWidth
int
The adjusted control width (FullPercentageHeaderWidth on the control)
The adjusted control width ( FullPercentageHeaderWidth on the control )
dropPosition
int
The drop position, preadjusted for scroll position and leftscrollbar, and limited with LimitColumnAdjustment
The drop position preadjusted for scroll position and leftscrollbar and limited with LimitColumnAdjustment