Ejemplo n.º 1
0
        /// <summary>
        /// When the cell is clicked this is called.
        /// </summary>
        /// <param name="index">The tab index of the button, which was clicked.</param>
        private void MakePutDown(Int32 index)
        {
            ReversiCell cell = Cells[index];

            if (cell.Enabled == true)
            {
                _model.PutDown(cell.X, cell.Y);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update a cell.
        /// </summary>
        /// <param name="x">The X coordiante of the cell.</param>
        /// <param name="y">The Y coordiante of the cell.</param>
        /// <param name="value">The number which will tell us what to do. Read more about it in the model (_table).</param>
        public void UpdateCell(Int32 x, Int32 y, Int32 value)
        {
            Int32       index = ((x * _model.ActiveTableSize) + y);
            ReversiCell cell  = Cells[index];

            switch (value)
            {
            case -1:
                cell.Text         = "";
                cell.BackColorInt = 0;     // Color.White;
                cell.Enabled      = false;
                break;

            case 0:
                cell.Text         = "";
                cell.BackColorInt = 2;     // Color.YellowGreen;
                cell.Enabled      = false;
                break;

            case 1:
                cell.Text         = "";
                cell.BackColorInt = 1;     // Color.Black;
                cell.Enabled      = false;
                break;

            case 3:
                if (!_isPlayer1TurnOn)
                {
                    cell.Text         = "o";
                    cell.TextColorInt = 1;     // Color.Black;
                    cell.Enabled      = true;
                }
                else
                {
                    cell.Text    = "";
                    cell.Enabled = false;
                }

                cell.BackColorInt = 2;     // Color.YellowGreen;

                break;

            case 6:

                if (_isPlayer1TurnOn)
                {
                    cell.Text         = "o";
                    cell.TextColorInt = 0;     // Color.White;
                    cell.Enabled      = true;
                }
                else
                {
                    cell.Text    = "";
                    cell.Enabled = false;
                }

                cell.BackColorInt = 2;     // Color.YellowGreen;

                break;

            case 4:
                cell.Text = "o";
                if (_isPlayer1TurnOn)
                {
                    cell.TextColorInt = 0;     // Color.White;
                }
                else
                {
                    cell.TextColorInt = 1;     // Color.Black;
                }
                //cell.TextColorInt = 3 // Color.Gray;
                cell.Enabled = true;
                break;

            case 5:
                cell.Text         = "";
                cell.BackColorInt = 2;     // Color.YellowGreen;
                cell.Enabled      = false;

                break;

            default:
                throw new Exception("Model gave us a number, that we was not ready for, while updating the table view.");
            }
        }