Пример #1
0
        private void StartGame_Click(object sender, RoutedEventArgs e)
        {
            board_layout = new Dictionary<int, ChessPiece>();
            if ((ComboBoxItem)ChooseColor.SelectedItem==null || (ComboBoxItem)ChooseLevel.SelectedItem==null)
            {
                MessageBoxResult result = MessageBox.Show("Please choose the color or level", "Confirmation", MessageBoxButton.OK);
                return;
            }

            if ((String)((ComboBoxItem)ChooseColor.SelectedItem).Content == "Black")
            {
                board = new MainControl(false, (String)((ComboBoxItem)ChooseLevel.SelectedItem).Content);
                board.MachinePlayer.MachineTimer.startClock();
            }
            else
            {
                board = new MainControl(true, (String)((ComboBoxItem)ChooseLevel.SelectedItem).Content);
                board.HumanPlayer.HumanTimer.startClock();
            }

            StartButton.IsEnabled = false;
            ChooseLevel.IsEnabled = false;
            ChooseColor.IsEnabled = false;
            SimulateButton.IsEnabled = false;

            player_timer.DataContext = board.HumanPlayer.HumanTimer;
            pc_timer.DataContext = board.MachinePlayer.MachineTimer;

            PlayerCapStack.ItemsSource = board.HumanPlayer.HumanCaptureStack.CapturedPiecesCollection;
            MachineCapStack.ItemsSource = board.MachinePlayer.MachineCaptureStack.CapturedPiecesCollection;

            this.ChessBoard.ItemsSource = board.BoardCollection;
        }
        private void StartGame_Click(object sender, RoutedEventArgs e)
        {
            board_layout = new Dictionary<int, ChessPiece>();

            if ((String)((ComboBoxItem)ChooseColor.SelectedItem).Content == "Black")
                board = new MainControl(false, (String)((ComboBoxItem)ChooseLevel.SelectedItem).Content);
            else
                board = new MainControl(true, (String)((ComboBoxItem)ChooseLevel.SelectedItem).Content);

            //Console.WriteLine("{0},{1}", ((ComboBoxItem)ChooseColor.SelectedItem).Content, ((ComboBoxItem)ChooseLevel.SelectedItem).Content);
            StartButton.IsEnabled = false;
            ChooseLevel.IsEnabled = false;
            ChooseColor.IsEnabled = false;

            player_timer.DataContext = board.HumanPlayer.HumanTimer;
            pc_timer.DataContext = board.MachinePlayer.MachineTimer;

            board.HumanPlayer.HumanTimer.startClock();

            PlayerCapStack.ItemsSource = board.HumanPlayer.HumanCaptureStack.CapturedPiecesCollection;
            MachineCapStack.ItemsSource = board.MachinePlayer.MachineCaptureStack.CapturedPiecesCollection;

            this.ChessBoard.ItemsSource = board.BoardCollection;
        }