Azmyth.Editor.GridControl.IsSelected C# (CSharp) Method

IsSelected() public method

public IsSelected ( int x, int y ) : bool
x int
y int
return bool
        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;
        }

Same methods

GridControl::IsSelected ( Point p ) : bool
GridControl::IsSelected ( TerrainTile room ) : bool