Exemplo n.º 1
0
        // Reset bàn cờ
        public void ResetBoard()
        {
            boardViewModel.CurrentBoard.ResetBoard();
            var brush1 = new ImageBrush();

            brush1.ImageSource = new BitmapImage(new Uri("Picture/c.png", UriKind.RelativeOrAbsolute));

            for (int i = 0; i < 12; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    this.Dispatcher.Invoke((Action)(() => { wpnBanCo.Children.Remove(CaroTable[i, j]); }));
                }
            }

            for (int i = 0; i < 12; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    CaroTable[i, j]            = new CaroButton();
                    CaroTable[i, j].m_X        = i;
                    CaroTable[i, j].m_Y        = j;
                    CaroTable[i, j].Background = brush1;
                    CaroTable[i, j].Width      = 40;
                    CaroTable[i, j].Height     = 40;
                    wpnBanCo.Children.Add(CaroTable[i, j]);
                    CaroTable[i, j].Click += CaroButtonTable_Click;
                }
            }
        }
Exemplo n.º 2
0
        // sự kiện lick
        private void CaroButtonTable_Click(object sender, RoutedEventArgs e)
        {
            CaroButton cell = (CaroButton)sender;


            if (boardViewModel.CurrentBoard.CheckNone(cell.Y, cell.X))
            {
                if (m_TypePlay == 1)
                {
                    if (boardViewModel.CurrentBoard.ActivePlayer == CellValues.Player1)
                    {
                        cell.Content = setPicture("Picture/Player1.png");
                    }

                    else
                    {
                        cell.Content = setPicture("Picture/Player2.png");
                    }
                    boardViewModel.CurrentBoard.PlayAt(cell.Y, cell.X, m_TypePlay);
                }
                else if (m_TypePlay == 2)
                {
                    cell.Content = setPicture("Picture/Player1.png");
                    boardViewModel.CurrentBoard.PlayAt(cell.Y, cell.X, m_TypePlay);
                }

                else if (m_TypePlay == 3 && m_player == CellValues.Player1)
                {
                    if (socket.m_StartGame == true)
                    {
                        cell.Content = setPicture("Picture/Player1.png");
                        boardViewModel.CurrentBoard.PlayAt(cell.Y, cell.X, 1);
                        socket.SendPoint(new Point(cell.Y, cell.X));
                        m_player = CellValues.Player2;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void wpnBanCo_Loaded(object sender, RoutedEventArgs e)
        {
            var brush1 = new ImageBrush();

            brush1.ImageSource = new BitmapImage(new Uri("Picture/c.png", UriKind.RelativeOrAbsolute));
            var brush2 = new ImageBrush();

            brush2.ImageSource = new BitmapImage(new Uri("Picture/c.png", UriKind.RelativeOrAbsolute));
            for (int i = 0; i < 12; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    CaroTable[i, j]            = new CaroButton();
                    CaroTable[i, j].m_X        = i;
                    CaroTable[i, j].m_Y        = j;
                    CaroTable[i, j].Background = brush1;
                    CaroTable[i, j].Width      = 40;
                    CaroTable[i, j].Height     = 40;
                    wpnBanCo.Children.Add(CaroTable[i, j]);
                    CaroTable[i, j].Click += CaroButtonTable_Click;
                }
            }
        }
Exemplo n.º 4
0
 private void wpnBanCo_Loaded(object sender, RoutedEventArgs e)
 {
     var brush1 = new ImageBrush();
     brush1.ImageSource = new BitmapImage(new Uri("Picture/c.png", UriKind.RelativeOrAbsolute));
     var brush2 = new ImageBrush();
     brush2.ImageSource = new BitmapImage(new Uri("Picture/c.png", UriKind.RelativeOrAbsolute));
     for (int i = 0; i < 12; i++)
         for (int j = 0; j < 12; j++)
         {
             CaroTable[i, j] = new CaroButton();
             CaroTable[i, j].m_X = i;
             CaroTable[i, j].m_Y = j;
             CaroTable[i, j].Background = brush1;
             CaroTable[i, j].Width = 40;
             CaroTable[i, j].Height = 40;
             wpnBanCo.Children.Add(CaroTable[i, j]);
             CaroTable[i, j].Click += CaroButtonTable_Click;
         }
 }
Exemplo n.º 5
0
        // Reset bàn cờ
        public void ResetBoard()
        {
            boardViewModel.CurrentBoard.ResetBoard();
            var brush1 = new ImageBrush();
            brush1.ImageSource = new BitmapImage(new Uri("Picture/c.png", UriKind.RelativeOrAbsolute));

            for (int i = 0; i < 12; i++ )
            {
                for(int j = 0; j < 12; j++)
                    this.Dispatcher.Invoke((Action)(() => { wpnBanCo.Children.Remove(CaroTable[i, j]); }));
            }

            for (int i = 0; i < 12; i++)
                for (int j = 0; j < 12; j++)
                {
                    CaroTable[i, j] = new CaroButton();
                    CaroTable[i, j].m_X = i;
                    CaroTable[i, j].m_Y = j;
                    CaroTable[i, j].Background = brush1;
                    CaroTable[i, j].Width = 40;
                    CaroTable[i, j].Height = 40;
                    wpnBanCo.Children.Add(CaroTable[i, j]);
                    CaroTable[i, j].Click += CaroButtonTable_Click;
                }
        }