示例#1
0
        private void UpdateView()
        {
            this.ShowTurn();

            this.UpdateDeadPiecesViews();

            //updating board.
            for (int i = 0; i < this.buttonArray.Length; i++)
            {
                for (int j = 0; j < this.buttonArray.Length; j++)
                {
                    BoardButton presentButton = this.buttonArray[i][j];
                    BoardSpace  presentSpace  = this.boardModel.GetBoardSpace(i, j); //MAYBE REPLACE BY GETTER

                    if (mode == 0)                                                   //if mode is now chose piece, we clear the possible destinations.
                    {
                        presentButton.ClearValue(BoardButton.BackgroundProperty);    //clears background color
                        presentSpace.IsPossibleDestination = false;
                    }

                    if (presentSpace.IsPossibleDestination)
                    {
                        presentButton.Background = Brushes.Red;
                    }

                    if (!presentSpace.IsPossibleDestination &&
                        (!presentSpace.Occupied ||
                         presentSpace.Piece.Color != this.turn))
                    {
                        presentButton.IsEnabled = false;
                    }
                    else
                    {
                        presentButton.IsEnabled = true;
                    }

                    //Condition in case we're in chose destination mode
                    //only destinations and the pressed button are enabled
                    if (this.mode == 1 &&
                        !presentSpace.IsPossibleDestination &&
                        !presentButton.Equals(this.lastPressed))
                    {
                        presentButton.IsEnabled = false;
                    }

                    presentButton.Content = presentSpace.GetBoardSpaceChar();

                    Debug.WriteLine(presentSpace.ToString());//REMOVE
                }
            }
        }
        private void UpdateView()
        {
            this.ShowTurn();

            this.UpdateDeadPiecesViews();

            //aktualizowanie planszy
            for (int i = 0; i < this.buttonArray.Length; i++)
            {
                for (int j = 0; j < this.buttonArray.Length; j++)
                {
                    BoardButton presentButton = this.buttonArray[i][j];
                    BoardSpace  presentSpace  = this.boardModel.GetBoardSpace(i, j);

                    if (mode == 0)   //pokazuje mozliwe miejsca docelowe figury.
                    {
                        presentButton.ClearValue(BoardButton.BackgroundProperty);
                        presentSpace.IsPossibleDestination = false;
                    }

                    if (presentSpace.IsPossibleDestination)
                    {
                        presentButton.Background = Brushes.Green;
                    }

                    if (!presentSpace.IsPossibleDestination &&
                        (!presentSpace.Occupied ||
                         presentSpace.Piece.Color != this.turn))
                    {
                        presentButton.IsEnabled = false;
                    }
                    else
                    {
                        presentButton.IsEnabled = true;
                    }

                    //w chwili wybrania figury
                    //tylko przycisk i miejsca docelowe sa pokazane
                    if (this.mode == 1 &&
                        !presentSpace.IsPossibleDestination &&
                        !presentButton.Equals(this.lastPressed))
                    {
                        presentButton.IsEnabled = false;
                    }

                    presentButton.Content = presentSpace.GetBoardSpaceChar();

                    Debug.WriteLine(presentSpace.ToString());
                }
            }
        }