protected void CalcTableState(int x, int y)
{
TableRegion region = this.HitTest(x, y);
// are we in the header
if (region == TableRegion.ColumnHeader)
{
int column = this.ColumnIndexAt(x, y);
// get out of here if we aren't in a column
if (column == -1)
{
this.TableState = TableState.Normal;
return;
}
// get the bounding rectangle for the column's header
Rectangle columnRect = this.ColumnModel.ColumnHeaderRect(column);
x = this.ClientXToDisplayRectX(x);
// are we in a resizing section on the left
if (x < columnRect.Left + Column.ResizePadding)
{
this.TableState = TableState.ColumnResizing;
while (column != 0)
{
if (this.ColumnModel.Columns[column - 1].Visible)
{
break;
}
column--;
}
// if we are in the first visible column or the next column
// to the left is disabled, then we should be potentialy
// selecting instead of resizing
if (column == 0 || !this.ColumnModel.Columns[column - 1].Enabled)
{
this.TableState = TableState.ColumnSelecting;
}
// Mateusz [PEYN] Adamus ([email protected])
// If next column to the left has RESIZABLE set to false
// then we can't resize it
if ((column != 0)
&& (!this.ColumnModel.Columns[column - 1].Resizable))
{
this.TableState = TableState.ColumnSelecting;
}
}
// or a resizing section on the right
else if ((x > columnRect.Right - Column.ResizePadding)
// Mateusz [PEYN] Adamus ([email protected])
// but only if column can be resized
&& (this.ColumnModel.Columns[column].Resizable))
{
this.TableState = TableState.ColumnResizing;
}
// looks like we're somewhere in the middle of
// the column header
else
{
this.TableState = TableState.ColumnSelecting;
}
}
else if (region == TableRegion.Cells)
{
this.TableState = TableState.Selecting;
}
else
{
this.TableState = TableState.Normal;
}
if (this.TableState == TableState.ColumnResizing && !this.ColumnResizing)
{
this.TableState = TableState.ColumnSelecting;
}
}