예제 #1
0
        private async void PropertyChangedEventHandler(Object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("GameState"))
            {
                GameState state = this.model.GameState;

                await this.HandleGameStateChanged(state);
            }
            else if (e.PropertyName.Equals("BoardStateChanges"))
            {
                ViewCellList list = this.model.BoardStateChanges;

                this.Model_BoardChanged(list);
            }
            else if (e.PropertyName.Equals("Level"))
            {
                this.Level = this.model.Level;
            }
            else if (e.PropertyName.Equals("Lines"))
            {
                this.Lines = this.model.Lines;
            }
            else if (e.PropertyName.Equals("Score"))
            {
                this.Score = this.model.Score;
            }
        }
예제 #2
0
        // private helper methods
        private void Model_BoardChanged(ViewCellList list)
        {
            for (int i = 0; i < list.Length; i++)
            {
                ViewCell viewCell = list[i];

                int index = viewCell.Point.Y * this.model.NumColumns + viewCell.Point.X;

                Color color =
                    (viewCell.Color == CellColor.LightGray) ? Color.Gray :
                    (viewCell.Color == CellColor.Magenta) ? Color.Navy :
                    (viewCell.Color == CellColor.Red) ? Color.Red :
                    (viewCell.Color == CellColor.Cyan) ? Color.Fuchsia :
                    (viewCell.Color == CellColor.Blue) ? Color.Blue :
                    (viewCell.Color == CellColor.Ocker) ? Color.Maroon :
                    (viewCell.Color == CellColor.Red) ? Color.Red :
                    (viewCell.Color == CellColor.Green) ? Color.Green :
                    Color.Yellow;

                this.board[index].CellColor = color;
            }
        }