src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/UI/VirtualTreeControl.cs
/// <summary>
///     Determine the column for a given hit point, as well as the
///     left and width of the column. The values returned here are
///     not adjusted by the horizontal scrollbar position.
/// </summary>
/// <param name="x">The x offset into row (unadjusted)</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. The values returned here are
not adjusted by the horizontal scrollbar position.
Determine the column for a given hit point as well as the left and width of the column . The values returned here are not adjusted by the horizontal scrollbar position .
private int ColumnHitTest(int x, out int itemLeft, out int itemWidth)
        {
            var column = 0;
            var columns = (myColumnPermutation != null) ? myColumnPermutation.VisibleColumnCount : myMctree.ColumnCount;
            var adjustLeft = false;
            var adjustRight = false;
            if (!HasVerticalScrollBar)
            {
                if (LeftScrollBar)
                {
                    adjustLeft = true;
                }
                else if (column == (columns - 1))
                {
                    adjustRight = true;
                }
            }
            var fullPercentWidth = FullPercentageHeaderWidth;
            itemLeft = 0;
            itemWidth = 0;
            if (adjustLeft)
            {
                itemLeft = SystemInformation.VerticalScrollBarWidth;
                if (x < itemLeft)
                {
                    if (!myHeaderBounds.HasHeaders)
                    {
                        itemWidth = fullPercentWidth / columns + itemLeft;
                    }
                    else
                    {
                        var cacheLeft = itemLeft;
                        myHeaderBounds.GetColumnBounds(fullPercentWidth, 0, 0, out itemLeft, out itemWidth);
                        itemWidth += cacheLeft;
                    }
                    itemLeft = 0;
                    return 0;
                }
                else
                {
                    x -= itemLeft;
                }
            }
            int columnWidth;
            if (!myHeaderBounds.HasHeaders)
            {
                columnWidth = fullPercentWidth / columns;
                while (x > columnWidth)
                {
                    x -= columnWidth;
                    ++column;
                }
                itemLeft += column * columnWidth;
                itemWidth = columnWidth;
            }
            else
            {
                int leftIncr;
                column = myHeaderBounds.ColumnHitTest(fullPercentWidth, x, out leftIncr, out itemWidth);
                itemLeft += leftIncr;
            }
            if (adjustRight)
            {
                if (column == (columns - 1))
                {
                    itemWidth += SystemInformation.VerticalScrollBarWidth;
                }
            }
            else if (adjustLeft && column == 0)
            {
                itemLeft = 0;
                itemWidth += SystemInformation.VerticalScrollBarWidth;
            }
            return column;
        }
private int ColumnHitTest ( int x , out int itemLeft , out int itemWidth ) { var column = 0 ; var columns = ( myColumnPermutation != null ) ? myColumnPermutation . VisibleColumnCount : myMctree . ColumnCount ; var adjustLeft = false ; var adjustRight = false ; if ( ! HasVerticalScrollBar ) { if ( LeftScrollBar ) { adjustLeft = true ; } else if ( column == ( columns - 1 ) ) { adjustRight = true ; } } var fullPercentWidth = FullPercentageHeaderWidth ; itemLeft = 0 ; itemWidth = 0 ; if ( adjustLeft ) { itemLeft = SystemInformation . VerticalScrollBarWidth ; if ( x < itemLeft ) { if ( ! myHeaderBounds . HasHeaders ) { itemWidth = fullPercentWidth / columns + itemLeft ; } else { var cacheLeft = itemLeft ; myHeaderBounds . GetColumnBounds ( fullPercentWidth , 0 , 0 , out itemLeft , out itemWidth ) ; itemWidth += cacheLeft ; } itemLeft = 0 ; return 0 ; } else { x -= itemLeft ; } } int columnWidth ; if ( ! myHeaderBounds . HasHeaders ) { columnWidth = fullPercentWidth / columns ; while ( x > columnWidth ) { x -= columnWidth ; ++ column ; } itemLeft += column * columnWidth ; itemWidth = columnWidth ; } else { int leftIncr ; column = myHeaderBounds . ColumnHitTest ( fullPercentWidth , x , out leftIncr , out itemWidth ) ; itemLeft += leftIncr ; } if ( adjustRight ) { if ( column == ( columns - 1 ) ) { itemWidth += SystemInformation . VerticalScrollBarWidth ; } } else if ( adjustLeft && column == 0 ) { itemLeft = 0 ; itemWidth += SystemInformation . VerticalScrollBarWidth ; } 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 .
The column x is in
The column x is in
x
int
The x offset into row (unadjusted)
The x offset into row ( unadjusted )
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