Exemplo n.º 1
0
        /// <summary>
        /// The function will be executed when clicking cell button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CellClick(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            int    isWin  = playModel.IsWin(button);

            if (isWin == 1)
            {
                timerTwo.Stop();
                ShowMemoryView();
                WinWindow winWindow = new WinWindow(playModel.GameId, playModel.Level);
                musicPlayer.PlayWin();
                winWindow.ShowDialog();
                return;
            }
            else if (isWin == -1)
            {
                timerTwo.Stop();
                ShowMemoryView();
                musicPlayer.PlayButtonError();
                LoseWindow loseWindow = new LoseWindow(playModel.GameId, playModel.Level);
                loseWindow.ShowDialog();
                return;
            }
            musicPlayer.PlayButtonCorrect();
            //begin to record the time used
            if (isGameBegin == false)
            {
                isGameBegin = true;
                timerTwo.Start();
            }
        }