예제 #1
0
파일: Fifteen.cs 프로젝트: Akio532/lab4
        private void button0_Click(object sender, EventArgs e)
        {
            int position = Convert.ToInt32(((Button_main)sender).Tag);

            game.Shift(position);
            label1.Text = (game.counter).ToString();
            RefreshButtonField();
            if (game.Check())
            {
                gameTimer1.Stop();
                string       s      = gameTimer1.Timeinfo();
                DialogResult result = MessageBox.Show($"Ваше время: {s}. Начать новую игру?", "Победа!", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    label1.Text = 0.ToString();
                    StartGame();
                    gameTimer1.Start();
                    game.counter = 0;
                }
                else
                {
                    Close();
                }
            }
        }
예제 #2
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            int position = Convert.ToInt32(((Button)sender).Tag);

            game.Shift(position);
            CountOfMoves.Content = (game.counter).ToString();
            RefreshButtonField();
            if (game.Check())
            {
                timer1.Stop();
                MessageBoxResult result = MessageBox.Show("Начать новую игру?", "Победа!", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    object          s  = sender;;
                    RoutedEventArgs e1 = e;
                    time = 0;
                    timer1.Start();
                    StartGame(s, e1);
                    CountOfMoves.Content = "0";
                    game.counter         = 0;
                }
                else
                {
                    Close();
                }
            }
        }
예제 #3
0
파일: Form1.cs 프로젝트: Akio532/lab4
        private void ButtonClick(object sender, EventArgs e)
        {
            label1.Text = "0";
            int position = Convert.ToInt32(((Button)sender).Tag);

            game.Shift(position);
            label1.Text = (game.counter).ToString();
            RefreshButtonField();
            if (game.Check())
            {
                timer1.Enabled = false;
                DialogResult result = MessageBox.Show("Начать новую игру?", "Победа!", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    label1.Text = 0.ToString();
                    StartGame();
                    date1          = new DateTime(0, 0);
                    timer1.Enabled = true;
                    game.counter   = 0;
                }
                else
                {
                    Close();
                }
            }
        }
예제 #4
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            int position = Convert.ToInt32(((Button)sender).Tag);

            game.Shift(position);
            RefreshButtonField();
            (info.Items[1] as StatusBarItem).Content = game.counter.ToString();
            if (game.counter > 0)
            {
                (menu.Items[2] as MenuItem).IsEnabled = true;
            }
            if (game.Check())
            {
                timer1.Stop();
                MessageBoxResult result = MessageBox.Show("Начать новую игру?", "Победа!", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    time = 0;
                    timer1.Start();
                    StartGame(sender, e);
                    (info.Items[1] as StatusBarItem).Content = "0";
                    game.counter = 0;
                }
                else
                {
                    Close();
                }
            }
        }