src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/UI/ColumnHeader.cs
/// <summary>
///     Determine the column for a given hit point, as well as the
///     left and width of the column.
/// </summary>
/// <param name="controlWidth">The current width of the control.</param>
/// <param name="x">The x offset into row</param>
/// <param name="itemLeft">The left edge of this column</param>
/// <param name="itemWidth">The width of this column</param>
/// <returns>The column x is in</returns>
Determine the column for a given hit point, as well as the
left and width of the column.
Determine the column for a given hit point as well as the left and width of the column .
public int ColumnHitTest(int controlWidth, int x, out int itemLeft, out int itemWidth)
            {
                var column = -1;
                itemLeft = 0;
                itemWidth = 0;
                var leftTotal = 0;
                var testWidth = 0;
                var headerCount = myHeaders.Length;
                if (myVariableBounds != null)
                {
                    EnsureColumnWidths(controlWidth);
                    var floatTotal = 0f;
                    var prevFloatTotal = 0f;
                    for (var i = 0; i < headerCount; ++i)
                    {
                        prevFloatTotal = floatTotal;
                        floatTotal += myColumnWidths[i];
                        testWidth = (int)(floatTotal + .5f);
                        if (x < testWidth)
                        {
                            column = i;
                            itemLeft = (int)(prevFloatTotal + .5f);
                            itemWidth = testWidth - itemLeft;
                            break;
                        }
                    }
                    if (column == -1)
                    {
                        column = headerCount - 1;
                        itemLeft = (int)(prevFloatTotal + .5f);
                        itemWidth = controlWidth - itemLeft;
                    }
                }
                else
                {
                    for (var i = 0; i < headerCount; ++i)
                    {
                        testWidth = myHeaders[i].Width;
                        if (x < testWidth)
                        {
                            column = i;
                            itemWidth = testWidth;
                            itemLeft = leftTotal;
                            break;
                        }
                        leftTotal += testWidth;
                        x -= testWidth;
                    }
                    if (column == -1)
                    {
                        column = headerCount - 1;
                        itemLeft = leftTotal - testWidth;
                        itemWidth = controlWidth - itemLeft;
                    }
                }
                return column;
            }
public int ColumnHitTest ( int controlWidth , int x , out int itemLeft , out int itemWidth ) { var column = - 1 ; itemLeft = 0 ; itemWidth = 0 ; var leftTotal = 0 ; var testWidth = 0 ; var headerCount = myHeaders . Length ; if ( myVariableBounds != null ) { EnsureColumnWidths ( controlWidth ) ; var floatTotal = 0f ; var prevFloatTotal = 0f ; for ( var i = 0 ; i < headerCount ; ++ i ) { prevFloatTotal = floatTotal ; floatTotal += myColumnWidths [ i ] ; testWidth = ( int ) ( floatTotal + .5f ) ; if ( x < testWidth ) { column = i ; itemLeft = ( int ) ( prevFloatTotal + .5f ) ; itemWidth = testWidth - itemLeft ; break ; } } if ( column == - 1 ) { column = headerCount - 1 ; itemLeft = ( int ) ( prevFloatTotal + .5f ) ; itemWidth = controlWidth - itemLeft ; } } else { for ( var i = 0 ; i < headerCount ; ++ i ) { testWidth = myHeaders [ i ] . Width ; if ( x < testWidth ) { column = i ; itemWidth = testWidth ; itemLeft = leftTotal ; break ; } leftTotal += testWidth ; x -= testWidth ; } if ( column == - 1 ) { column = headerCount - 1 ; itemLeft = leftTotal - testWidth ; itemWidth = controlWidth - itemLeft ; } } return column ; }
Determine the column for a given hit point, as well as the
left and width of the column.
Determine the column for a given hit point as well as the left and width of the column .
// See if any of our columns have moved below the minimal width // Keep this consistent with GetVariableColumnBounds/GetColumnBounds
The column x is in
The column x is in
controlWidth
int
The current width of the control.
The current width of the control .
x
int
The x offset into row
The x offset into row
int
out
itemLeft
The left edge of this column
The left edge of this column
itemWidth
The width of this column
The width of this column