public Square CoordinateToSquare(int x, int y) { if (x > FactoredEdgeWidth && x < (FactoredSquareWidth * 8) + FactoredEdgeWidth && y > FactoredEdgeHeight && y < (FactoredSquareHeight * 8) + FactoredEdgeHeight) { int file = (x - FactoredEdgeWidth) / FactoredSquareWidth; int rank = (y - FactoredEdgeHeight) / FactoredSquareHeight; if (m_viewFromBlack) { file = 7 - file; } else { rank = 7 - rank; } return(ChessFacade.Position(file, rank)); } return(Square.None); }