/// <summary>
 /// Invoke the 'SetGameEnded' event handler if it is set.
 /// </summary>
 /// <param name="arg">The event hadler argumentum.</param>
 private void OnSetGameEnded(ReversiSetGameEndedEventArgs arg)
 {
     if (SetGameEnded != null)
     {
         SetGameEnded(this, arg);
     }
 }
        /// <summary>
        /// We finished a game. We delete the last put downs backwords, then if it not ended
        /// (_remainingSteps[0,0] != 0) we set _remainingSteps[0,0] to 1.
        /// </summary>
        /// <param name="e"></param>
        private void removeStep(ReversiSetGameEndedEventArgs e)
        {
            if (e.Player1Points > e.Player2Points)
            {
                _possibleResults[0] += 1;
            }
            else if (e.Player1Points < e.Player2Points)
            {
                _possibleResults[1] += 1;
            }
            else
            {
                _possibleResults[2] += 1;
            }

            while (_remainingSteps[_remainingSteps[0, 0], 0] == 0)
            {
                --(_remainingSteps[0, 0]);
                if (_remainingSteps[_remainingSteps[0, 0], 0] != 0)
                { 
                    _remainingSteps[_remainingSteps[0, 0], 0] -= 2;
                }

                if (_remainingSteps[0,0] == 0)
                {
                    break;
                }
            }

            if (_remainingSteps[0, 0] != 0)
            {
                _remainingSteps[0, 0] = 1;
                _currentPassingCount = 0;
            }

            ++_possibleGameCount;
        }
        private void model_SetGameEnded(Object sender, ReversiSetGameEndedEventArgs e)
        {
            _eventSetGameEndedInvoked = true;

            if (!_simpleEvents)
            {
                removeStep(e);
            } 
        }
 /// <summary>
 /// The model told us the game is over.
 /// </summary>
 /// <param name="sender">The _model object, we do not use it as a param.</param>
 /// <param name="e">We get the points of the players.</param>
 private void model_SetGameEnded(Object sender, ReversiSetGameEndedEventArgs e)
 {
     _pauseButton.Enabled = false;
     _passButton.Enabled = false;
     _saved = true;
     _fileSaveToolStripMenuItem.Enabled = false;
     if (e.Player1Points > e.Player2Points)
     {
         MessageBox.Show("Player 1 won." + Environment.NewLine + "Player 1 points: " + e.Player1Points.ToString() + ", player 2 points: " + e.Player2Points.ToString() + ".", "Game Ended");
     }
     else if (e.Player1Points < e.Player2Points)
     {
         MessageBox.Show("Player 2 won." + Environment.NewLine + "Player 1 points: " + e.Player1Points.ToString() + ", player 2 points: " + e.Player2Points.ToString() + ".", "Game Ended");
     }
     else
     {
         MessageBox.Show("It is a tie." + Environment.NewLine + "Player 1 points: " + e.Player1Points.ToString() + ", player 2 points: " + e.Player2Points.ToString() + ".", "Game Ended");
     }
 }