public bool IsSelected(int x, int y)
{
Rectangle rect;
bool isSelected = false;
Point selection = m_selectedCellLocation;
int selectionWidth = (int)(m_selectionSize / (m_cellWidth * m_scale));
int selectionHeight = (int)(m_selectionSize / (m_cellHeight * m_scale));
switch (m_selectionShape)
{
case ToolShape.Square:
selection.Offset(((selectionWidth + 1) / -2), ((selectionHeight + 1) / -2));
rect = new Rectangle(selection, new Size(selectionWidth + 1, selectionHeight + 1));
if (rect.IntersectsWith(new Rectangle(x, y, 1, 1)))
{
isSelected = true;
}
break;
case ToolShape.Circle:
selection.Offset(((selectionWidth + 2) / -2), ((selectionHeight + 2) / -2));
rect = new Rectangle(selection, new Size(selectionWidth + 1, selectionHeight + 1));
m_graphicsPath.Reset();
m_graphicsPath.AddEllipse(rect);
if (m_graphicsPath.IsVisible(new Point(x, y)))
{
isSelected = true;
}
break;
case ToolShape.Point:
rect = new Rectangle(selection, new Size(1, 1));
if (rect.IntersectsWith(new Rectangle(x, y, 1, 1)))
{
isSelected = true;
}
break;
}
return isSelected;
}