Exemple #1
0
        /// <summary>
        /// Add the current move of the board
        /// </summary>
        private void AddCurrentMove()
        {
            MoveItem moveItem;
            string   strMove;
            string   strMoveIndex;
            int      iMoveCount;
            int      iItemCount;
            int      iIndex;

            ChessBoard.MovePosS     movePos;
            ChessBoard.PlayerColorE ePlayerToMove;

            m_bIgnoreChg  = true;
            movePos       = m_chessBoard.MovePosStack.CurrentMove;
            ePlayerToMove = m_chessBoard.CurrentMoveColor;
            m_chessBoard.UndoMove();
            iMoveCount = m_chessBoard.MovePosStack.Count;
            iItemCount = listViewMoveList.Items.Count;
            while (iItemCount >= iMoveCount)
            {
                iItemCount--;
                MoveList.RemoveAt(iItemCount);
            }
            strMove = GetMoveDesc(movePos);
            m_chessBoard.RedoMove();
            iIndex       = iItemCount;
            strMoveIndex = (m_eDisplayMode == DisplayModeE.MovePos) ? (iIndex + 1).ToString() : (iIndex / 2 + 1).ToString() + ((Char)('a' + (iIndex & 1))).ToString();
            moveItem     = new MoveItem(strMoveIndex,
                                        (ePlayerToMove == ChessBoard.PlayerColorE.Black) ? "Black" : "White",
                                        strMove);
            MoveList.Add(moveItem);
            m_bIgnoreChg = false;
        }
Exemple #2
0
        /// <summary>
        /// Redisplay all the moves using the current setting
        /// </summary>
        private void Redisplay()
        {
            string[]     arrMoveName;
            int          iMoveCount;
            MovePosStack movePosStack;
            MoveExt      move;
            string       strMove;
            string       strMoveIndex;
            MoveItem     moveItem;
            ChessBoard   chessBoard;

            chessBoard = m_chessCtl.Board;
            if (chessBoard != null)
            {
                movePosStack = chessBoard.MovePosStack;
                iMoveCount   = movePosStack.Count;
                if (iMoveCount != 0)
                {
                    if (m_eDisplayMode == DisplayModeE.MovePos)
                    {
                        arrMoveName = null;
                    }
                    else
                    {
                        arrMoveName = PgnUtil.GetPGNArrayFromMoveList(chessBoard);
                    }
                    for (int iIndex = 0; iIndex < iMoveCount; iIndex++)
                    {
                        move = movePosStack[iIndex];
                        if (m_eDisplayMode == DisplayModeE.MovePos)
                        {
                            strMove      = ChessBoard.GetHumanPos(move);
                            strMoveIndex = (iIndex + 1).ToString();
                        }
                        else
                        {
                            strMove      = arrMoveName[iIndex];
                            strMoveIndex = (iIndex / 2 + 1).ToString() + ((Char)('a' + (iIndex & 1))).ToString();
                        }
                        moveItem         = MoveList[iIndex];
                        MoveList[iIndex] = new MoveItem(strMoveIndex, moveItem.Who, strMove);
                    }
                }
            }
        }