Exemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int position = Convert.ToInt32(((Button)sender).Tag);

            if (game.Shift(position))//перемещение
            {
                RefreshButtonField();
                count++;
                (info.Items[1] as StatusBarItem).Content = count.ToString();
            }
            if (game.Check())
            {
                timer1.Stop();
                MessageBoxResult result = MessageBox.Show("Вы хотите начать новую игру?", "Победа!", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    object          s  = sender;
                    RoutedEventArgs e1 = e;
                    StartGame(s, e1);
                    (info.Items[1] as StatusBarItem).Content = "0";
                    (info.Items[4] as StatusBarItem).Content = "0";
                }
                else
                {
                    Close();
                }
            }
        }
Exemplo n.º 2
0
        private void Button_Click(object sender, EventArgs e)
        {
            int position = Convert.ToInt32(((Button)sender).Tag);

            if (game.Shift(position))//перемещение
            {
                RefreshButtonField();
                count++;
                CountStatus.Text = count.ToString();
            }
            if (game.Check())//Завершение игры
            {
                Victory victory = new Victory(count, sec);
                victory.ShowDialog();
                GameStart();
            }
            this.ActiveControl = null;
        }