// Called when click on any chess squar object
        private void Squar_Click(object sender, System.EventArgs e)
        {
            if (m_ParentGame.IsRunning && !m_ParentGame.ChessGame.ActivePlay.IsComputer())
            {
                Squar ChessSquar = (Squar)sender;


                m_ParentGame.SelectedSquar = ChessSquar.Name;
                m_ParentGame.RedrawBoard();
            }
        }
Ejemplo n.º 2
0
        // Called when click on any chess square object
        private void Squar_Click(object sender, System.EventArgs e)
        {
            if (m_ParentGame.IsRunning && !m_ParentGame.ChessGame.ActivePlay.IsComputer())
            {
                Squar ChessSquar = (Squar)sender;
                //              m_ParentGame.Sounds.PlayClick();
                style.AppendTextWithHint(ChessSquar.Name, SayAs.SpellOut);
                sSynth.Speak(style);  // audio output coordinates of clicked empty square
                style.ClearContent();

                m_ParentGame.SelectedSquar = ChessSquar.Name;
                m_ParentGame.RedrawBoard();
            }
        }
Ejemplo n.º 3
0
        // Builds the chess pieces place holder images controls
        public void BuildBoard()
        {
            Squars = new ArrayList();                   // Initialize place holder pictures

            // Now dynamically draw all the chess pieces place holder images
            for (int row = 1; row <= 8; row++)                  // repeat for every row in the chess board
            {
                for (int col = 1; col <= 8; col++)              // repeat for every column in the chess board row
                {
                    Squar ChessSquar = new Squar(row, col, this);
                    ChessSquar.SetBackgroundSquar(ChessImages);                         // Set the chess squar background
                    Squars.Add(ChessSquar);
                    ParentForm.Controls.Add(ChessSquar);
                }
            }
        }
Ejemplo n.º 4
0
        // Redraw the image list
        public void RefreshList()
        {
            foreach (Squar sqr in Squars)
            {
                sqr.DrawPiece(null);
            }

            // Draw last added images in the available list
            int iStart = 0, iIndex = 0;

            if (Images.Count > Squars.Count)
            {
                iStart = Images.Count - Squars.Count;
            }

            for (; iStart < Images.Count; iStart++)
            {
                Squar sqr = (Squar)Squars[iIndex++];
                sqr.DrawPiece((Image)Images[iStart]);
            }
        }
Ejemplo n.º 5
0
        public void InitializeBar(Images ImagesList)
        {
            ChessImages = ImagesList;

            // TODO: Add any initialization after the InitializeComponent call
            for (int col = 1; col <= 12; col++)         // repeat for every column in the chess board row
            {
                Squar ChessSquar = new Squar(col, 1, null);
                //ChessSquar.SetBackgroundSquar(ChessImages);	// Set the chess squar background

                if ((col) % 2 == 0)             // White cell
                {
                    ChessSquar.BackgroundImage = ImagesList["White2"];
                }
                else
                {
                    ChessSquar.BackgroundImage = ImagesList["Black2"];
                }
                Squars.Add(ChessSquar);
                this.Controls.Add(ChessSquar);
            }
        }
Ejemplo n.º 6
0
        // Redraw the visible board from the internal chess board
        public void RedrawBoard()
        {
            foreach (Squar ChessSquar in Squars)
            {
                if (ChessSquar.BackgroundImage == null)               // background image doesn't exists
                {
                    ChessSquar.SetBackgroundSquar(ChessImages);
                }

                if (ChessGame.Board[ChessSquar.Name] != null)                                                   // Valid board squar
                {
                    ChessSquar.DrawPiece(ChessImages.GetImageForPiece(ChessGame.Board[ChessSquar.Name].piece)); // draw the chess piece image
                }
                if (ChessSquar.Name == SelectedSquar && ShowMoveHelp == true)                                   // selected check box
                {
                    ChessSquar.BackgroundImage = null;
                    ChessSquar.BackColor       = System.Drawing.Color.Thistle;
                }
            }


            // Check if need to show the possible legal moves for the current selected piece
            if (SelectedSquar != null && SelectedSquar != "" && ShowMoveHelp == true && ChessGame.Board[SelectedSquar].piece != null && !ChessGame.Board[SelectedSquar].piece.IsEmpty() && ChessGame.Board[SelectedSquar].piece.Side.type == ChessGame.GameTurn)
            {
                ArrayList moves = ChessGame.GetLegalMoves(ChessGame.Board[SelectedSquar]);                      // Get all legal moves for the current selected item

                // Hightlight all the possible moves for the current player
                foreach (Cell cell in moves)
                {
                    Squar sqr = GetBoardSquar(cell.ToString());                         // get the board by cell position
                    sqr.BackgroundImage = null;
                    // Show a semi-transparent, saddle color
                    sqr.BackColor = System.Drawing.Color.FromArgb(200, System.Drawing.Color.SaddleBrown);
                }
            }
            SelectedSquar = "";                 // Reset the selected squar position
        }
Ejemplo n.º 7
0
        // Redraw the visible board from the internal chess board
        public void RedrawBoard()
        {
            foreach (Squar ChessSquar in Squars)
            {
                if (ChessSquar.BackgroundImage == null)               // if background image doesn't exist
                {
                    ChessSquar.SetBackgroundSquar(ChessImages);
                }

                if (ChessGame.Board[ChessSquar.Name] != null)                                                   // Valid board square
                {
                    ChessSquar.DrawPiece(ChessImages.GetImageForPiece(ChessGame.Board[ChessSquar.Name].piece)); // draw the chess piece image
                }
                if (ChessSquar.Name == SelectedSquar && ShowMoveHelp == true)                                   // selected check box
                {
                    ChessSquar.BackgroundImage = null;
                    ChessSquar.BackColor       = System.Drawing.Color.Thistle;
                }
            }

            if (SelectedSquar != null && SelectedSquar != "" && ChessGame.Board[SelectedSquar].piece != null && !ChessGame.Board[SelectedSquar].piece.IsEmpty())
            {
                if (ChessGame.Board[SelectedSquar].piece.Side.isWhite())
                {
                    sSynth.SpeakAsync("player");
                }
                if (ChessGame.Board[SelectedSquar].piece.Side.isBlack())
                {
                    sSynth.SpeakAsync("computer");
                }

                if (ChessGame.Board[SelectedSquar].piece.IsPawn())
                {
                    style.AppendTextWithPronunciation("pawn", "ˈpːɒɳ");
                }
                else
                {
                    style.AppendText(ChessGame.Board[SelectedSquar].piece.ToString(), PromptEmphasis.Strong);   // identify piece at selected square
                }
                sSynth.SpeakAsync(style);
                style.ClearContent();
            }

            // Check if need to show the possible legal moves for the current selected piece
            if (SelectedSquar != null && SelectedSquar != "" && ShowMoveHelp == true && ChessGame.Board[SelectedSquar].piece != null && !ChessGame.Board[SelectedSquar].piece.IsEmpty() && ChessGame.Board[SelectedSquar].piece.Side.type == ChessGame.GameTurn)
            {
                ArrayList moves = ChessGame.GetLegalMoves(ChessGame.Board[SelectedSquar]);    // Get all legal moves for the current selected item

                // highlight all the possible moves for the current player
                if (moves.Count != 0)
                {
                    sSynth.SpeakAsync("Available moves are ");                   // speak coordinates of clicked square
                }
                foreach (Cell cell in moves)
                {
                    Squar sqr = GetBoardSquar(cell.ToString());   // get the board by cell position
//                  sqr.BackgroundImage = null;
                    // Show a semi-transparent, saddle color
//                     sqr.BackColor = System.Drawing.Color.FromArgb(200, System.Drawing.Color.SteelBlue);
                }
            }
            SelectedSquar = "";                 // Reset the selected square position
        }