/// <summary>
 /// ChessSquare Constructor
 /// </summary>
 public ChessSquare()
 {
     chessLocation = new Point(0,0);
     startLocation = new Point(0,0);
     chessPiece = null;
     isLastMove = false;
     squareID = EnumSquareID.A1;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// SetChessSquareID Accessor
 /// </summary>
 /// <param name="aSquareID"></param>
 public void SetID(EnumSquareID aSquareID)
 {
     squareID = aSquareID;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// GetSquareByID method
        /// </summary>
        /// <param name="aLocation"></param>
        /// <returns>ChessSquare</returns>
        public ChessSquare GetSquareByID(EnumSquareID aSquareID)
        {
            ChessSquare square;
            for (int i = 0; i < ChessImageConstants.SquareCount; i++)
            {
                square = (ChessSquare)squareList[i];

                if (square != null)
                {
                    if (square.GetChessSquareID() == aSquareID)
                    {
                        return square;
                    }
                }
            }
            return null;
        }
 public static EnumSquareID IncrementEnumSquareID(EnumSquareID id)
 {
     if (id == EnumSquareID.ER)
         return id;
     else
         return id + 1;
 }
 //private bool isHighlight;
 //private bool isLastMove;
 /// <summary>
 /// ChessSquare Constructor
 /// </summary>
 public ChessSquare()
 {
     chessLocation = new Point(0, 0);
     startLocation = new Point(0, 0);
     squareID = EnumSquareID.A1;
 }
        /// <summary>
        /// SetChessLocation Accessor
        /// </summary>
        /// <param name="aLocation"></param>
        public void SetChessLocation(Point aLocation)
        {
            if ((aLocation.X < 0) || (aLocation.X > 7) || (aLocation.Y < 0) || (aLocation.Y > 7))
                throw (new Exception(String.Format(
                    "Square.SetChessLocation : Invalid Location ({0},{1})", aLocation.X, aLocation.Y)));

            // the new FEN AN way
            squareID = GetSquareIDfromLocation(aLocation);

            // the original location way
            chessLocation = aLocation;
        }
        /// <summary>
        /// GetSquareIDfromLocation
        /// </summary>
        /// <param name="aLocation"></param>
        /// <returns>EnumSquareID</returns>
        public EnumSquareID GetSquareIDfromLocation(Point aLocation)
        {
            // the Chess Square Designation Way using Algebraic Notation
            uint theFile = 0;
            uint theRank = 0;
            uint aFile = 0;
            uint aRank = 0;
            uint j = 1;
            while (j <= ChessImageConstants.SquareCount)
            {
                theFile = (uint)aLocation.X + 1;
                theRank = (uint)aLocation.Y + 1;

                aFile = 1 + ((j - 1) % 8);
                aRank = 8 - ((j - 1) / 8);

                if (theFile == aFile && theRank == aRank)
                {
                    squareID = (EnumSquareID)(((aRank - 1) * 8) + (aFile - 1));
                    break;
                }
                j++;
            }
            return squareID;
        }
 public static EnumSquareID DecrementEnumSquareID(EnumSquareID id)
 {
     if (id == EnumSquareID.A1)
         return id;
     else
         return id - 1;
 }